Skip to content

Commit d0bf89c

Browse files
authored
Merge pull request #2951 from vladimir-dudnik/vd/fix-clamp-in-yolo
fix object_detection_demo/cpp for yolo models
2 parents d5068c3 + d92f838 commit d0bf89c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

demos/common/cpp/models/src/detection_model_yolo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ void ModelYolo::parseYOLOOutput(const std::string& output_name,
292292
DetectedObject obj;
293293
obj.x = clamp(x-width/2, 0.f, (float)original_im_w);
294294
obj.y = clamp(y-height/2, 0.f, (float)original_im_h);
295-
obj.width = clamp(width, 0.f, (float)original_im_w) - obj.x;
296-
obj.height = clamp(height, 0.f, (float)original_im_h) - obj.y;
295+
obj.width = clamp(width, 0.f, (float)original_im_w - obj.x);
296+
obj.height = clamp(height, 0.f, (float)original_im_h - obj.y);
297297

298298
for (int j = 0; j < region.classes; ++j) {
299299
int class_index = calculateEntryIndex(entriesNum, region.coords, region.classes + isObjConf, n * entriesNum + i, region.coords + isObjConf + j);

demos/object_detection_demo/cpp/main.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,8 @@ cv::Mat renderDetectionData(DetectionResult& result, const ColorPalette& palette
265265
std::ostringstream conf;
266266
conf << ":" << std::fixed << std::setprecision(1) << obj.confidence * 100 << '%';
267267
const auto& color = palette[obj.labelID];
268-
cv::putText(outputImg, obj.label + conf.str(),
269-
cv::Point2f(obj.x, obj.y - 5), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, { 230, 230, 230 }, 3);
270-
cv::putText(outputImg, obj.label + conf.str(),
271-
cv::Point2f(obj.x, obj.y - 5), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, color);
268+
putHighlightedText(outputImg, obj.label + conf.str(),
269+
cv::Point2f(obj.x, obj.y - 5), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, color, 2);
272270
cv::rectangle(outputImg, obj, color, 2);
273271
}
274272

0 commit comments

Comments
 (0)