前提・実現したいこと
python3.8
yolo-pytorch-v3を動かしています。
初心者でなかなかエラーの原因がわかってない状況で困っています。
よろしくお願い致します。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "cam_demo.py", line 152, in <module> list(map(lambda x: write(x, orig_im), output)) File "cam_demo.py", line 152, in <lambda> list(map(lambda x: write(x, orig_im), output)) File "cam_demo.py", line 49, in write cv2.rectangle(img, c1, c2,color, 1) cv2.error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'rectangle' > 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 > - Can't parse 'rec'. Expected sequence length 4, got 2 > - Can't parse 'rec'. Expected sequence length 4, got 2
該当のソースコード
python3.8
1def write(x, img): 2 c1 = tuple(x[1:3].int()) 3 c2 = tuple(x[3:5].int()) 4 cls = int(x[-1]) 5 label = "{0}".format(classes[cls]) 6 color = random.choice(colors) 7 cv2.rectangle(img, c1, c2,color, 1) 8 t_size = cv2.getTextSize(label, cv2.FONT_HERSHEY_PLAIN, 1 , 1)[0] 9 c2 = c1[0] + t_size[0] + 3, c1[1] + t_size[1] + 4 10 cv2.rectangle(img, c1, c2,color, -1) 11 cv2.putText(img, label, (c1[0], c1[1] + t_size[1] + 4), cv2.FONT_HERSHEY_PLAIN, 1, [225,255,255], 1); 12 return img 13