1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
void BoxVisualization(cv::Mat frame, int tl_x, int tl_y, int br_x, int br_y, int label, float score)
{
// 渲染box
int fontface = cv::FONT_HERSHEY_SIMPLEX;
int thickness = 1;
float fontScale = 0.5;
int baseline = 0;
cv::Scalar color(140, 199, 0);
cv::Rect box((int)tl_x, (int)tl_y, (int)(br_x - tl_x), (int)(br_y - tl_y));
cv::rectangle(frame, box, color, 2, 8, 0);
cv::String label_str = cv::format("l %d, s: %.2f", label, score);
cv::Size fontSize = cv::getTextSize(label_str, fontface, fontScale, thickness, &baseline);
cv::rectangle(frame, cv::Size(box.tl().x, box.tl().y - fontSize.height - baseline), cv::Size(box.tl().x + fontSize.width, box.tl().y),
cv::Scalar(34, 43, 59), -1, 8);
cv::putText(frame, label_str, cv::Point(box.tl().x, box.tl().y - baseline), fontface, fontScale, cv::Scalar(255, 0, 255), thickness, 8);
}
|