video face prison biz新增process fram方法,未修改
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
from typing import Optional, List, Dict
|
||||
from typing import Optional, List, Dict, Tuple
|
||||
import time
|
||||
from insightface.app import FaceAnalysis
|
||||
from biz.base_face_biz import BaseFaceBiz
|
||||
@@ -64,4 +64,39 @@ class VideoFacePrisonBiz(BaseFaceBiz):
|
||||
|
||||
return frame
|
||||
|
||||
def process_frame(self, frame: np.ndarray) -> Tuple[np.ndarray, List[Dict], float]:
|
||||
"""
|
||||
处理单帧图像
|
||||
|
||||
返回:
|
||||
(原始帧, 识别结果列表, 处理时间ms)
|
||||
"""
|
||||
start_time = time.time()
|
||||
|
||||
# 人脸检测和识别
|
||||
faces = self.app.get(frame)
|
||||
|
||||
results = []
|
||||
for face in faces:
|
||||
# 检查人脸质量是否可接受
|
||||
is_acceptable, quality_metrics = self.is_face_quality_acceptable(face, frame)
|
||||
|
||||
# 查找最佳匹配
|
||||
best_name, similarity = self.find_best_match(face.embedding)
|
||||
|
||||
is_match = best_name is not None and similarity >= self.similarity_threshold
|
||||
|
||||
result = {
|
||||
'bbox': face.bbox.astype(int).tolist(),
|
||||
'similarity': similarity,
|
||||
'best_match': best_name,
|
||||
'is_match': is_match,
|
||||
'det_score': float(face.det_score),
|
||||
'quality_metrics': quality_metrics,
|
||||
'is_acceptable': is_acceptable
|
||||
}
|
||||
results.append(result)
|
||||
|
||||
processing_time = (time.time() - start_time) * 1000
|
||||
return frame, results, processing_time
|
||||
|
||||
|
||||
Reference in New Issue
Block a user