aboutsummaryrefslogtreecommitdiff
path: root/nicla/signs_detect.py
diff options
context:
space:
mode:
Diffstat (limited to 'nicla/signs_detect.py')
-rw-r--r--nicla/signs_detect.py34
1 files changed, 23 insertions, 11 deletions
diff --git a/nicla/signs_detect.py b/nicla/signs_detect.py
index 57b6c3e..17d47c3 100644
--- a/nicla/signs_detect.py
+++ b/nicla/signs_detect.py
@@ -9,32 +9,40 @@ def init_kpts(str):
kpts = temp_img.find_keypoints(max_keypoints=128, threshold=kpts_threshold, corner_detector=kpts_corner, scale_factor=1.2)
return kpts
+speed = init_kpts("speed")
+stop = init_kpts("stop")
+car = init_kpts("image")
+
def match_kpts(kpts0, kpts1):
if kpts0 is not None and kpts1 is not None:
match = image.match_descriptor(kpts0, kpts1, threshold=70)
#print("matched:%d dt:%d"%(match.count(), match.theta()))
if match.count() > 0:
- print(match.count())
- return match.count() > 0
+ #print(match.count())
+ return match.count() > 0
else:
return 0
def read_red_sign(val, img, kpts):
+ data = 0x00
if match_kpts(kpts, stop):
- img.draw_rectangle(val.rect())
+ #img.draw_rectangle(val.rect())
#img.draw_cross(match.cx(), match.cy(), size=10)
#print("stop")
- return 0x01
- if match_kpts(kpts, speed):
- img.draw_rectangle(val.rect())
+ data = 0x01
+ elif match_kpts(kpts, speed):
+ #img.draw_rectangle(val.rect())
#print("speed")
- return 0x02
- if match_kpts(kpts, car):
- img.draw_rectangle(val.rect())
+ data = 0x02
+ elif match_kpts(kpts, car):
+ #img.draw_rectangle(val.rect())
#print("car")
- return 0x03
+ data = 0x03
+
+ return data
-#def read_red_sign(val, img, kpts):
+def read_blu_sign(val, img, kpts):
+ return 0x02
def sign_detection(img):
######## Detect signs
@@ -55,7 +63,11 @@ def sign_detection(img):
for index, b in enumerate(blobs_r):
sign_buffer = read_red_sign(b, img, kpts_img)
+ if sign_buffer != 0x00:
+ break
#for index, b in enumerate(blobs_b):
#sign_buffer = read_blu_sign(b, img, kpts_img)
+ #if sign_buffer != 0x00:
+ #break
return sign_buffer