2026-07-20 02:08:23 +00:00
|
|
|
"""
|
|
|
|
|
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:
|
2026-07-21 07:33:23 +00:00
|
|
|
x, y, diameter = target
|
|
|
|
|
print("target at ({}, {}) diameter={}".format(x, y, diameter))
|
2026-07-20 02:08:23 +00:00
|
|
|
time.sleep(0.2)
|