Normalize line endings and whitespace

This commit is contained in:
OpenCV Buildbot
2012-10-17 11:12:04 +04:00
committed by Andrey Kamaev
parent 0442bca235
commit 81f826db2b
1511 changed files with 258678 additions and 258624 deletions

View File

@@ -59,40 +59,40 @@ using namespace cv;
The algorithm:
for each tested combination of detector+descriptor+matcher:
create detector, descriptor and matcher,
load their params if they are there, otherwise use the default ones and save them
for each dataset:
load reference image
detect keypoints in it, compute descriptors
for each transformed image:
load the image
load the transformation matrix
detect keypoints in it too, compute descriptors
find matches
transform keypoints from the first image using the ground-truth matrix
compute the number of matched keypoints, i.e. for each pair (i,j) found by a matcher compare
j-th keypoint from the second image with the transformed i-th keypoint. If they are close, +1.
so, we have:
N - number of keypoints in the first image that are also visible
(after transformation) on the second image
N1 - number of keypoints in the first image that have been matched.
n - number of the correct matches found by the matcher
n/N1 - precision
n/N - recall (?)
we store (N, n/N1, n/N) (where N is stored primarily for tuning the detector's thresholds,
in order to semi-equalize their keypoints counts)
*/
typedef Vec3f TVec; // (N, n/N1, n/N) - see above
@@ -138,7 +138,7 @@ static void transformKeypoints( const vector<KeyPoint>& kp,
size_t i, n = kp.size();
contours.resize(n);
vector<Point> temp;
for( i = 0; i < n; i++ )
{
ellipse2Poly(Point2f(kp[i].pt.x*scale, kp[i].pt.y*scale),
@@ -157,7 +157,7 @@ static TVec proccessMatches( Size imgsize,
double overlapThreshold )
{
const double visibilityThreshold = 0.6;
// 1. [preprocessing] find bounding rect for each element of kp1t_contours and kp_contours.
// 2. [cross-check] for each DMatch (iK, i1)
// update best_match[i1] using DMatch::distance.
@@ -167,18 +167,18 @@ static TVec proccessMatches( Size imgsize,
// if best_match[i1] is initialized, increment N1
// if kp_contours[best_match[i1]] and kp1t_contours[i1] overlap by overlapThreshold*100%,
// increment n. Use bounding rects to speedup this step
int i, size1 = (int)kp1t_contours.size(), size = (int)kp_contours.size(), msize = (int)matches.size();
vector<DMatch> best_match(size1);
vector<Rect> rects1(size1), rects(size);
// proprocess
for( i = 0; i < size1; i++ )
rects1[i] = boundingRect(kp1t_contours[i]);
for( i = 0; i < size; i++ )
rects[i] = boundingRect(kp_contours[i]);
// cross-check
for( i = 0; i < msize; i++ )
{
@@ -188,35 +188,35 @@ static TVec proccessMatches( Size imgsize,
if( best_match[i1].trainIdx < 0 || best_match[i1].distance > m.distance )
best_match[i1] = m;
}
int N = 0, N1 = 0, n = 0;
// overlapping
for( i = 0; i < size1; i++ )
{
int i1 = i, iK = best_match[i].queryIdx;
if( iK >= 0 )
N1++;
Rect r = rects1[i] & Rect(0, 0, imgsize.width, imgsize.height);
if( r.area() < visibilityThreshold*rects1[i].area() )
continue;
N++;
if( iK < 0 || (rects1[i1] & rects[iK]).area() == 0 )
continue;
double n_area = intersectConvexConvex(kp1t_contours[i1], kp_contours[iK], noArray(), true);
if( n_area == 0 )
continue;
double area1 = contourArea(kp1t_contours[i1], false);
double area = contourArea(kp_contours[iK], false);
double ratio = n_area/(area1 + area - n_area);
n += ratio >= overlapThreshold;
}
return TVec((float)N, (float)n/std::max(N1, 1), (float)n/std::max(N, 1));
}
@@ -228,7 +228,7 @@ static void saveResults(const string& dir, const string& name, const string& dsn
string fname2 = format("%s%s_%s_recall.csv", dir.c_str(), name.c_str(), dsname.c_str());
FILE* f1 = fopen(fname1.c_str(), "wt");
FILE* f2 = fopen(fname2.c_str(), "wt");
for( size_t i = 0; i < results.size(); i++ )
{
fprintf(f1, "%d, %.1f\n", xvals[i], results[i][1]*100);
@@ -251,31 +251,31 @@ int main(int argc, char** argv)
//"SURF_BF", "SURF", "SURF", "BruteForce",
0
};
static const char* datasets[] =
{
"bark", "bikes", "boat", "graf", "leuven", "trees", "ubc", "wall", 0
};
static const int imgXVals[] = { 2, 3, 4, 5, 6 }; // if scale, blur or light changes
static const int viewpointXVals[] = { 20, 30, 40, 50, 60 }; // if viewpoint changes
static const int jpegXVals[] = { 60, 80, 90, 95, 98 }; // if jpeg compression
const double overlapThreshold = 0.6;
vector<vector<vector<TVec> > > results; // indexed as results[ddm][dataset][testcase]
string dataset_dir = string(getenv("OPENCV_TEST_DATA_PATH")) +
"/cv/detectors_descriptors_evaluation/images_datasets";
string dir=argc > 1 ? argv[1] : ".";
if( dir[dir.size()-1] != '\\' && dir[dir.size()-1] != '/' )
dir += "/";
int result = system(("mkdir " + dir).c_str());
CV_Assert(result == 0);
for( int i = 0; ddms[i*4] != 0; i++ )
{
const char* name = ddms[i*4];
@@ -283,40 +283,40 @@ int main(int argc, char** argv)
const char* descriptor_name = ddms[i*4+2];
const char* matcher_name = ddms[i*4+3];
string params_filename = dir + string(name) + "_params.yml";
cout << "Testing " << name << endl;
Ptr<FeatureDetector> detector = FeatureDetector::create(detector_name);
Ptr<DescriptorExtractor> descriptor = DescriptorExtractor::create(descriptor_name);
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create(matcher_name);
saveloadDDM( params_filename, detector, descriptor, matcher );
results.push_back(vector<vector<TVec> >());
for( int j = 0; datasets[j] != 0; j++ )
{
const char* dsname = datasets[j];
cout << "\ton " << dsname << " ";
cout.flush();
const int* xvals = strcmp(dsname, "ubc") == 0 ? jpegXVals :
strcmp(dsname, "graf") == 0 || strcmp(dsname, "wall") == 0 ? viewpointXVals : imgXVals;
vector<KeyPoint> kp1, kp;
vector<DMatch> matches;
vector<vector<Point2f> > kp1t_contours, kp_contours;
Mat desc1, desc;
Mat img1 = imread(format("%s/%s/img1.png", dataset_dir.c_str(), dsname), 0);
CV_Assert( !img1.empty() );
detector->detect(img1, kp1);
descriptor->compute(img1, kp1, desc1);
results[i].push_back(vector<TVec>());
for( int k = 2; ; k++ )
{
cout << ".";
@@ -324,20 +324,20 @@ int main(int argc, char** argv)
Mat imgK = imread(format("%s/%s/img%d.png", dataset_dir.c_str(), dsname, k), 0);
if( imgK.empty() )
break;
detector->detect(imgK, kp);
descriptor->compute(imgK, kp, desc);
matcher->match( desc, desc1, matches );
Mat H = loadMat(format("%s/%s/H1to%dp.xml", dataset_dir.c_str(), dsname, k));
transformKeypoints( kp1, kp1t_contours, H );
transformKeypoints( kp, kp_contours, Mat::eye(3, 3, CV_64F));
TVec r = proccessMatches( imgK.size(), matches, kp1t_contours, kp_contours, overlapThreshold );
results[i][j].push_back(r);
}
saveResults(dir, name, dsname, results[i][j], xvals);
cout << endl;
}