To explain once again, when the camera is looking at a car on the road and recognizes a car far away, the bounding box is drawn accurately, but as the car approaches the camera, the bounding box becomes much larger compared to the size of the object.
it is my draw_results
“”"
static void draw_results(cv::Mat& frame, DetectResult resultData, int img_width, int img_height, det_model_type type){
int i = 0;
float left, right, top, bottom;
for (i = 0; i < resultData.detect_num; i++) {
left = resultData.point[i].point.rectPoint.left*704;
right = resultData.point[i].point.rectPoint.right*704;
top = resultData.point[i].point.rectPoint.top*480;
bottom = resultData.point[i].point.rectPoint.bottom*480;
cout << " left:" << resultData.point[i].point.rectPoint.left << endl;
cout << " right:"<< resultData.point[i].point.rectPoint.right << endl;
cout << " top:" << resultData.point[i].point.rectPoint.top << endl;
cout << " bottom:" << resultData.point[i].point.rectPoint.bottom<< endl;
cout << " frame cols : " << frame.cols << "frame rows : " << frame.rows << endl;
cv::Rect rect(left, top, right-left, bottom-top);
cv::rectangle(frame,rect,obj_id_to_color(resultData.result_name[i].lable_id),1,8,0);
switch (type) {
case DET_YOLOFACE_V2:
break;
case DET_YOLO_V2:
case DET_YOLO_V3:
case DET_YOLO_V4:
case DET_YOLO_TINY:
{
if (top < 50) {
top = 50;
left +=10;
}
int baseline;
cv::Size text_size = cv::getTextSize(resultData.result_name[i].lable_name, cv::FONT_HERSHEY_COMPLEX,0.5,1,&baseline);
cv::Rect rect1(left, top-20, text_size.width+10, 20);
cv::rectangle(frame,rect1,obj_id_to_color(resultData.result_name[i].lable_id),-1);
cv::putText(frame,resultData.result_name[i].lable_name,cvPoint(left+5,top-5),cv::FONT_HERSHEY_COMPLEX,0.5,cv::Scalar(0,0,0),1);
break;
}
default:
break;
}
}
cv::imshow("Image Window",frame);
cv::waitKey(1);
}
“”"
and this is my result left , top , right , bottom