video face prison biz新增process fram方法,未修改
This commit is contained in:
@@ -745,7 +745,7 @@ def sync_videofacebiz_blacklist():
|
|||||||
feature_array = np.frombuffer(feature.feature_data, dtype=np.float32)
|
feature_array = np.frombuffer(feature.feature_data, dtype=np.float32)
|
||||||
|
|
||||||
# 使用person_id作为标识符
|
# 使用person_id作为标识符
|
||||||
person_name = f"blacklist_{feature.person_id}"
|
person_name = f"{feature.person_id}"
|
||||||
registered_faces[person_name] = feature_array
|
registered_faces[person_name] = feature_array
|
||||||
loaded_count += 1
|
loaded_count += 1
|
||||||
|
|
||||||
@@ -970,7 +970,7 @@ def sync_videofaceprisonbiz_blacklist():
|
|||||||
feature_array = np.frombuffer(feature.feature_data, dtype=np.float32)
|
feature_array = np.frombuffer(feature.feature_data, dtype=np.float32)
|
||||||
|
|
||||||
# 使用person_id作为标识符
|
# 使用person_id作为标识符
|
||||||
person_name = f"blacklist_{feature.person_id}"
|
person_name = f"{feature.person_id}"
|
||||||
registered_faces[person_name] = feature_array
|
registered_faces[person_name] = feature_array
|
||||||
loaded_count += 1
|
loaded_count += 1
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from typing import Optional, List, Dict
|
from typing import Optional, List, Dict, Tuple
|
||||||
import time
|
import time
|
||||||
from insightface.app import FaceAnalysis
|
from insightface.app import FaceAnalysis
|
||||||
from biz.base_face_biz import BaseFaceBiz
|
from biz.base_face_biz import BaseFaceBiz
|
||||||
@@ -64,4 +64,39 @@ class VideoFacePrisonBiz(BaseFaceBiz):
|
|||||||
|
|
||||||
return frame
|
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