aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2023-06-07 11:21:19 +0200
committerheavydemon21 <nielsstunnebrink1@gmail.com>2023-06-07 11:21:19 +0200
commitb62bcc004fc0dd3d53fbbaf02d3af516b7cb47e0 (patch)
treef084614790096f95d9dce8c30e9b5729dc2e3632
parent051f0284c9895282205632087a2de6d163073cee (diff)
integration
-rw-r--r--nicla/road.py26
-rw-r--r--nicla/signs_detect.py9
-rw-r--r--nicla/traffic_light.py2
3 files changed, 16 insertions, 21 deletions
diff --git a/nicla/road.py b/nicla/road.py
index 27101ea..5e5e1de 100644
--- a/nicla/road.py
+++ b/nicla/road.py
@@ -26,7 +26,6 @@ points = [(STRETCH, HORIZON),
(-SQUEEZE, HEIGHT-1)]
def drive(driveImg):
- img = driveImg.copy()
img.to_grayscale()
img.replace(vflip=True, hmirror=True)
img.rotation_corr(corners=points)
@@ -50,23 +49,24 @@ def drive(driveImg):
print(avg)
steerByte = int((avg + 1.0) * (DUI_CMD_STEER_END - DUI_CMD_STEER_START) / 2 + DUI_CMD_STEER_START)
uart.uart_buffer(steerByte)
- sensor.dealloc_extra_fb()
-count = 0
+
+
+speed = signs_detect.init_kpts("speed")
+stop = signs_detect.init_kpts("stop")
+car = signs_detect.init_kpts("image")
while(True):
- if count == 0:
- count = count + 1
- speed = signs_detect.init_kpts("speed")
- #stop = signs_detect.init_kpts("stop")
- #car = signs_detect.init_kpts("image")
- else:
+
img = sensor.snapshot()
data = traffic_light.traf_lights(img)
if data is not None:
uart.uart_buffer(data)
- #data_sign = signs_detect.sign_detection(img)
- #if data_sign is not None:
- #uart.uart_buffer(data_sign)
- drive(img)
+ sign_img = sensor.snapshot()
+ data_sign = signs_detect.sign_detection(sign_img)
+ if data_sign is not None:
+ uart.uart_buffer(data_sign)
+
+ drive_img = sensor.snapshot()
+ drive(drive_img)
#uart.uart_buffer(DUI_CMD_SPEED_END)
diff --git a/nicla/signs_detect.py b/nicla/signs_detect.py
index 775ac15..786972d 100644
--- a/nicla/signs_detect.py
+++ b/nicla/signs_detect.py
@@ -7,7 +7,6 @@ def init_kpts(str):
temp_img = image.Image(f"./{str}.jpg",copy_to_fb=True)
temp_img.to_grayscale()
kpts = temp_img.find_keypoints(max_keypoints=128, threshold=kpts_threshold, corner_detector=kpts_corner, scale_factor=1.2)
- temp_img.dealloc_extra_fb()
return kpts
def match_kpts(kpts0, kpts1):
@@ -37,8 +36,7 @@ def read_red_sign(val, img, kpts):
#def read_red_sign(val, img, kpts):
-def sign_detection(img_sign):
- img = img_sign.copy()
+def sign_detection(img):
######## Detect signs
blobs_r = img.find_blobs([(0, 100, 25, 63, -128, 127)])
blobs_b = img.find_blobs([(0, 29, 11, -128, -31, -5)])
@@ -58,7 +56,6 @@ def sign_detection(img_sign):
for index, b in enumerate(blobs_r):
sign_buffer = read_red_sign(b, img, kpts_img)
- for index, b in enumerate(blobs_b):
- sign_buffer = read_blu_sign(b, img, kpts_img)
- sensor.dealloc_extra_fb()
+ #for index, b in enumerate(blobs_b):
+ #sign_buffer = read_blu_sign(b, img, kpts_img)
return sign_buffer
diff --git a/nicla/traffic_light.py b/nicla/traffic_light.py
index 7399523..9499aea 100644
--- a/nicla/traffic_light.py
+++ b/nicla/traffic_light.py
@@ -32,7 +32,6 @@ def rgb2hsv(rgb):
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()
@@ -61,7 +60,6 @@ def traf_lights(imgTraffic):
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])
- sensor.dealloc_extra_fb()
if light_status == 1:
return 0x06