mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Moved feature detection scripts into their own folders and added explict frame_skip value per Ibrahim's request. Finished working on snapshot and video recording scripts for next release. ... From CMUcam4 work I learned that people will just want examples that do "X" thing. So, in general, our examples should include a simple script showing off a feature and then a more complex script that does "X" where "X" is some app that a person would want. For example, we'll get reuqests for face tracking with servos, and movement detection with servos. So, instead of answering this question a million times with an example script we'll just have examples for all kinds of things people will want. Gotta automate dealing with help support at the end of the day...
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import sensor, time, image
|
|
sensor.reset()
|
|
|
|
# Reset sensor
|
|
sensor.reset()
|
|
|
|
# Sensor settings
|
|
sensor.set_contrast(1)
|
|
sensor.set_gainceiling(16)
|
|
sensor.set_framesize(sensor.HQVGA)
|
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
|
|
|
# Load Haar Cascade
|
|
# By default this will use all stages, lower satges is faster but less accurate.
|
|
face_cascade = image.HaarCascade("frontalface", stages=25)
|
|
print(face_cascade)
|
|
|
|
# Skip a few frames to allow the sensor settle down
|
|
# Note: This takes more time when exec from the IDE.
|
|
for i in range(0, 30):
|
|
img = sensor.snapshot()
|
|
img.draw_string(0, 0, "Please wait...")
|
|
|
|
d0 = None
|
|
#d0 = image.load_descriptor(image.LBP, "/desc.lbp")
|
|
clock = time.clock()
|
|
|
|
while (True):
|
|
clock.tick()
|
|
img = sensor.snapshot()
|
|
|
|
objects = img.find_features(face_cascade, threshold=0.5, scale=1.25)
|
|
if objects:
|
|
face = objects[0]
|
|
d1 = img.find_lbp(face)
|
|
if (d0 == None):
|
|
d0 = d1
|
|
else:
|
|
dist = image.match_descriptor(image.LBP, d0, d1)
|
|
img.draw_string(0, 10, "Match %d%%"%(dist))
|
|
|
|
img.draw_rectangle(face)
|
|
# Draw FPS
|
|
img.draw_string(0, 0, "FPS:%.2f"%(clock.fps()))
|