这是输入框:
我使用RetinaFace
从中检测所有面孔和常规的csv文件。这是我的csv文件:
,bbox,score,landmarks
0,"[1811, 850, 1948, 1013]",0.999666452407836,"[[1828, 911], [1887, 913], [1841, 942], [1832, 974], [1876, 976]]"
1,"[346, 1285, 503, 1468]",0.9996420145034791,"[[365, 1361], [424, 1348], [385, 1395], [390, 1426], [439, 1416]]"
2,"[1543, 1418, 1702, 1618]",0.9995224475860591,"[[1578, 1514], [1647, 1498], [1619, 1554], [1610, 1585], [1658, 1572]]"
(上面仅存在一些行)。只是为了显示我的输出图像,其中RetinaFace检测到了所有面部:
但是我不能分开面对:
frame = cv2.imread('input.jpg')
x,y,w,h = [1811, 850, 1948, 1013] # one of the bounding boxes
plt.imshow(frame[y:y+h, x:x+w])
它没有提供正确的面部位置。我得到的输出是:最佳答案
我引用了retinaface
代码,发现边界框是通过这种方式提取的:link
x_min, y_min, x_max, y_max = annotation["bbox"]
使用类似于上述索引的索引对我来说非常合适。x,y,w,h = label
plt.imshow(frame[y:h, x:w])
关于python - 使用边框从图像裁剪脸部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63783729/