2. 人脸检测

2.1. 代码

例程:

from mpython import *
import smartcamera_new as smartcamera
import time

smart_camera = smartcamera.SmartCamera(tx=Pin.P16, rx=Pin.P15)
smart_camera.face_detect_init(1)
while True:
    smart_camera.face_detect.recognize()
    if smart_camera.face_detect.face_num != None:
        print(str('人脸数量:') + str(smart_camera.face_detect.face_num))
        print(str('置信度:') + str(smart_camera.face_detect.max_score))
    time.sleep_ms(20)

2.2. mPython图形化示例

../_images/face_detect.png

2.3. 方法

face_detect_init(_choice=1)

_choice -整型 摄像头序号 内置摄像头1

例:

smart_camera.face_detect_init(1)
face_detect.recognize()

运行人脸识别

face_detect.face_num()

人脸检测数量 整型

face_detect.max_score()

人脸检测概率 浮点型 范围:[0-1]