我想实现人脸识别返回画出的框的中心坐标 在这个代码中 报出这个错误
-
import sensor, time, image # 重置感光元件 sensor.reset() # 感光元件设置 sensor.set_contrast(3) sensor.set_gainceiling(16) # HQVGA and GRAYSCALE are the best for face tracking. # HQVGA和灰度对于人脸识别效果最好 sensor.set_framesize(sensor.HQVGA) sensor.set_pixformat(sensor.GRAYSCALE) from image import SEARCH_EX, SEARCH_DS face_cascade = image.HaarCascade("frontalface", stages=25) print(face_cascade) # FPS clock clock = time.clock() while (True): clock.tick() # 拍摄一张照片 template = sensor.snapshot() r = template.find_template(template, 0.70, step=4, search=SEARCH_EX) for m in r: template.draw_rectangle(m) x = r[0] y = r[1] w = r[2] h = r[3] print(r[0]+r[2]/2, r[1]+r[3]/2)
-
人脸识别用的是find_features,你的代码是find_template。完全不对啊。
参考代码:
https://book.openmv.cc/example/07-Face-Detection/face-detection.html