From ff7b46fa665b35477deef6351ba9f6a18d561cf6 Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Thu, 24 Jun 2010 11:29:26 +0000 Subject: [PATCH] Added algorithmic test for BruteForceMatcher --- tests/cv/src/abruteforcematcher.cpp | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/cv/src/abruteforcematcher.cpp diff --git a/tests/cv/src/abruteforcematcher.cpp b/tests/cv/src/abruteforcematcher.cpp new file mode 100644 index 0000000000..ff850ec81b --- /dev/null +++ b/tests/cv/src/abruteforcematcher.cpp @@ -0,0 +1,58 @@ +#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;