tensorrt_inference icon indicating copy to clipboard operation
tensorrt_inference copied to clipboard

Question about calculating rect.x-rect.w/2 in yolov5.cpp

Open leeyunhome opened this issue 3 years ago • 4 comments

Hello,

Can you explain why you are doing this calculation?

cv::putText(org_img, name, cv::Point(rect.x - rect.w / 2, rect.y - rect.h / 2 - 5), cv::FONT_HERSHEY_COMPLEX, 0.7, class_colors[rect.classes], 2); cv::Rect rst(rect.x - rect.w / 2, rect.y - rect.h / 2, rect.w, rect.h); cv::rectangle(org_img, rst, class_colors[rect.classes], 2, cv::LINE_8, 0);

Thank you.

leeyunhome avatar Apr 14 '21 02:04 leeyunhome

this code just for draw rectangles and labels, the rect.x, rect.y means the center x and y of the rect.

linghu8812 avatar Apr 14 '21 03:04 linghu8812

this code just for draw rectangles and labels, the rect.x, rect.y means the center x and y of the rect.

Why do I need the center of rect when drawing a rectangle?

leeyunhome avatar Apr 14 '21 03:04 leeyunhome

only need left, top, width, height

linghu8812 avatar Apr 14 '21 03:04 linghu8812

only need left**,** top, width, height

left top, width, height ?

Thank you.

leeyunhome avatar Apr 14 '21 03:04 leeyunhome