调用rk3588人脸检测api

import cv2
from rockx import RockX
import numpy as np
# BODY_DETECT_MIN_SCORE = 0.4
FACE_DETECT_MIN_SCORE = 0.6
#存放了模型和数据
ROCKX_DATA_DIR = "/home/coolpi/RockX_SDK_V1.6.0_20220913/sdk/rockx-data-rk3588"
#实例化RockX类
# handle = RockX(RockX.ROCKX_MODULE_PERSON_DETECTION, rockx_data_dir=ROCKX_DATA_DIR)
handle = RockX(RockX.ROCKX_MODULE_FACE_DETECTION, rockx_data_dir=ROCKX_DATA_DIR)

# process_map = {
#         RockX.ROCKX_MODULE_PERSON_DETECTION : ("body", "rockx_person_detect", BODY_DETECT_MIN_SCORE),
#     }
#调用RockX类的rockx_person_detect方法
process = getattr(handle, "rockx_face_detect")
dataset = 'datatest/run.mp4'
cap = cv2.VideoCapture(dataset)
flag, frame = cap.read()
i = 0
det_results = [] 
while flag:
    # 读取每一帧,flag表示是否读取成功,frame为图片内容。
    flag, frame = cap.read()
    # frame = cv2.pyrDown(frame)
    if frame is None:
        # print("No video captured")
        continue
    else:
        width = frame.shape[1]
        height = frame.shape[0]
        ################
        ret, results = process(
            frame, width, height,RockX.ROCKX_PIXEL_FORMAT_BGR888)
        
        # results = self._filter_results(results)
        ################
        # ret, results = process(frame, width, height,RockX.ROCKX_PIXEL_FORMAT_BGR888)
        for result in results:
            if result.score >FACE_DETECT_MIN_SCORE:
                b = [result.box.top, result.box.right, result.box.bottom, result.box.left,result.score]
                print(b)
        i=i+1
        print(i)

你可能感兴趣的:(人脸检测)