OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'rectangle'
See original GitHub issueAfter saving the model, running detection with ‘python detect.py --weights ./checkpoints/yolov4-416 --size 416 --model yolov4 --images ./data/images/kite.jpg’ give me an error of:
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:22
Top Results From Across the Web
5:Bad argument) in function 'rectangle' - Can't parse 'pt1 ...
The problem is that you are passing tuples with floats into the function's parameters as the points. Here is the error reproduced:
Read more >Error error: (-5:Bad argument) in function 'rectangle' - Python
error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'rectangle' > Overload resolution failed: > - Can't parse 'pt1'.
Read more >cv2.error: OpenCV(4.5.5) :-1 - YouTube
cv2. error : OpenCV (4.5. 5 ) :- 1 : error : (- 5 : Bad argument) in function 'drawMatches' || cv.drawMatches.
Read more >OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'cvtColor'
cv2. error : OpenCV ( 4.5.2 ) :- 1 : error : (- 5 : Bad argument) in function 'cvtColor'.
Read more >opencv(4.6.0) :-1: error: (-5:bad argument) in function 'rectangle'
StackOverflow ; error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'rectangle' ; > - Can · parse 'pt1'. Sequence item with index 0...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Try to change following lines in core/utils.py as defined below:
Line 152 -> c1, c2 = (int(coor[1]), int(coor[0])), (int(coor[3]), int(coor[2])) Line 159 -> cv2.rectangle(image, c1, (int(np.float32(c3[0])), int(np.float32(c3[1]))), bbox_color, -1) Line 161 -> cv2.putText(image, bbox_mess, (c1[0], int(np.float32(c1[1] - 2))), cv2.FONT_HERSHEY_SIMPLEX, fontScale, (0, 0, 0), bbox_thick // 2, lineType=cv2.LINE_AA)
That’s a really cool solution thanks 😃