【发布时间】:2021-12-16 23:14:39
【问题描述】:
我想使用 mediapipe 人脸检测模块从原始图像和视频中裁剪人脸图像,以构建用于情感识别的数据集。
有没有办法从 mediapipe faceDetection 解决方案中获取边界框?
cap = cv2.VideoCapture(0)
with mp_face_detection.FaceDetection(
model_selection=0, min_detection_confidence=0.5) as face_detection:
while cap.isOpened():
success, image = cap.read()
if not success:
print("Ignoring empty camera frame.")
continue
image.flags.writeable = False
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = face_detection.process(image)
# Draw the face detection annotations on the image.
image.flags.writeable = True
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
if results.detections:
for detection in results.detections:
mp_drawing.draw_detection(image, detection)
##
'''
#### here i want to grab the bounding box for the detected faces in order to crop the face image
'''
##
cv2.imshow('MediaPipe Face Detection', cv2.flip(image, 1))
if cv2.waitKey(5) & 0xFF == 27:
break
cap.release()
谢谢
【问题讨论】:
-
我不确定下面是否值得作为答案,所以把它放在这里。 1. 检查什么是“检测”:github.com/google/mediapipe/blob/master/mediapipe/framework/… 2. 我相信你应该使用 location_data。它应该有“格式”,应该是“边界框”,然后应该填充“边界框”字段。
-
刚刚检查了我的假设,用 sn-p 作为答案发布。
标签: python face-detection mediapipe