33 lines
852 B
Python
33 lines
852 B
Python
|
|
"""
|
||
|
|
Simple demo: find a coloured blob with the ESP eye over I2C.
|
||
|
|
|
||
|
|
Wire (Pico example):
|
||
|
|
Pico GP0 (SDA) -> ESP GPIO19 (SDA)
|
||
|
|
Pico GP1 (SCL) -> ESP GPIO20 (SCL)
|
||
|
|
GND -> GND
|
||
|
|
|
||
|
|
Copy vision.py + this file to the board, then run.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from vision import Vision
|
||
|
|
import time
|
||
|
|
|
||
|
|
eye = Vision(sda=0, scl=1)
|
||
|
|
|
||
|
|
if not eye.connected():
|
||
|
|
print("Eye not found — check wiring (expect I2C addr 0x42)")
|
||
|
|
else:
|
||
|
|
print("Eye OK, version", eye.version())
|
||
|
|
if not eye.start():
|
||
|
|
print("Camera did not come up — check ESP power/log")
|
||
|
|
else:
|
||
|
|
print("Tracking… (Ctrl-C to stop)")
|
||
|
|
while True:
|
||
|
|
target = eye.read_target()
|
||
|
|
if target is None:
|
||
|
|
print("no target")
|
||
|
|
else:
|
||
|
|
x, y = target
|
||
|
|
print("target at ({}, {})".format(x, y))
|
||
|
|
time.sleep(0.2)
|