Commit f2626514 authored by Maria Dimashova's avatar Maria Dimashova

added test case of matching the same descriptors

parent 168d1936
...@@ -669,7 +669,7 @@ void CV_DescriptorMatcherTest::matchTest( const Mat& query, const Mat& train ) ...@@ -669,7 +669,7 @@ void CV_DescriptorMatcherTest::matchTest( const Mat& query, const Mat& train )
int badCount = 0; int badCount = 0;
for( size_t i = 0; i < matches.size(); i++ ) for( size_t i = 0; i < matches.size(); i++ )
{ {
DMatch match = matches[i]; DMatch& match = matches[i];
if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) ) if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) )
badCount++; badCount++;
} }
...@@ -682,6 +682,33 @@ void CV_DescriptorMatcherTest::matchTest( const Mat& query, const Mat& train ) ...@@ -682,6 +682,33 @@ void CV_DescriptorMatcherTest::matchTest( const Mat& query, const Mat& train )
} }
} }
// test const version of match() for the same query and test descriptors
{
vector<DMatch> matches;
dmatcher->match( query, query, matches );
if( (int)matches.size() != query.rows )
{
ts->printf(cvtest::TS::LOG, "Incorrect matches count while test match() function for the same query and test descriptors (1).\n");
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
}
else
{
for( size_t i = 0; i < matches.size(); i++ )
{
DMatch& match = matches[i];
std::cout << match.distance << std::endl;
if( match.queryIdx != (int)i || match.trainIdx != (int)i || std::abs(match.distance) > FLT_EPSILON )
{
ts->printf( cvtest::TS::LOG, "Bad match (i=%d, queryIdx=%d, trainIdx=%d, distance=%f) while test match() function for the same query and test descriptors (1).\n",
i, match.queryIdx, match.trainIdx, match.distance );
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
}
}
}
}
// test version of match() with add() // test version of match() with add()
{ {
vector<DMatch> matches; vector<DMatch> matches;
...@@ -709,7 +736,7 @@ void CV_DescriptorMatcherTest::matchTest( const Mat& query, const Mat& train ) ...@@ -709,7 +736,7 @@ void CV_DescriptorMatcherTest::matchTest( const Mat& query, const Mat& train )
int badCount = 0; int badCount = 0;
for( size_t i = 0; i < matches.size(); i++ ) for( size_t i = 0; i < matches.size(); i++ )
{ {
DMatch match = matches[i]; DMatch& match = matches[i];
int shift = dmatcher->isMaskSupported() ? 1 : 0; int shift = dmatcher->isMaskSupported() ? 1 : 0;
{ {
if( i < queryDescCount/2 ) if( i < queryDescCount/2 )
...@@ -762,7 +789,7 @@ void CV_DescriptorMatcherTest::knnMatchTest( const Mat& query, const Mat& train ...@@ -762,7 +789,7 @@ void CV_DescriptorMatcherTest::knnMatchTest( const Mat& query, const Mat& train
int localBadCount = 0; int localBadCount = 0;
for( int k = 0; k < knn; k++ ) for( int k = 0; k < knn; k++ )
{ {
DMatch match = matches[i][k]; DMatch& match = matches[i][k];
if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor+k) || (match.imgIdx != 0) ) if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor+k) || (match.imgIdx != 0) )
localBadCount++; localBadCount++;
} }
...@@ -814,7 +841,7 @@ void CV_DescriptorMatcherTest::knnMatchTest( const Mat& query, const Mat& train ...@@ -814,7 +841,7 @@ void CV_DescriptorMatcherTest::knnMatchTest( const Mat& query, const Mat& train
int localBadCount = 0; int localBadCount = 0;
for( int k = 0; k < knn; k++ ) for( int k = 0; k < knn; k++ )
{ {
DMatch match = matches[i][k]; DMatch& match = matches[i][k];
{ {
if( i < queryDescCount/2 ) if( i < queryDescCount/2 )
{ {
...@@ -866,7 +893,7 @@ void CV_DescriptorMatcherTest::radiusMatchTest( const Mat& query, const Mat& tra ...@@ -866,7 +893,7 @@ void CV_DescriptorMatcherTest::radiusMatchTest( const Mat& query, const Mat& tra
badCount++; badCount++;
else else
{ {
DMatch match = matches[i][0]; DMatch& match = matches[i][0];
if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) ) if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) )
badCount++; badCount++;
} }
...@@ -918,7 +945,7 @@ void CV_DescriptorMatcherTest::radiusMatchTest( const Mat& query, const Mat& tra ...@@ -918,7 +945,7 @@ void CV_DescriptorMatcherTest::radiusMatchTest( const Mat& query, const Mat& tra
int localBadCount = 0; int localBadCount = 0;
for( int k = 0; k < needMatchCount; k++ ) for( int k = 0; k < needMatchCount; k++ )
{ {
DMatch match = matches[i][k]; DMatch& match = matches[i][k];
{ {
if( i < queryDescCount/2 ) if( i < queryDescCount/2 )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment