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
d888f8d9f6
commit
787fbc6e3b
@ -1,23 +1,15 @@
|
|||||||
from openmv import sensor, imlib
|
import sensor, imlib, time
|
||||||
total_frames = 0
|
clock = time.clock()
|
||||||
total_ticks = 0
|
|
||||||
while (True):
|
while (True):
|
||||||
# take snapshot
|
# take snapshot
|
||||||
image = sensor.snapshot()
|
image = sensor.snapshot()
|
||||||
t_start = ticks()
|
|
||||||
|
|
||||||
# detect blobs
|
# detect blobs
|
||||||
imlib.threshold(image, (255, 127, 127), 38)
|
imlib.threshold(image, (255, 127, 127), 48)
|
||||||
imlib.median(image, 1)
|
clock.tick()
|
||||||
|
imlib.median(image, 3)
|
||||||
blobs = imlib.count_blobs(image)
|
blobs = imlib.count_blobs(image)
|
||||||
|
|
||||||
total_ticks = total_ticks + (ticks()-t_start)
|
|
||||||
total_frames = total_frames + 1
|
|
||||||
|
|
||||||
# take new snapshot
|
|
||||||
image = sensor.snapshot()
|
image = sensor.snapshot()
|
||||||
for r in blobs:
|
for r in blobs:
|
||||||
imlib.draw_rectangle(image, r)
|
imlib.draw_rectangle(image, r)
|
||||||
|
break
|
||||||
print (total_ticks/total_frames)
|
|
||||||
print (len(blobs))
|
|
||||||
|
|||||||
@ -1,21 +1,19 @@
|
|||||||
from openmv import sensor, imlib
|
import sensor, imlib, time
|
||||||
# Set sensor gainceiling
|
# Set sensor gainceiling
|
||||||
sensor.set_gainceiling(sensor.X32)
|
sensor.set_gainceiling(sensor.X8)
|
||||||
|
# Set sensor brightness
|
||||||
|
sensor.set_brightness(-2)
|
||||||
# Set sensor to grayscale
|
# Set sensor to grayscale
|
||||||
sensor.set_pixformat(sensor.GRAYSCALE)
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
||||||
|
|
||||||
# Load Haar Cascade
|
# Load Haar Cascade
|
||||||
cascade = imlib.load_cascade("0:/face.bin")
|
cascade = imlib.load_cascade("0:/frontalface_default.cascade")
|
||||||
print(cascade)
|
print(cascade)
|
||||||
|
clock = time.clock()
|
||||||
total_frames = 0
|
|
||||||
total_ticks = 0
|
|
||||||
while (True):
|
while (True):
|
||||||
|
clock.tick()
|
||||||
image = sensor.snapshot()
|
image = sensor.snapshot()
|
||||||
t_start = ticks()
|
|
||||||
objects = imlib.detect_objects(image, cascade)
|
objects = imlib.detect_objects(image, cascade)
|
||||||
total_ticks = total_ticks + (ticks()-t_start)
|
|
||||||
total_frames = total_frames + 1
|
|
||||||
for r in objects:
|
for r in objects:
|
||||||
imlib.draw_rectangle(image, r)
|
imlib.draw_rectangle(image, r)
|
||||||
print (total_ticks/total_frames)
|
print (clock.fps())
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
from openmv import sensor, imlib
|
import sensor, imlib
|
||||||
sensor.set_pixformat(sensor.RGB565)
|
sensor.set_pixformat(sensor.RGB565)
|
||||||
while (True):
|
while (True):
|
||||||
image = sensor.snapshot()
|
image = sensor.snapshot()
|
||||||
|
|||||||
@ -3,4 +3,4 @@ lcd.init()
|
|||||||
lcd.clear(0xFF)
|
lcd.clear(0xFF)
|
||||||
while (True):
|
while (True):
|
||||||
image = sensor.snapshot()
|
image = sensor.snapshot()
|
||||||
lcd.write_image(image)
|
lcd.write_image(image)
|
||||||
@ -1,15 +1,11 @@
|
|||||||
from openmv import sensor, imlib
|
import sensor, imlib, time
|
||||||
sensor.set_pixformat(sensor.GRAYSCALE)
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
||||||
template = imlib.load_template("0:/temp")
|
template = imlib.load_template("0:/minion.template")
|
||||||
total_frames = 0
|
clock = time.clock()
|
||||||
total_ticks = 0
|
|
||||||
t_start = ticks()
|
|
||||||
while (True):
|
while (True):
|
||||||
image = sensor.snapshot()
|
clock.tick()
|
||||||
t_start = ticks()
|
image = sensor.snapshot()
|
||||||
obj = imlib.template_match(image, template, 0.7)
|
obj = imlib.template_match(image, template, 0.7)
|
||||||
total_ticks = total_ticks + (ticks()-t_start)
|
if obj:
|
||||||
total_frames = total_frames + 1
|
|
||||||
print (total_ticks/total_frames)
|
|
||||||
if obj:
|
|
||||||
imlib.draw_rectangle(image, obj)
|
imlib.draw_rectangle(image, obj)
|
||||||
|
print (clock.fps())
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user