From 9f417268b302a0b7fe67b87e2c5444e3379e2ddf Mon Sep 17 00:00:00 2001 From: Stefan Romberg Date: Thu, 24 Jan 2013 10:01:18 +0100 Subject: [PATCH] Fixed visualization by choosing the color appropriate to the detection Fixed visualization by choosing the color appropriate to the detection score. Previously the example showed all detections with the same color disregarding the confidence. This led to the impression that the object detection did not work at all because there are many detections with low confidences. PR to master was https://github.com/Itseez/opencv/pull/320 --- samples/c/latentsvmdetect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/c/latentsvmdetect.cpp b/samples/c/latentsvmdetect.cpp index ae204d32e9..e74b227a62 100644 --- a/samples/c/latentsvmdetect.cpp +++ b/samples/c/latentsvmdetect.cpp @@ -56,11 +56,12 @@ static void detect_and_draw_objects( IplImage* image, CvLatentSvmDetector* detec for( i = 0; i < detections->total; i++ ) { CvObjectDetection detection = *(CvObjectDetection*)cvGetSeqElem( detections, i ); + float score = detection.score; CvRect bounding_box = detection.rect; cvRectangle( image, cvPoint(bounding_box.x, bounding_box.y), cvPoint(bounding_box.x + bounding_box.width, bounding_box.y + bounding_box.height), - CV_RGB(255,0,0), 3 ); + CV_RGB(cvRound(255.0f*score),0,0), 3 ); } cvReleaseMemStorage( &storage ); }