From: Vadim Pisarevsky Date: Thu, 16 Oct 2014 13:00:40 +0000 (+0400) Subject: fixed several test failures; currently 9 out of 73 tests fail X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~2882^2~4^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97a5dd0eade17e2d4e67379998b5116d86f1192f;p=platform%2Fupstream%2Fopencv.git fixed several test failures; currently 9 out of 73 tests fail --- diff --git a/modules/features2d/src/akaze.cpp b/modules/features2d/src/akaze.cpp index b72b940..290031d 100644 --- a/modules/features2d/src/akaze.cpp +++ b/modules/features2d/src/akaze.cpp @@ -187,6 +187,28 @@ namespace cv } } + void write(FileStorage& fs) const + { + fs << "descriptor" << descriptor; + fs << "descriptor_channels" << descriptor_channels; + fs << "descriptor_size" << descriptor_size; + fs << "threshold" << threshold; + fs << "octaves" << octaves; + fs << "sublevels" << sublevels; + fs << "diffusivity" << diffusivity; + } + + void read(const FileNode& fn) + { + descriptor = (int)fn["descriptor"]; + descriptor_channels = (int)fn["descriptor_channels"]; + descriptor_size = (int)fn["descriptor_size"]; + threshold = (float)fn["threshold"]; + octaves = (int)fn["octaves"]; + sublevels = (int)fn["sublevels"]; + diffusivity = (int)fn["diffusivity"]; + } + int descriptor; int descriptor_channels; int descriptor_size; diff --git a/modules/features2d/src/brisk.cpp b/modules/features2d/src/brisk.cpp index 1facb3e..d123a3a 100644 --- a/modules/features2d/src/brisk.cpp +++ b/modules/features2d/src/brisk.cpp @@ -2099,7 +2099,7 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode) void BriskLayer::getAgastPoints(int threshold, std::vector& keypoints) { - fast_9_16_->set("threshold", threshold); + fast_9_16_ = FastFeatureDetector::create(threshold); fast_9_16_->detect(img_, keypoints); // also write scores diff --git a/modules/features2d/src/feature2d.cpp b/modules/features2d/src/feature2d.cpp index 039b33d..93b650b 100644 --- a/modules/features2d/src/feature2d.cpp +++ b/modules/features2d/src/feature2d.cpp @@ -60,6 +60,11 @@ void Feature2D::detect( InputArray image, std::vector& keypoints, InputArray mask ) { + if( image.empty() ) + { + keypoints.clear(); + return; + } detectAndCompute(image, mask, keypoints, noArray(), false); } @@ -97,6 +102,11 @@ void Feature2D::compute( InputArray image, std::vector& keypoints, OutputArray descriptors ) { + if( image.empty() ) + { + descriptors.release(); + return; + } detectAndCompute(image, noArray(), keypoints, descriptors, true); } diff --git a/modules/features2d/src/kaze.cpp b/modules/features2d/src/kaze.cpp index 83eeecc..229bb0f 100644 --- a/modules/features2d/src/kaze.cpp +++ b/modules/features2d/src/kaze.cpp @@ -132,6 +132,26 @@ namespace cv } } + void write(FileStorage& fs) const + { + fs << "extended" << (int)extended; + fs << "upright" << (int)upright; + fs << "threshold" << threshold; + fs << "octaves" << octaves; + fs << "sublevels" << sublevels; + fs << "diffusivity" << diffusivity; + } + + void read(const FileNode& fn) + { + extended = (int)fn["extended"] != 0; + upright = (int)fn["upright"] != 0; + threshold = (float)fn["threshold"]; + octaves = (int)fn["octaves"]; + sublevels = (int)fn["sublevels"]; + diffusivity = (int)fn["diffusivity"]; + } + bool extended; bool upright; float threshold; diff --git a/modules/features2d/src/kaze/KAZEFeatures.cpp b/modules/features2d/src/kaze/KAZEFeatures.cpp index 702a8a0..294898c 100644 --- a/modules/features2d/src/kaze/KAZEFeatures.cpp +++ b/modules/features2d/src/kaze/KAZEFeatures.cpp @@ -145,7 +145,7 @@ int KAZEFeatures::Create_Nonlinear_Scale_Space(const Mat &img) */ void KAZEFeatures::Compute_KContrast(const Mat &img, const float &kpercentile) { - options_.kcontrast = compute_k_percentile(img, kpercentile, options_.sderivatives, options_.kcontrast_bins, 0, 0); + options_.kcontrast = compute_k_percentile(img, kpercentile, options_.sderivatives, options_.kcontrast_bins, 0, 0); } /* ************************************************************************* */ diff --git a/modules/features2d/test/test_brisk.cpp b/modules/features2d/test/test_brisk.cpp index 38e07c3..4e1d037 100644 --- a/modules/features2d/test/test_brisk.cpp +++ b/modules/features2d/test/test_brisk.cpp @@ -72,7 +72,7 @@ void CV_BRISKTest::run( int ) cvtColor(image1, gray1, COLOR_BGR2GRAY); cvtColor(image2, gray2, COLOR_BGR2GRAY); - Ptr detector = Algorithm::create("Feature2D.BRISK"); + Ptr detector = BRISK::create(); vector keypoints1; vector keypoints2; diff --git a/modules/features2d/test/test_matchers_algorithmic.cpp b/modules/features2d/test/test_matchers_algorithmic.cpp index a15578a..147ae55 100644 --- a/modules/features2d/test/test_matchers_algorithmic.cpp +++ b/modules/features2d/test/test_matchers_algorithmic.cpp @@ -532,12 +532,14 @@ void CV_DescriptorMatcherTest::run( int ) TEST( Features2d_DescriptorMatcher_BruteForce, regression ) { - CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", Algorithm::create("DescriptorMatcher.BFMatcher"), 0.01f ); + CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", + DescriptorMatcher::create("BFMatcher"), 0.01f ); test.safe_run(); } TEST( Features2d_DescriptorMatcher_FlannBased, regression ) { - CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", Algorithm::create("DescriptorMatcher.FlannBasedMatcher"), 0.04f ); + CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", + DescriptorMatcher::create("FlannBasedMatcher"), 0.04f ); test.safe_run(); } diff --git a/modules/features2d/test/test_orb.cpp b/modules/features2d/test/test_orb.cpp index 47335b4..b7f854b 100644 --- a/modules/features2d/test/test_orb.cpp +++ b/modules/features2d/test/test_orb.cpp @@ -47,9 +47,7 @@ using namespace cv; TEST(Features2D_ORB, _1996) { - Ptr fd = ORB::create(); - fd->set("nFeatures", 10000);//setting a higher maximum to make effect of threshold visible - fd->set("fastThreshold", 20);//more features than the default + Ptr fd = ORB::create(10000, 1.2f, 8, 31, 0, 2, ORB::HARRIS_SCORE, 31, 20); Ptr de = fd; Mat image = imread(string(cvtest::TS::ptr()->get_data_path()) + "shared/lena.png"); diff --git a/modules/features2d/test/test_rotation_and_scale_invariance.cpp b/modules/features2d/test/test_rotation_and_scale_invariance.cpp index fa6a136..90fc2f8 100644 --- a/modules/features2d/test/test_rotation_and_scale_invariance.cpp +++ b/modules/features2d/test/test_rotation_and_scale_invariance.cpp @@ -615,19 +615,15 @@ TEST(Features2d_RotationInvariance_Detector_ORB, regression) TEST(Features2d_RotationInvariance_Descriptor_BRISK, regression) { - DescriptorRotationInvarianceTest test(Algorithm::create("Feature2D.BRISK"), - Algorithm::create("Feature2D.BRISK"), - Algorithm::create("Feature2D.BRISK")->defaultNorm(), - 0.99f); + Ptr f2d = BRISK::create(); + DescriptorRotationInvarianceTest test(f2d, f2d, f2d->defaultNorm(), 0.99f); test.safe_run(); } TEST(Features2d_RotationInvariance_Descriptor_ORB, regression) { - DescriptorRotationInvarianceTest test(Algorithm::create("Feature2D.ORB"), - Algorithm::create("Feature2D.ORB"), - Algorithm::create("Feature2D.ORB")->defaultNorm(), - 0.99f); + Ptr f2d = ORB::create(); + DescriptorRotationInvarianceTest test(f2d, f2d, f2d->defaultNorm(), 0.99f); test.safe_run(); } @@ -646,25 +642,19 @@ TEST(Features2d_RotationInvariance_Descriptor_ORB, regression) TEST(Features2d_ScaleInvariance_Detector_BRISK, regression) { - DetectorScaleInvarianceTest test(Algorithm::create("Feature2D.BRISK"), - 0.08f, - 0.49f); + DetectorScaleInvarianceTest test(BRISK::create(), 0.08f, 0.49f); test.safe_run(); } TEST(Features2d_ScaleInvariance_Detector_KAZE, regression) { - DetectorScaleInvarianceTest test(Algorithm::create("Feature2D.KAZE"), - 0.08f, - 0.49f); + DetectorScaleInvarianceTest test(KAZE::create(), 0.08f, 0.49f); test.safe_run(); } TEST(Features2d_ScaleInvariance_Detector_AKAZE, regression) { - DetectorScaleInvarianceTest test(Algorithm::create("Feature2D.AKAZE"), - 0.08f, - 0.49f); + DetectorScaleInvarianceTest test(AKAZE::create(), 0.08f, 0.49f); test.safe_run(); }