From e95f8194e221f73c15c8506d021637cd95c78664 Mon Sep 17 00:00:00 2001 From: Maria Dimashova Date: Fri, 17 Jun 2011 10:47:35 +0000 Subject: [PATCH] uncommented Opponent descriptors test, fixed descriptors mat size --- modules/features2d/src/descriptors.cpp | 4 +++- modules/features2d/test/test_features2d.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index 480055202d..7c8977ca2f 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -371,6 +371,7 @@ void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, vector< vector idxs[N]; // Compute descriptors three times, once for each Opponent channel to concatenate into a single color descriptor + int maxKeypointsCount = 0; for( int ci = 0; ci < N; ci++ ) { channelKeypoints[ci].insert( channelKeypoints[ci].begin(), keypoints.begin(), keypoints.end() ); @@ -385,13 +386,14 @@ void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, vector< idxs[ci][ki] = (int)ki; } std::sort( idxs[ci].begin(), idxs[ci].end(), KP_LessThan(channelKeypoints[ci]) ); + maxKeypointsCount = std::max( maxKeypointsCount, (int)channelKeypoints[ci].size()); } vector outKeypoints; outKeypoints.reserve( keypoints.size() ); int descriptorSize = descriptorExtractor->descriptorSize(); - Mat mergedDescriptors( (int)keypoints.size(), 3*descriptorSize, descriptorExtractor->descriptorType() ); + Mat mergedDescriptors( maxKeypointsCount, 3*descriptorSize, descriptorExtractor->descriptorType() ); int mergedCount = 0; // cp - current channel position size_t cp[] = {0, 0, 0}; diff --git a/modules/features2d/test/test_features2d.cpp b/modules/features2d/test/test_features2d.cpp index 9328eaea66..6640077a03 100644 --- a/modules/features2d/test/test_features2d.cpp +++ b/modules/features2d/test/test_features2d.cpp @@ -1059,12 +1059,12 @@ TEST( Features2d_DescriptorExtractor_BRIEF, regression ) test.safe_run(); } -//TEST( Features2d_DescriptorExtractor_OpponentSIFT, regression ) -//{ -// CV_DescriptorExtractorTest > test( "descriptor-opponent-sift", 0.18f, -// DescriptorExtractor::create("OpponentSIFT"), 8.06652f ); -// test.safe_run(); -//} +TEST( Features2d_DescriptorExtractor_OpponentSIFT, regression ) +{ + CV_DescriptorExtractorTest > test( "descriptor-opponent-sift", 0.18f, + DescriptorExtractor::create("OpponentSIFT"), 8.06652f ); + test.safe_run(); +} TEST( Features2d_DescriptorExtractor_OpponentSURF, regression ) {