mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update blob detection example
This commit is contained in:
parent
1d62ec6101
commit
ab05fb6213
23
usr/examples/blob_detection.py
Normal file
23
usr/examples/blob_detection.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from openmv import sensor, imlib
|
||||||
|
total_frames = 0
|
||||||
|
total_ticks = 0
|
||||||
|
while (True):
|
||||||
|
# take snapshot
|
||||||
|
image = sensor.snapshot()
|
||||||
|
t_start = ticks()
|
||||||
|
|
||||||
|
# detect blobs
|
||||||
|
imlib.threshold(image, (255, 127, 127), 38)
|
||||||
|
imlib.median(image, 1)
|
||||||
|
blobs = imlib.count_blobs(image)
|
||||||
|
|
||||||
|
total_ticks = total_ticks + (ticks()-t_start)
|
||||||
|
total_frames = total_frames + 1
|
||||||
|
|
||||||
|
# take new snapshot
|
||||||
|
image = sensor.snapshot()
|
||||||
|
for r in blobs:
|
||||||
|
imlib.draw_rectangle(image, r)
|
||||||
|
|
||||||
|
print (total_ticks/total_frames)
|
||||||
|
print (len(blobs))
|
||||||
@ -1,6 +0,0 @@
|
|||||||
from openmv import sensor, imlib
|
|
||||||
while (True):
|
|
||||||
image = sensor.snapshot()
|
|
||||||
r= imlib.detect_color(image, (340, 50, 50), 10)
|
|
||||||
imlib.draw_rectangle(image, r)
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user