pytorch-YOLOv4 icon indicating copy to clipboard operation
pytorch-YOLOv4 copied to clipboard

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)

Open Walk-a-thon opened this issue 2 years ago • 1 comments

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.

Walk-a-thon avatar Jan 05 '22 11:01 Walk-a-thon

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.

Shiny-ZhangXiXin avatar Apr 21 '22 07:04 Shiny-ZhangXiXin