From: Ilya Lysenkov Date: Thu, 1 Jul 2010 07:22:16 +0000 (+0000) Subject: Added timing test for BruteForceMatcher X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~9011 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9596deebb48de230b3eb52dfa3f68d53765575d;p=platform%2Fupstream%2Fopencv.git Added timing test for BruteForceMatcher --- diff --git a/tests/cv/src/abruteforcematcher.cpp b/tests/cv/src/abruteforcematcher.cpp deleted file mode 100644 index ff850ec..0000000 --- a/tests/cv/src/abruteforcematcher.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "cvtest.h" - -using namespace cv; - -class BruteForceMatcherTest : public CvTest -{ -public: - BruteForceMatcherTest(); -protected: - void run( int ); -}; - -BruteForceMatcherTest::BruteForceMatcherTest() : CvTest( "BruteForceMatcher", "BruteForceMatcher") -{ -} - -void BruteForceMatcherTest::run( int ) -{ - const int dimensions = 64; - const int descriptorsNumber = 1024; - - Mat train = Mat( descriptorsNumber, dimensions, CV_32FC1); - Mat query = Mat( descriptorsNumber, dimensions, CV_32FC1); - - Mat permutation( 1, descriptorsNumber, CV_32SC1 ); - for( int i=0;i( 0, i ) = i; - - RNG rng (cvGetTickCount()); - randShuffle( permutation, 1, &rng ); - - float boundary = 500.f; - for( int row=0;row( permutation.at( 0, row ), col ) = bit*boundary + rng.uniform( 0.f, boundary ); - query.at( row, col ) = bit*boundary + rng.uniform( 0.f, boundary ); - } - } - - vector matches; - BruteForceMatcher > matcher; - matcher.add( train ); - matcher.match( query, matches ); - - for( int i=0;i( 0, i ) ) - { - ts->set_failed_test_info( CvTS::FAIL_MISMATCH ); - break; - } - } -} - -BruteForceMatcherTest bruteForceMatcherTest; diff --git a/tests/cv/src/tabruteforcematcher.cpp b/tests/cv/src/tabruteforcematcher.cpp new file mode 100644 index 0000000..5bb42a3 --- /dev/null +++ b/tests/cv/src/tabruteforcematcher.cpp @@ -0,0 +1,81 @@ +#include "cvtest.h" + +using namespace cv; + +class BruteForceMatcherTest : public CvTest +{ +public: + BruteForceMatcherTest(); +protected: + void run( int ); +}; + +struct CV_EXPORTS L2Fake : public L2 +{ +}; + +BruteForceMatcherTest::BruteForceMatcherTest() : CvTest( "BruteForceMatcher", "BruteForceMatcher::matchImpl") +{ + support_testing_modes = CvTS::TIMING_MODE; +} + +void BruteForceMatcherTest::run( int ) +{ + const int dimensions = 64; + const int descriptorsNumber = 5000; + + Mat train = Mat( descriptorsNumber, dimensions, CV_32FC1); + Mat query = Mat( descriptorsNumber, dimensions, CV_32FC1); + + Mat permutation( 1, descriptorsNumber, CV_32SC1 ); + for( int i=0;i( 0, i ) = i; + + RNG rng (cvGetTickCount()); + randShuffle( permutation, 1, &rng ); + + float boundary = 500.f; + for( int row=0;row( permutation.at( 0, row ), col ) = bit*boundary + rng.uniform( 0.f, boundary ); + query.at( row, col ) = bit*boundary + rng.uniform( 0.f, boundary ); + } + } + + vector specMatches, genericMatches; + BruteForceMatcher > specMatcher; + BruteForceMatcher genericMatcher; + specMatcher.add( train ); + genericMatcher.add( train ); + + + int64 time0 = cvGetTickCount(); + specMatcher.match( query, specMatches ); + int64 time1 = cvGetTickCount(); + genericMatcher.match( query, genericMatches ); + int64 time2 = cvGetTickCount(); + + float specMatcherTime = float(time1 - time0)/(float)cvGetTickFrequency(); + ts->printf( CvTS::LOG, "Matching by matrix multiplication time s: %f, us per pair: %f\n", + specMatcherTime*1e-6, specMatcherTime/( descriptorsNumber*descriptorsNumber ) ); + + float genericMatcherTime = float(time2 - time1)/(float)cvGetTickFrequency(); + ts->printf( CvTS::LOG, "Matching without matrix multiplication time s: %f, us per pair: %f\n", + genericMatcherTime*1e-6, genericMatcherTime/( descriptorsNumber*descriptorsNumber ) ); + + if( specMatches.size() != descriptorsNumber || genericMatches.size() != descriptorsNumber ) + ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT ); + for( int i=0;i( 0, i ) || genericMatches[i] != permutation.at( 0, i ) ) + { + ts->set_failed_test_info( CvTS::FAIL_MISMATCH ); + break; + } + } +} + +BruteForceMatcherTest bruteForceMatcherTest;