@ -716,7 +716,7 @@ void DetectorQualityTest::runDatasetTest (const vector<Mat> &imgs, const vector<
evaluateFeatureDetector ( imgs [ 0 ] , imgs [ ci + 1 ] , Hs [ ci ] , & keypoints1 , & keypoints2 ,
rep , calcQuality [ di ] [ ci ] . correspondenceCount ,
detector ) ;
calcQuality [ di ] [ ci ] . repeatability = 100.f * rep ;
calcQuality [ di ] [ ci ] . repeatability = rep = = - 1 ? rep : 100.f * rep ;
writeKeypoints ( keypontsFS , keypoints2 , ci + 1 ) ;
}
}
@ -732,32 +732,25 @@ void testLog( CvTS* ts, bool isBadAccuracy )
int DetectorQualityTest : : processResults ( int datasetIdx , int caseIdx )
{
int res = CvTS : : OK ;
bool isBadAccuracy ;
Quality valid = validQuality [ datasetIdx ] [ caseIdx ] , calc = calcQuality [ datasetIdx ] [ caseIdx ] ;
bool isBadAccuracy ;
int countEps = 1 ;
const float rltvEps = 0.001 ;
const int countEps = 1 + cvRound ( 0.005f * ( float ) valid . correspondenceCount ) ;
const float rltvEps = 0.5f ;
ts - > printf ( CvTS : : LOG , " %s: calc=%f, valid=%f " , REPEAT . c_str ( ) , calc . repeatability , valid . repeatability ) ;
isBadAccuracy = valid . repeatability - calc . repeatability > rltvEps ;
isBadAccuracy = ( valid . repeatability - calc . repeatability ) > rltvEps ;
testLog ( ts , isBadAccuracy ) ;
res = isBadAccuracy ? CvTS : : FAIL_BAD_ACCURACY : res ;
ts - > printf ( CvTS : : LOG , " %s: calc=%d, valid=%d " , CORRESP_COUNT . c_str ( ) , calc . correspondenceCount , valid . correspondenceCount ) ;
isBadAccuracy = valid . correspondenceCount - calc . correspondenceCount > countEps ;
isBadAccuracy = ( valid . correspondenceCount - calc . correspondenceCount ) > countEps ;
testLog ( ts , isBadAccuracy ) ;
res = isBadAccuracy ? CvTS : : FAIL_BAD_ACCURACY : res ;
return res ;
}
DetectorQualityTest fastDetectorQuality = DetectorQualityTest ( " FAST " , " quality-detector-fast " ) ;
DetectorQualityTest gfttDetectorQuality = DetectorQualityTest ( " GFTT " , " quality-detector-gftt " ) ;
DetectorQualityTest harrisDetectorQuality = DetectorQualityTest ( " HARRIS " , " quality-detector-harris " ) ;
DetectorQualityTest mserDetectorQuality = DetectorQualityTest ( " MSER " , " quality-detector-mser " ) ;
DetectorQualityTest starDetectorQuality = DetectorQualityTest ( " STAR " , " quality-detector-star " ) ;
DetectorQualityTest siftDetectorQuality = DetectorQualityTest ( " SIFT " , " quality-detector-sift " ) ;
DetectorQualityTest surfDetectorQuality = DetectorQualityTest ( " SURF " , " quality-detector-surf " ) ;
/****************************************************************************************\
* Descriptors evaluation *
\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@ -844,8 +837,8 @@ protected:
} ;
vector < CommonRunParams > commRunParams ;
Ptr < GenericDescriptorMatch > specificDescMatch ;
Ptr < GenericDescriptorMatch > defaultDescMatch ;
Ptr < GenericDescriptorMatch > specificDescMatcher ;
Ptr < GenericDescriptorMatch > defaultDescMatcher ;
CommonRunParams commRunParamsDefault ;
string matcherName ;
@ -909,7 +902,7 @@ void DescriptorQualityTest::readDefaultRunParams (FileNode &fn)
{
commRunParamsDefault . projectKeypointsFrom1Image = ( int ) fn [ PROJECT_KEYPOINTS_FROM_1IMAGE ] ! = 0 ;
commRunParamsDefault . matchFilter = ( int ) fn [ MATCH_FILTER ] ;
defaultDescMatch - > read ( fn ) ;
defaultDescMatcher - > read ( fn ) ;
}
}
@ -917,7 +910,7 @@ void DescriptorQualityTest::writeDefaultRunParams (FileStorage &fs) const
{
fs < < PROJECT_KEYPOINTS_FROM_1IMAGE < < commRunParamsDefault . projectKeypointsFrom1Image ;
fs < < MATCH_FILTER < < commRunParamsDefault . matchFilter ;
defaultDescMatch - > write ( fs ) ;
defaultDescMatcher - > write ( fs ) ;
}
void DescriptorQualityTest : : readDatasetRunParams ( FileNode & fn , int datasetIdx )
@ -928,7 +921,7 @@ void DescriptorQualityTest::readDatasetRunParams( FileNode& fn, int datasetIdx )
commRunParams [ datasetIdx ] . keypontsFilename = ( string ) fn [ KEYPOINTS_FILENAME ] ;
commRunParams [ datasetIdx ] . projectKeypointsFrom1Image = ( int ) fn [ PROJECT_KEYPOINTS_FROM_1IMAGE ] ! = 0 ;
commRunParams [ datasetIdx ] . matchFilter = ( int ) fn [ MATCH_FILTER ] ;
specificDescMatch - > read ( fn ) ;
specificDescMatcher - > read ( fn ) ;
}
else
{
@ -943,13 +936,13 @@ void DescriptorQualityTest::writeDatasetRunParams( FileStorage& fs, int datasetI
fs < < PROJECT_KEYPOINTS_FROM_1IMAGE < < commRunParams [ datasetIdx ] . projectKeypointsFrom1Image ;
fs < < MATCH_FILTER < < commRunParams [ datasetIdx ] . matchFilter ;
defaultDescMatch - > write ( fs ) ;
defaultDescMatcher - > write ( fs ) ;
}
void DescriptorQualityTest : : setDefaultDatasetRunParams ( int datasetIdx )
{
commRunParams [ datasetIdx ] = commRunParamsDefault ;
commRunParams [ datasetIdx ] . keypontsFilename = " surf _" + DATASET_NAMES [ datasetIdx ] + " .xml.gz " ;
commRunParams [ datasetIdx ] . keypontsFilename = " SURF _" + DATASET_NAMES [ datasetIdx ] + " .xml.gz " ;
}
void DescriptorQualityTest : : writePlotData ( int di ) const
@ -967,15 +960,15 @@ void DescriptorQualityTest::writePlotData( int di ) const
void DescriptorQualityTest : : readAlgorithm ( )
{
defaultDescMatch = createGenericDescriptorMatch ( algName ) ;
specificDescMatch = createGenericDescriptorMatch ( algName ) ;
defaultDescMatcher = createGenericDescriptorMatcher ( algName ) ;
specificDescMatcher = createGenericDescriptorMatcher ( algName ) ;
if ( defaultDescMatch = = 0 )
if ( defaultDescMatcher = = 0 )
{
Ptr < DescriptorExtractor > extractor = createDescriptorExtractor ( algName ) ;
Ptr < DescriptorMatcher > matcher = createDescriptorMatcher ( matcherName ) ;
defaultDescMatch = new VectorDescriptorMatch ( extractor , matcher ) ;
specificDescMatch = new VectorDescriptorMatch ( extractor , matcher ) ;
defaultDescMatcher = new VectorDescriptorMatch ( extractor , matcher ) ;
specificDescMatcher = new VectorDescriptorMatch ( extractor , matcher ) ;
if ( extractor = = 0 | | matcher = = 0 )
{
@ -1035,7 +1028,7 @@ void DescriptorQualityTest::runDatasetTest (const vector<Mat> &imgs, const vecto
return ;
}
Ptr < GenericDescriptorMatch > descMatch = commRunParams [ di ] . isActiveParams ? specificDescMatch : defaultDescMatch ;
Ptr < GenericDescriptorMatch > descMatch = commRunParams [ di ] . isActiveParams ? specificDescMatcher : defaultDescMatcher ;
calcQuality [ di ] . resize ( TEST_CASE_COUNT ) ;
vector < KeyPoint > keypoints1 ;
@ -1076,28 +1069,40 @@ void DescriptorQualityTest::runDatasetTest (const vector<Mat> &imgs, const vecto
int DescriptorQualityTest : : processResults ( int datasetIdx , int caseIdx )
{
const float rltvEps = 0.001f ;
int res = CvTS : : OK ;
bool isBadAccuracy ;
Quality valid = validQuality [ datasetIdx ] [ caseIdx ] , calc = calcQuality [ datasetIdx ] [ caseIdx ] ;
bool isBadAccuracy ;
const float rltvEps = 0.001f ;
ts - > printf ( CvTS : : LOG , " %s: calc=%f, valid=%f " , RECALL . c_str ( ) , calc . recall , valid . recall ) ;
isBadAccuracy = valid . recall - calc . recall > rltvEps ;
isBadAccuracy = ( valid . recall - calc . recall ) > rltvEps ;
testLog ( ts , isBadAccuracy ) ;
res = isBadAccuracy ? CvTS : : FAIL_BAD_ACCURACY : res ;
ts - > printf ( CvTS : : LOG , " %s: calc=%f, valid=%f " , PRECISION . c_str ( ) , calc . precision , valid . precision ) ;
isBadAccuracy = valid . precision - calc . precision > rltvEps ;
isBadAccuracy = ( valid . precision - calc . precision ) > rltvEps ;
testLog ( ts , isBadAccuracy ) ;
res = isBadAccuracy ? CvTS : : FAIL_BAD_ACCURACY : res ;
return res ;
}
//DescriptorQualityTest siftDescriptorQuality = DescriptorQualityTest( "SIFT", "quality-descriptor-sift", "BruteForce" );
//DescriptorQualityTest surfDescriptorQuality = DescriptorQualityTest( "SURF", "quality-descriptor-surf", "BruteForce" );
//DescriptorQualityTest siftL1DescriptorQuality = DescriptorQualityTest( "SIFT", "quality-descriptor-sift-L1", "BruteForce-L1" );
//DescriptorQualityTest surfL1DescriptorQuality = DescriptorQualityTest( "SURF", "quality-descriptor-surf-L1", "BruteForce-L1" );
//--------------------------------- Calonder descriptor test --------------------------------------------
class CalonderDescriptorQualityTest : public DescriptorQualityTest
{
public :
CalonderDescriptorQualityTest ( ) :
DescriptorQualityTest ( " Calonder " , " quality-descriptor-calonder " ) { }
virtual void readAlgorithm ( )
{
string classifierFile = string ( ts - > get_data_path ( ) ) + " /features2d/calonder_classifier.rtc " ;
defaultDescMatcher = new VectorDescriptorMatch ( new CalonderDescriptorExtractor < float > ( classifierFile ) ,
new BruteForceMatcher < L2 < float > > ) ;
specificDescMatcher = defaultDescMatcher ;
}
} ;
//--------------------------------- One Way descriptor test --------------------------------------------
class OneWayDescriptorQualityTest : public DescriptorQualityTest
@ -1139,7 +1144,7 @@ void OneWayDescriptorQualityTest::processRunParamsFile ()
OneWayDescriptorMatch * match = new OneWayDescriptorMatch ( ) ;
match - > initialize ( OneWayDescriptorMatch : : Params ( ) , base ) ;
defaultDescMatch = match ;
defaultDescMatcher = match ;
writeAllDatasetsRunParams ( ) ;
}
@ -1151,7 +1156,30 @@ void OneWayDescriptorQualityTest::writeDatasetRunParams( FileStorage& fs, int da
fs < < MATCH_FILTER < < commRunParams [ datasetIdx ] . matchFilter ;
}
// Detectors
//DetectorQualityTest fastDetectorQuality = DetectorQualityTest( "FAST", "quality-detector-fast" );
//DetectorQualityTest gfttDetectorQuality = DetectorQualityTest( "GFTT", "quality-detector-gftt" );
//DetectorQualityTest harrisDetectorQuality = DetectorQualityTest( "HARRIS", "quality-detector-harris" );
//DetectorQualityTest mserDetectorQuality = DetectorQualityTest( "MSER", "quality-detector-mser" );
//DetectorQualityTest starDetectorQuality = DetectorQualityTest( "STAR", "quality-detector-star" );
//DetectorQualityTest siftDetectorQuality = DetectorQualityTest( "SIFT", "quality-detector-sift" );
//DetectorQualityTest surfDetectorQuality = DetectorQualityTest( "SURF", "quality-detector-surf" );
//OneWayDescriptorQualityTest oneWayDescriptorQuality;
// Detectors
//DescriptorQualityTest siftDescriptorQuality = DescriptorQualityTest( "SIFT", "quality-descriptor-sift", "BruteForce" );
//DescriptorQualityTest surfDescriptorQuality = DescriptorQualityTest( "SURF", "quality-descriptor-surf", "BruteForce" );
//DescriptorQualityTest fernDescriptorQualityTest( "FERN", "quality-descriptor-fern");
//DescriptorQualityTest calonderDescriptorQualityTest( "CALONDER", "quality-descriptor-calonder");
//CalonderDescriptorQualityTest calonderDescriptorQualityTest;
// Don't run them because of bug in OneWayDescriptorBase many to many matching. TODO: fix this bug.
//OneWayDescriptorQualityTest oneWayDescriptorQuality;
// Don't run them (will validate and save results as "quality-descriptor-sift" and "quality-descriptor-surf" test data).
// TODO: differ result filenames.
//DescriptorQualityTest siftL1DescriptorQuality = DescriptorQualityTest( "SIFT", "quality-descriptor-sift-L1", "BruteForce-L1" );
//DescriptorQualityTest surfL1DescriptorQuality = DescriptorQualityTest( "SURF", "quality-descriptor-surf-L1", "BruteForce-L1" );
//DescriptorQualityTest oppSiftL1DescriptorQuality = DescriptorQualityTest( "SIFT", "quality-descriptor-opponent-sift-L1", "BruteForce-L1" );
//DescriptorQualityTest oppSurfL1DescriptorQuality = DescriptorQualityTest( "SURF", "quality-descriptor-opponent-surf-L1", "BruteForce-L1" );