diff options
author | NielsCoding <48092678+heavydemon21@users.noreply.github.com> | 2023-06-06 20:30:44 +0200 |
---|---|---|
committer | NielsCoding <48092678+heavydemon21@users.noreply.github.com> | 2023-06-06 20:30:44 +0200 |
commit | 051f0284c9895282205632087a2de6d163073cee (patch) | |
tree | 0804f502f2709329dd9bf6fba6fc6cc6f06a6bc2 | |
parent | da7cc5409372caeac64d46346877b5440e4a4383 (diff) |
WIP final integration
-rw-r--r-- | nicla/.Trashes/._501 | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/.Trashes/501/._image.png | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/.Trashes/501/._temp.mjpeg | 0 | ||||
-rw-r--r-- | nicla/.Trashes/501/image.png | bin | 0 -> 20357 bytes | |||
-rw-r--r-- | nicla/.Trashes/501/temp.mjpeg | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/._end.jpg | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/._image.jpg | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/._no_entry.jpg | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/._speed.jpg | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/._stop.jpg | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/._temp.orb | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/.fseventsd/fseventsd-uuid | 1 | ||||
-rw-r--r-- | nicla/ERROR.LOG | 1 | ||||
-rw-r--r-- | nicla/README.txt | 17 | ||||
-rw-r--r-- | nicla/end.jpg | bin | 0 -> 10829 bytes | |||
-rw-r--r-- | nicla/image.jpg | bin | 0 -> 30111 bytes | |||
-rw-r--r-- | nicla/kpts.orb | bin | 0 -> 2696 bytes | |||
-rw-r--r-- | nicla/no_entry.jpg | bin | 0 -> 16864 bytes | |||
-rw-r--r-- | nicla/road.py | 32 | ||||
-rw-r--r-- | nicla/signs_detect.py | 64 | ||||
-rw-r--r-- | nicla/speed.jpg | bin | 0 -> 27055 bytes | |||
-rw-r--r-- | nicla/speed.orb | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | nicla/stop.jpg | bin | 0 -> 35442 bytes | |||
-rw-r--r-- | nicla/temp.orb | bin | 0 -> 6308 bytes |
24 files changed, 103 insertions, 12 deletions
diff --git a/nicla/.Trashes/._501 b/nicla/.Trashes/._501 Binary files differnew file mode 100644 index 0000000..338bd7b --- /dev/null +++ b/nicla/.Trashes/._501 diff --git a/nicla/.Trashes/501/._image.png b/nicla/.Trashes/501/._image.png Binary files differnew file mode 100644 index 0000000..02cf786 --- /dev/null +++ b/nicla/.Trashes/501/._image.png diff --git a/nicla/.Trashes/501/._temp.mjpeg b/nicla/.Trashes/501/._temp.mjpeg new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nicla/.Trashes/501/._temp.mjpeg diff --git a/nicla/.Trashes/501/image.png b/nicla/.Trashes/501/image.png Binary files differnew file mode 100644 index 0000000..d8bc7f5 --- /dev/null +++ b/nicla/.Trashes/501/image.png diff --git a/nicla/.Trashes/501/temp.mjpeg b/nicla/.Trashes/501/temp.mjpeg Binary files differnew file mode 100644 index 0000000..577a50a --- /dev/null +++ b/nicla/.Trashes/501/temp.mjpeg diff --git a/nicla/._end.jpg b/nicla/._end.jpg Binary files differnew file mode 100644 index 0000000..c26df8c --- /dev/null +++ b/nicla/._end.jpg diff --git a/nicla/._image.jpg b/nicla/._image.jpg Binary files differnew file mode 100644 index 0000000..4520888 --- /dev/null +++ b/nicla/._image.jpg diff --git a/nicla/._no_entry.jpg b/nicla/._no_entry.jpg Binary files differnew file mode 100644 index 0000000..a22af57 --- /dev/null +++ b/nicla/._no_entry.jpg diff --git a/nicla/._speed.jpg b/nicla/._speed.jpg Binary files differnew file mode 100644 index 0000000..f3a3faf --- /dev/null +++ b/nicla/._speed.jpg diff --git a/nicla/._stop.jpg b/nicla/._stop.jpg Binary files differnew file mode 100644 index 0000000..4a47a5b --- /dev/null +++ b/nicla/._stop.jpg diff --git a/nicla/._temp.orb b/nicla/._temp.orb Binary files differnew file mode 100644 index 0000000..acfd770 --- /dev/null +++ b/nicla/._temp.orb diff --git a/nicla/.fseventsd/fseventsd-uuid b/nicla/.fseventsd/fseventsd-uuid new file mode 100644 index 0000000..d3c0376 --- /dev/null +++ b/nicla/.fseventsd/fseventsd-uuid @@ -0,0 +1 @@ +6FDC5716-0B86-4159-ACC7-80164FCE6FE6
\ No newline at end of file diff --git a/nicla/ERROR.LOG b/nicla/ERROR.LOG new file mode 100644 index 0000000..ba1a6e3 --- /dev/null +++ b/nicla/ERROR.LOG @@ -0,0 +1 @@ +FATAL ERROR: diff --git a/nicla/README.txt b/nicla/README.txt new file mode 100644 index 0000000..9fdd185 --- /dev/null +++ b/nicla/README.txt @@ -0,0 +1,17 @@ +Thank you for supporting Arduino and the OpenMV project! + +To download the OpenMV IDE, please visit: +https://openmv.io/pages/download + +For tutorials and documentation, please visit: +https://docs.arduino.cc/ +http://docs.openmv.io/ + +For technical OpenMV support and projects, please visit the forums: +http://forums.openmv.io/ + +For Arduino related issues, please visit the Arduino help center: +https://support.arduino.cc/ + +Please use Github to report bugs and issues: +https://github.com/openmv/openmv diff --git a/nicla/end.jpg b/nicla/end.jpg Binary files differnew file mode 100644 index 0000000..7756273 --- /dev/null +++ b/nicla/end.jpg diff --git a/nicla/image.jpg b/nicla/image.jpg Binary files differnew file mode 100644 index 0000000..51a3c75 --- /dev/null +++ b/nicla/image.jpg diff --git a/nicla/kpts.orb b/nicla/kpts.orb Binary files differnew file mode 100644 index 0000000..0c3e1e7 --- /dev/null +++ b/nicla/kpts.orb diff --git a/nicla/no_entry.jpg b/nicla/no_entry.jpg Binary files differnew file mode 100644 index 0000000..6b1c54b --- /dev/null +++ b/nicla/no_entry.jpg diff --git a/nicla/road.py b/nicla/road.py index 02867b8..27101ea 100644 --- a/nicla/road.py +++ b/nicla/road.py @@ -1,12 +1,13 @@ import sensor, image, time, math import uart +import signs_detect import traffic_light from consts import * sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.HVGA) -sensor.skip_frames(time = 2000) +sensor.skip_frames(time = 4000) clock = time.clock() WIDTH = 480 @@ -33,14 +34,12 @@ def drive(driveImg): offset_sum = 0.0 offset_count = 0.0 - for blob in img.find_blobs([(ROAD_MIN_BRIGHTNESS, 0xff)], pixels_threshold=100): img.draw_rectangle(blob.rect()) area_weight = blob.area() horizontal_pos = (blob.x() + blob.w()/2) / WIDTH offset_sum += horizontal_pos * area_weight offset_count += area_weight - # dit tegen niemand zeggen if offset_count < 0.01: return avg = offset_sum / offset_count @@ -52,13 +51,22 @@ def drive(driveImg): 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 while(True): - img = sensor.snapshot() - data = traffic_light.traf_lights(img) - if data is not None: - print(data) - uart.uart_buffer(data) - drive(img) - #uart.uart_buffer(DUI_CMD_SPEED_END) - clock.tick() + 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) + #uart.uart_buffer(DUI_CMD_SPEED_END) diff --git a/nicla/signs_detect.py b/nicla/signs_detect.py new file mode 100644 index 0000000..775ac15 --- /dev/null +++ b/nicla/signs_detect.py @@ -0,0 +1,64 @@ +import sensor, image + +kpts_threshold = 20 +kpts_corner = image.CORNER_FAST + +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): + 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() > 1 + else: + return 0 + +def read_red_sign(val, img, kpts): + if match_kpts(kpts, stop): + 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()) + #print("speed") + return 0x02 + if match_kpts(kpts, car): + img.draw_rectangle(val.rect()) + #print("car") + return 0x03 + +#def read_red_sign(val, img, kpts): + +def sign_detection(img_sign): + img = img_sign.copy() + ######## Detect signs + blobs_r = img.find_blobs([(0, 100, 25, 63, -128, 127)]) + blobs_b = img.find_blobs([(0, 29, 11, -128, -31, -5)]) + #print(f"old: { len(blobs_r) + len(blobs_b) }") + + blobs_r[:] = [b for b in blobs_r if (b.convexity() < 0.7 and b.area() > 64)] + blobs_b[:] = [b for b in blobs_b if (b.convexity() < 0.7 and b.area() > 64)] + #print(f"new: { len(blobs_r) + len(blobs_b) }") + + + ######## Read signs + img = img.to_grayscale() + sign_buffer = 0x00 + if(len(blobs_r) > 0 or len(blobs_b) > 0): + kpts_img = img.find_keypoints(max_keypoints=255, threshold=kpts_threshold, corner_detector=kpts_corner) + + 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() + return sign_buffer diff --git a/nicla/speed.jpg b/nicla/speed.jpg Binary files differnew file mode 100644 index 0000000..c6cf7a9 --- /dev/null +++ b/nicla/speed.jpg diff --git a/nicla/speed.orb b/nicla/speed.orb Binary files differnew file mode 100644 index 0000000..5c48d10 --- /dev/null +++ b/nicla/speed.orb diff --git a/nicla/stop.jpg b/nicla/stop.jpg Binary files differnew file mode 100644 index 0000000..cd35e95 --- /dev/null +++ b/nicla/stop.jpg diff --git a/nicla/temp.orb b/nicla/temp.orb Binary files differnew file mode 100644 index 0000000..ec41eff --- /dev/null +++ b/nicla/temp.orb |