复现路上的花开花落(2)cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function ‘line‘

复现complex yolo

运行检测程序报错

Traceback (most recent call last):
  File "test_detection.py", line 152, in 
    bev_utils.drawRotatedBox(RGB_Map, int(x), int(y), int(w), l, int(yaw), cnf.colors[int(cls_pred)])
  File "E:\IDM下载\conplex yolo\Complex-YOLOv3\utils\kitti_bev_utils.py", line 174, in drawRotatedBox
    cv2.line(img, (corners_int[0, 0], corners_int[0, 1]), (corners_int[3, 0], corners_int[3, 1]), (255, 255, 0), 2)
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
>  - Can't parse 'pt1'. Sequence item with index 0 has a wrong type
>  - Can't parse 'pt1'. Sequence item with index 0 has a wrong type

原因:类型出错

解决办法:

第一种:将报错语句中所有能改类型的值全加上int强制转成整型

第二句更正为:

cv2.line(img, (int(corners_int[0, 0]), int(corners_int[0, 1])), (int(corners_int[3, 0]), int(corners_int[3, 1])), (255, 255, 0), 2)

第二种:opencv-python版本过高导致,降低版本

参考别的博主,从4.6.0降下来,亲测该版本可行

pip install opencv-python==4.5.1.48

参考链接:

无法解析“pt1”。索引为 0 的序列项的类型错误 ·问题 #48 ·Maudzung/Complex-YOLOv4-Pytorch (github.com)

【YOLOv4运行demo.py报错】:cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function ‘rectangle‘_码上出奇迹的博客-CSDN博客

你可能感兴趣的:(opencv,python,人工智能)