diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2023-06-06 19:11:42 +0200 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2023-06-06 19:11:42 +0200 |
commit | da7cc5409372caeac64d46346877b5440e4a4383 (patch) | |
tree | fd5f36f67169fb65e96f2b1f0bedcbcc97d33ea7 /nicla/traffic_light.py | |
parent | d18a886418bf191ef427ec9276239ea2779e8439 (diff) |
Update traffic_light.py
Diffstat (limited to 'nicla/traffic_light.py')
-rw-r--r-- | nicla/traffic_light.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/nicla/traffic_light.py b/nicla/traffic_light.py index 517e2c3..7399523 100644 --- a/nicla/traffic_light.py +++ b/nicla/traffic_light.py @@ -31,9 +31,9 @@ def rgb2hsv(rgb): return (h, s, v) -def traf_lights(img) - original = img.copy() - img = img.to_grayscale() +def traf_lights(imgTraffic): + original = imgTraffic.copy() + img = imgTraffic.to_grayscale() for blob in img.find_blobs([(0, 60)], pixels_threshold=100): aspect = blob.h() / blob.w() if abs(aspect - 2.2) > 0.5: continue @@ -53,12 +53,21 @@ def traf_lights(img) if i == 1 and abs(h - 0.05) > 0.1: continue if i == 2 and abs(h - 0.40) > 0.1: continue light_status = i + 1 - print((h,s,v,)) + #print((h,s,v,)) break if light_status == 0: continue img.draw_rectangle(blob.rect()) img.draw_circle(lights[light_status-1][0], lights[light_status-1][1], 2) - print(("", "rood", "geel", "groen")[light_status]) + #print(("", "rood", "geel", "groen")[light_status]) sensor.dealloc_extra_fb() + + if light_status == 1: + return 0x06 + elif light_status == 2: + return 0x07 + elif light_status == 3: + return 0x08 + else: + return 0x01 |