corrected angular difference check in MSER test (thanks to Pieter-Jan Busschaert for the patch)

This commit is contained in:
Vadim Pisarevsky 2011-05-03 12:58:58 +00:00
parent dff9c0703f
commit 6432267de8

View File

@ -107,7 +107,15 @@ int CV_MserTest::CompareBoxes(const vector<CvBox2D>& boxes1,const vector<CvBox2D
float rel_diff;
if (!((boxes1[i].angle == 0.0f) && (abs(boxes2[i].angle) < max_rel_diff)))
{
rel_diff = abs(boxes1[i].angle-boxes2[i].angle)/abs(boxes1[i].angle);
float angle_diff = (float)fmod(boxes1[i].angle - boxes2[i].angle, 180);
// for angular correctness, it makes no sense to use a "relative" error.
// a 1-degree error around 5 degrees is equally bas as around 250 degrees.
// in correct cases, angle_diff can now be a bit above 0 or a bit below 180
if (angle_diff > 90.0f)
{
angle_diff -= 180.0f;
}
rel_diff = (float)fabs(angle_diff);
if (rel_diff > max_rel_diff)
return i;
}
@ -173,6 +181,7 @@ void CV_MserTest::run(int)
}
string boxes_path = string(ts->get_data_path()) + "mser/boxes.txt";
string calc_boxes_path = string(ts->get_data_path()) + "mser/boxes.calc.txt";
if (!LoadBoxes(boxes_path.c_str(),boxes_orig))
{
@ -190,8 +199,9 @@ void CV_MserTest::run(int)
}
else
{
SaveBoxes(calc_boxes_path.c_str(), boxes);
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
ts->printf( cvtest::TS::LOG, "Incorrect correspondence in %d box\n",n_box);
ts->printf( cvtest::TS::LOG, "Incorrect correspondence in box %d\n",n_box);
}
cvReleaseMemStorage(&storage);