diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2023-06-06 13:53:10 +0200 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2023-06-06 13:53:10 +0200 |
commit | bdf59e4c3680987591bdf0234220922e5e41fc5a (patch) | |
tree | fe1b4a335c056a1b5c06d585d5654f9aa7664c40 /nicla/road.py | |
parent | 93c107718fd6e323fa2336db885b26721f241fa4 (diff) |
first integration
Diffstat (limited to 'nicla/road.py')
-rw-r--r-- | nicla/road.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/nicla/road.py b/nicla/road.py index c5ffae3..8d60dff 100644 --- a/nicla/road.py +++ b/nicla/road.py @@ -1,5 +1,6 @@ import sensor, image, time, math import uart +import traffic_light from consts import * sensor.reset() @@ -23,8 +24,8 @@ points = [(STRETCH, HORIZON), (WIDTH-1+SQUEEZE, HEIGHT-1), (-SQUEEZE, HEIGHT-1)] -def main(): - img = sensor.snapshot() +def drive(driveImg): + img = driveImg.copy() img.to_grayscale() img.replace(vflip=True, hmirror=True) img.rotation_corr(corners=points) @@ -49,8 +50,14 @@ def main(): 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() while(True): - main() + 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() |