From e57d4c28bcc8099c70f3c34a3b0c986b0d6b52f1 Mon Sep 17 00:00:00 2001 From: Davis King Date: Sat, 24 Dec 2011 15:23:05 -0500 Subject: [PATCH] Improved an error message. --- dlib/svm/structural_svm_object_detection_problem.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dlib/svm/structural_svm_object_detection_problem.h b/dlib/svm/structural_svm_object_detection_problem.h index d2762e98d..0a7720824 100644 --- a/dlib/svm/structural_svm_object_detection_problem.h +++ b/dlib/svm/structural_svm_object_detection_problem.h @@ -167,6 +167,10 @@ namespace dlib { if (boxes_overlap(mapped_rects[i], mapped_rects[j])) { + const double area_overlap = mapped_rects[i].intersect(mapped_rects[j]).area(); + const double match_amount = area_overlap/(double)( mapped_rects[i]+mapped_rects[j]).area(); + const double overlap_amount = area_overlap/std::min(mapped_rects[i].area(),mapped_rects[j].area()); + using namespace std; ostringstream sout; sout << "An impossible set of object labels was detected. This is happening because "; @@ -184,9 +188,8 @@ namespace dlib sout << "The offending rectangles are:\n"; sout << "rect1: "<< mapped_rects[i] << endl; sout << "rect2: "<< mapped_rects[j] << endl; - sout << "overlap amount: " << - mapped_rects[i].intersect(mapped_rects[j]).area()/(double)( mapped_rects[i]+mapped_rects[j]).area() - << endl; + sout << "match amount: " << match_amount << endl; + sout << "overlap amount: " << overlap_amount << endl; throw dlib::impossible_labeling_error(sout.str()); } }