tensorflow-yolov4-tflite
tensorflow-yolov4-tflite copied to clipboard
OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'rectangle'
After 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
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)
@lazarjovanovicnissatech Thank you, it worked! :D
@lazarjovanovicnissatech Thank you! I have been struggling with this as well.
@lazarjovanovicnissatech same problem occured in windows 10. You are great, i think repo should be updated
Hi everybody, i'm new in this topics, i dont undertand where can i find that lines to fix the error. Anybody can help me please?? step by step im a rookie, jajaja! Tks so much!
Hi everybody, i'm new in this topics, i dont undertand where can i find that lines to fix the error. Anybody can help me please?? step by step im a rookie, jajaja! Tks so much!
So, you have at first to clone the repo. Then, inside, there is a directory called core where you have to enter. Inside core directory, there is a file called utils.py. Open this file in any editor that counts line in code and modify specified lines from above.
That's a really cool solution thanks :)
So, you have at first to clone the repo. Then, inside, there is a directory called core where you have to enter. Inside core directory, there is a file called utils.py. Open this file in any editor that counts line in code and modify specified lines from above.
Hi everyone, getting the same error in juypter notebook. Unable to locate utils.py
inside my installed cv2 package through anaconda. It would be great if someone could help me out in locating the files utils.py
.
Thanks!
How should we tackle this problem on Kaggle?
I think Line is not be installed with pip install cv2 on conda so use these : conda install -c conda-forge opencv conda install -c conda-forge/label/gcc7 opencv conda install -c conda-forge/label/broken opencv conda install -c conda-forge/label/cf201901 opencv conda install -c conda-forge/label/cf202003 opencv
Hi, I have this problem to: frame = cv2.rectangle(frame, int(x1, y1) + box_h, int(x2, y1), color, 5) TypeError: only integer tensors of a single element can be converted to an index [ WARN:0] global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-sn_xpupm\opencv\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
solved
I face this problem how to solve and where the repo for cloning::
Traceback (most recent call last):
File "E:\Computer Vision\day2\string.py", line 13, in
Overload resolution failed:
- rectangle() takes at most 7 arguments (8 given)
- rectangle() takes at most 7 arguments (8 given)
- rectangle() takes at most 6 arguments (8 given)
- rectangle() takes at most 6 arguments (8 given)
Probably it depends on the version of the dependencies, but if you face those type issues, just put coor = coor.astype(int)
right after coor[3] = int(coor[3] * image_w)
in L145 and remove the float casts np.float32
in L159 and L161.
cv2.rectangle(image, c1, c3, bbox_color, -1)
cv2.putText(image, bbox_mess, (c1[0], (c1[1] - 2)), cv2.FONT_HERSHEY_SIMPLEX,
fontScale, (0, 0, 0), bbox_thick // 2, lineType=cv2.LINE_AA)
Traceback (most recent call last):
File "D:\voter task\yolo-coco-data\yolo_object_detection.py", line 70, in
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
Im facing this issue kindly help me out
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)
Thank you it worked :)
how to solve the error error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'dilate'
Overload resolution failed:
- src is not a numerical tuple
- Expected Ptrcv::UMat for argument 'src'
For the code:
image = cv2.resize(img, (1800, 1800)) alpha=1.5 beta=20 new_image=cv2.addWeighted(image,alpha,np.zeros(image.shape, image.dtype),0,beta) cv2.imwrite("new",new_image)
This error coming ..
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'resize'
Overload resolution failed:
- src is not a numpy array, neither a scalar
- Expected Ptrcv::UMat for argument 'src'
I'm also having issues as well it's giving this error: cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'CascadeClassifier'
Overload resolution failed:
- Can't convert object to 'str' for 'filename'
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)
I think lines have changed cause this is for example what line 152 looks like
hello, where to find the 'utils.py'?
hello, where to find the 'utils.py'?
inside the "core" folder
Following worked for me:
img = cv2.rectangle(img.copy(), (x,y), (x2,y2), (0,0,255), 2)