mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
18 lines
458 B
Python
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())
|