linghu8812 / tensorrt_inference

699 stars 205 forks source link

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

Open leeyunhome opened 3 years ago

leeyunhome commented 3 years ago

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.

linghu8812 commented 3 years ago

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

leeyunhome commented 3 years ago

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?

linghu8812 commented 3 years ago

only need left, top, width, height

leeyunhome commented 3 years ago

only need left, top, width, height

left top, width, height ?

Thank you.