生殖への道に咲く花 (2) cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'line'

複雑なヨロを再現

テスト プログラムを実行してエラーを報告する

Traceback (most recent call last):
  File "test_detection.py", line 152, in <module>
    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 を追加し、それらを強制的に整数に変換します

2 番目の文は次のように修正されます。

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)

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'_Code Miraculous Blog-CSDN Blog

おすすめ

転載: blog.csdn.net/imok1234567/article/details/127377873