I want to evaluate some detector
#include <opencv.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main(void)
{
//===================VARIABLES==========================
//input images
Mat img_1 = imread("data/graf1.png", IMREAD_GRAYSCALE);
Mat img_2 = imread("data/graf3.png", IMREAD_GRAYSCALE);
//homography matrix
Mat H1to2;
FileStorage fs("data/H1to3p.xml", FileStorage::READ);
fs.getFirstTopLevelNode() >> H1to2;
//keypoints vector
vector<KeyPoint> keypoints_1, keypoints_2;
//decripotrs matrices
Mat desc1, desc2;
//SIFT detector
Ptr<xfeatures2d::SIFT> sift = xfeatures2d::SIFT::create();
//Descriptor evaluation
float repeatability;
int correspCount;
evaluateFeatureDetector(img_1,img_2,H1to2,&keypoints_1,&keypoints_2,repeatability,correspCount,sift);
cout<<"repeatability="<<repeatability<<" correspCount="<<correspCount<<" Keypoint 1st="<<keypoints_1.size()<<" Keypoint 2st="<<keypoints_2.size()<<endl;
return 0;
}
And this is the output:
repeatability=0.484741 correspCount=953 Keypoint 1st=2667 Keypoint 2st=3498
But since the repeatability=correspCount/min(Keypoint 1st,Keypoint 2st)
the value above is not correct.
In this answer a possible cause is explained, but looking how evaluateFeatureDetector
is implemented in evaluation.cpp
(especially calculateRepeatability
) it seems that this not-common keypoints are already removed:
...
if( ifEvaluateDetectors )
{
overlapThreshold = 1.f - 0.4f;
// remove key points from outside of the common image part
Size sz1 = img1.size(), sz2 = img2.size();
filterEllipticKeyPointsByImageSize( keypoints1, sz1 );
filterEllipticKeyPointsByImageSize( keypoints1t, sz2 );
filterEllipticKeyPointsByImageSize( keypoints2, sz2 );
filterEllipticKeyPointsByImageSize( keypoints2t, sz1 );
}
...