当前位置:   article > 正文

cv2.error: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function ‘rectangle‘

cv2.error: opencv(4.9.0) :-1: error: (-5:bad argument) in function 'line

  File "D:\Code\GhostFaceNets\facenet-retinaface-pytorch-main\retinaface.py", line 460, in detect_image
    cv2.rectangle(old_image, (b[0], b[1]), (b[2], b[3]), (0, 0, 255), 2)
cv2.error: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'rectangle'
> Overload resolution failed:
>  - img marked as output argument, but provided NumPy array marked as readonly
>  - Expected Ptr<cv::UMat> for argument 'img'
>  - img marked as output argument, but provided NumPy array marked as readonly
>  - Expected Ptr<cv::UMat> for argument 'img'

cv2.rectangle(old_image, (b[0], b[1]), (b[2], b[3]), (0, 0, 255), 2)

在调试facenet+retinaface时,检测一张图像中多张人脸时出现以上问题。在网上搜了很多,最终选择询问李博士。

解决方法:

  1. old_image = np.int32(old_image)
  2. cv2.rectangle(old_image, (b[0], b[1]), (b[2], b[3]), (0, 0, 255), 2)

成功解决。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/141041
推荐阅读
相关标签
  

闽ICP备14008679号