From 4a3da1c4ed67af8c2037cac548e2b351be080de6 Mon Sep 17 00:00:00 2001 From: Vladislav Sovrasov Date: Mon, 12 Dec 2016 12:25:57 +0300 Subject: [PATCH] Fix missing angles in AKAZE keypoints --- modules/features2d/src/akaze.cpp | 2 ++ modules/features2d/src/kaze/AKAZEFeatures.cpp | 11 ++++++++++ modules/features2d/src/kaze/AKAZEFeatures.h | 1 + .../test/test_detectors_regression.cpp | 20 +++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/modules/features2d/src/akaze.cpp b/modules/features2d/src/akaze.cpp index d598155275..2297194b2c 100644 --- a/modules/features2d/src/akaze.cpp +++ b/modules/features2d/src/akaze.cpp @@ -200,6 +200,8 @@ namespace cv if (!useProvidedKeypoints) { impl.Feature_Detection(keypoints); + if( !descriptors.needed() ) + impl.Compute_Keypoints_Orientation(keypoints); } if (!mask.empty()) diff --git a/modules/features2d/src/kaze/AKAZEFeatures.cpp b/modules/features2d/src/kaze/AKAZEFeatures.cpp index 9c30ca928a..77a68a554c 100644 --- a/modules/features2d/src/kaze/AKAZEFeatures.cpp +++ b/modules/features2d/src/kaze/AKAZEFeatures.cpp @@ -844,6 +844,17 @@ void AKAZEFeatures::Compute_Main_Orientation(KeyPoint& kpt, const std::vector& kpts) const +{ + for(size_t i = 0; i < kpts.size(); i++) + Compute_Main_Orientation(kpts[i], evolution_); +} + /* ************************************************************************* */ /** * @brief This method computes the upright descriptor (not rotation invariant) of diff --git a/modules/features2d/src/kaze/AKAZEFeatures.h b/modules/features2d/src/kaze/AKAZEFeatures.h index 14800bc372..16a858fd6d 100644 --- a/modules/features2d/src/kaze/AKAZEFeatures.h +++ b/modules/features2d/src/kaze/AKAZEFeatures.h @@ -54,6 +54,7 @@ public: /// Feature description methods void Compute_Descriptors(std::vector& kpts, cv::Mat& desc); static void Compute_Main_Orientation(cv::KeyPoint& kpt, const std::vector& evolution_); + void Compute_Keypoints_Orientation(std::vector& kpts) const; }; /* ************************************************************************* */ diff --git a/modules/features2d/test/test_detectors_regression.cpp b/modules/features2d/test/test_detectors_regression.cpp index a235065172..9b6d489535 100644 --- a/modules/features2d/test/test_detectors_regression.cpp +++ b/modules/features2d/test/test_detectors_regression.cpp @@ -301,3 +301,23 @@ TEST( Features2d_Detector_AKAZE, regression ) CV_FeatureDetectorTest test( "detector-akaze", AKAZE::create() ); test.safe_run(); } + +TEST( Features2d_Detector_AKAZE, detect_and_compute_split ) +{ + Mat testImg(100, 100, CV_8U); + RNG rng(101); + rng.fill(testImg, RNG::UNIFORM, Scalar(0), Scalar(255), true); + + Ptr ext = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.001f, 1, 1, KAZE::DIFF_PM_G2); + vector detAndCompKps; + Mat desc; + ext->detectAndCompute(testImg, noArray(), detAndCompKps, desc); + + vector detKps; + ext->detect(testImg, detKps); + + ASSERT_EQ(detKps.size(), detAndCompKps.size()); + + for(size_t i = 0; i < detKps.size(); i++) + ASSERT_EQ(detKps[i].hash(), detAndCompKps[i].hash()); +}