openmv/usr/examples/blob_detection.py
2014-05-03 00:03:39 +02:00

18 lines
458 B
Python

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