openmv/usr/examples/blob_detection.py
2014-04-04 21:08:33 +02:00

20 lines
446 B
Python

import sensor, time
sensor.set_pixformat(sensor.RGB565)
clock = time.clock()
while (True):
clock.tick()
# take snapshot
image = sensor.snapshot()
# detect blobs
image.threshold((255, 127, 127), 40)
image.median(3)
blobs = image.find_blobs()
# draw rectangles around detected blobs
image = sensor.snapshot()
for r in blobs:
image.draw_rectangle(r)
print(clock.fps())