Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.46k stars 1.49k forks source link

Why are we explicitly converting the parameters to float in cv2.rectangle(img, (x1,y1), **(np.float32(c3[0]), np.float32(c3[1]))**, rgb, -1) #501

Open Walk-a-thon opened 2 years ago

Walk-a-thon commented 2 years ago

File name : pytorch-YOLOv4/tool/utils.py Line number : 140 code : cv2.rectangle(img, (x1,y1), (np.float32(c3[0]), np.float32(c3[1])), rgb, -1) Issue : Why are we converting the 3rd parameter (end point) to float when the requirement is in Integer format as per the documentation attached below: https://docs.opencv.org/4.x/dc/d84/group__core__basic.html#ga1e83eafb2d26b3c93f09e8338bcab192

Also you are passing the right value in line number : 143 According to me there is some issue in the code.

Shiny-ZhangXiXin commented 2 years ago

I have the same confusion as you, I also feel that the cv2. rectangle should accept integer coordinates. In practice, the original code will return an error: OpenCV(3.4.14) : -1: error: (-5: Bad argument) in function 'rectangle' , xxx has a wrong type. When I change back to an integer, it works fine.