Skip to content

Commit 4686140

Browse files
ASONG0506chenjiansong
andauthored
yolov5: fix bbox inaccurate issue (wang-xinyu#779)
Co-authored-by: chenjiansong <[email protected]>
1 parent 2fef5f0 commit 4686140

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

yolov5/common.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
using namespace nvinfer1;
1313

1414
cv::Rect get_rect(cv::Mat& img, float bbox[4]) {
15-
int l, r, t, b;
15+
float l, r, t, b;
1616
float r_w = Yolo::INPUT_W / (img.cols * 1.0);
1717
float r_h = Yolo::INPUT_H / (img.rows * 1.0);
1818
if (r_h > r_w) {
@@ -34,7 +34,7 @@ cv::Rect get_rect(cv::Mat& img, float bbox[4]) {
3434
t = t / r_h;
3535
b = b / r_h;
3636
}
37-
return cv::Rect(l, t, r - l, b - t);
37+
return cv::Rect(round(l), round(t), round(r - l), round(b - t));
3838
}
3939

4040
float iou(float lbox[4], float rbox[4]) {

0 commit comments

Comments
 (0)