int badCount = 0;
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) )
badCount++;
}
}
}
+ // 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()
{
vector<DMatch> matches;
int badCount = 0;
for( size_t i = 0; i < matches.size(); i++ )
{
- DMatch match = matches[i];
+ DMatch& match = matches[i];
int shift = dmatcher->isMaskSupported() ? 1 : 0;
{
if( i < queryDescCount/2 )
int localBadCount = 0;
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) )
localBadCount++;
}
int localBadCount = 0;
for( int k = 0; k < knn; k++ )
{
- DMatch match = matches[i][k];
+ DMatch& match = matches[i][k];
{
if( i < queryDescCount/2 )
{
badCount++;
else
{
- DMatch match = matches[i][0];
+ DMatch& match = matches[i][0];
if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) )
badCount++;
}
int localBadCount = 0;
for( int k = 0; k < needMatchCount; k++ )
{
- DMatch match = matches[i][k];
+ DMatch& match = matches[i][k];
{
if( i < queryDescCount/2 )
{