-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help!!!cv2.error: OpenCV(4.5.2) 👎 error: (-5:Bad argument) in function 'rectangle' #151
Comments
Hi Zxl1556180489, |
At that point c1 and c2 are still tensors, so OpenCV raises type error. To fix it change lines 286 and 287 to: |
c1 and c2 are tensors,you could use like c1[0].item() to fix it. |
x = x.detach().cpu().int().numpy()
img = results[x[0]]
c1 = (x[1], x[2])
c2 = (x[3], x[4])
cls = int(x[-1]) |
Replace lines 178 and 179 with this c1 = tuple(map(torch.Tensor.item, x[1:3].int()))
c2 = tuple(map(torch.Tensor.item, x[3:5].int())) |
Traceback (most recent call last):
File "/home/zxl/PycharmProjects/wjchaoGit/pytorch-yolo-v3-master(usbcam)/pytorch-yolo-v3-master/cam_demo.py", line 151, in
list(map(lambda x: write(x, orig_im), output))
File "/home/zxl/PycharmProjects/wjchaoGit/pytorch-yolo-v3-master(usbcam)/pytorch-yolo-v3-master/cam_demo.py", line 151, in
list(map(lambda x: write(x, orig_im), output))
File "/home/zxl/PycharmProjects/wjchaoGit/pytorch-yolo-v3-master(usbcam)/pytorch-yolo-v3-master/cam_demo.py", line 49, in write
cv2.rectangle(img, c1, c2, color, 1)
cv2.error: OpenCV(4.5.2) 👎 error: (-5:Bad argument) in function 'rectangle'
The text was updated successfully, but these errors were encountered: