mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update examples
This commit is contained in:
parent
06c9253644
commit
ee2ba469d8
@ -1,17 +1,39 @@
|
||||
import sensor, time
|
||||
import sensor, time, led
|
||||
#sensor.reset()
|
||||
sensor.set_contrast(2)
|
||||
sensor.set_framesize(sensor.QQVGA)
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
|
||||
clock = time.clock()
|
||||
while (True):
|
||||
clock.tick()
|
||||
# take snapshot
|
||||
# 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
|
||||
|
||||
# Threshold image with RGB
|
||||
binary = image.threshold([(80, 100, 0),
|
||||
(80, -80, 30),
|
||||
(60, 0, -100)], 65)
|
||||
|
||||
# Image closing
|
||||
binary.dilate(3)
|
||||
binary.erode(3)
|
||||
|
||||
# Detect blobs in image
|
||||
blobs = binary.find_blobs()
|
||||
# draw rectangles around detected blobs
|
||||
|
||||
led.off(led.RED)
|
||||
led.off(led.GREEN)
|
||||
led.off(led.BLUE)
|
||||
|
||||
# Draw rectangles around detected blobs
|
||||
for r in blobs:
|
||||
image.draw_rectangle(r)
|
||||
if r[5]==1:
|
||||
led.on(led.RED)
|
||||
if r[5]==2:
|
||||
led.on(led.GREEN)
|
||||
if r[5]==3:
|
||||
led.on(led.BLUE)
|
||||
image.draw_rectangle(r[0:4])
|
||||
|
||||
print(clock.fps())
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import sensor, time
|
||||
#sensor.reset()
|
||||
sensor.set_framesize(sensor.QQVGA)
|
||||
# Set sensor to grayscale
|
||||
sensor.set_pixformat(sensor.GRAYSCALE)
|
||||
|
||||
image = sensor.snapshot()
|
||||
kpts = image.find_keypoints(threshold=30, normalized=False)
|
||||
kpts = image.find_keypoints(threshold=50, normalized=False)
|
||||
print (kpts)
|
||||
time.sleep(500)
|
||||
|
||||
@ -14,7 +13,7 @@ while (True):
|
||||
clock.tick()
|
||||
image = sensor.snapshot()
|
||||
try:
|
||||
image.match_keypoints(kpts, 64)
|
||||
image.match_keypoints(kpts, 32)
|
||||
except:
|
||||
pass
|
||||
print (clock.fps())
|
||||
print (clock.avg())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user