python - 使用边框从图像裁剪脸部

标签 python opencv machine-learning deep-learning

这是输入框:
input image
我使用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检测到了所有面部:
Output image
但是我不能分开面对:
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])
它没有提供正确的面部位置。我得到的输出是:
output

最佳答案

我引用了retinaface代码,发现边界框是通过这种方式提取的:link

x_min, y_min, x_max, y_max = annotation["bbox"]
使用类似于上述索引的索引对我来说非常合适。
x,y,w,h = label
plt.imshow(frame[y:h, x:w])
enter image description here

关于python - 使用边框从图像裁剪脸部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63783729/

相关文章:

python - 在 python openCV 的网络摄像头视频上选择静态 ROI

python - OpenCV 3.1.0 : Finding the 3D position of a flat plane with known dimensions

python - 拟合模型上的评分方法与 scikit-learn 中的 precision_score 之间有什么区别?

machine-learning - 如何设置Weka随机森林中分割的最小实例数?

python - 如何调试导入语句更改行为

python - 使用深度学习处理音频时出现不支持的操作数类型错误

Python 类 "Main"值

python - 有没有办法可视化 haar 级联文件?

python - sklearn 的metrics.accuracy_score 的结果似乎是错误的

1.0.0 中指定元路径的 python pandas json_normalize - 需要可迭代