我尝试使用Dlib shape_predictor_68_landmark来标记我的照片。我使用OpenCV来读取和调整照片的大小(所有的照片都是从视频中获取的肖像照片)。然后,我使用这些处理过的照片运行函数dlib.get_frontal_face_detector()
。
这是我的代码:
detector=dlib.get_frontal_face_detector()
for filename in os.listdir("/content/drive/MyDrive/new"):
frame = cv2.imread("/content/drive/MyDrive/new/" + filename)
frame = cv2.resize(frame, (720, 720), interpolation=cv2.INTER_NEAREST)
faces = detector(frame, 0)
print('File name:',filename)
print('Face=',faces)
faces = detector(frame, 0)
应该输出一个rectangles[]
,但是当我打印它以进行检查时,它的输出结果是一个空的rectangles[]
。结果(部分)如下:
File name: frame_484.jpg
Face= rectangles[]
我不知道如何让它输出正确的输出(换句话说,不是空的rectangles[])。
发布于 2022-06-21 07:05:16
该模型不输出矩形,这意味着模型无法检测到给定图像中的任何人脸,但是可以尝试改进结果:
在使用rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
。
如果所有这些都不起作用,那么您可以尝试dlib的CNN模块,它比frontal_face模块dlib.cnn_face_detection_model_v1
具有更高的精度
https://stackoverflow.com/questions/72695821
复制相似问题