例程讲解09-Feature-Detection->lbp
import sensor, time, image
sensor.reset()
sensor.reset()
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)
for i in range(0, 30):
img = sensor.snapshot()
img.draw_string(0, 0, "Please wait...")
d0 = None
clock = time.clock()
while (True):
clock.tick()
img = sensor.snapshot()
objects = img.find_features(face_cascade, threshold=0.5, scale_factor=1.25)
if objects:
face = objects[0]
d1 = img.find_lbp(face)
if (d0 == None):
d0 = d1
else:
dist = image.match_descriptor(d0, d1)
img.draw_string(0, 10, "Match %d%%"%(dist))
img.draw_rectangle(face)
img.draw_string(0, 0, "FPS:%.2f"%(clock.fps()))
星瞳科技OpenMV官方中文文档函数讲解: