Fix missing angles in AKAZE keypoints
authorVladislav Sovrasov <sovrasov.vlad@gmail.com>
Mon, 12 Dec 2016 09:25:57 +0000 (12:25 +0300)
committerVladislav Sovrasov <sovrasov.vlad@gmail.com>
Mon, 12 Dec 2016 09:28:16 +0000 (12:28 +0300)
modules/features2d/src/akaze.cpp
modules/features2d/src/kaze/AKAZEFeatures.cpp
modules/features2d/src/kaze/AKAZEFeatures.h
modules/features2d/test/test_detectors_regression.cpp

index d598155..2297194 100644 (file)
@@ -200,6 +200,8 @@ namespace cv
             if (!useProvidedKeypoints)
             {
                 impl.Feature_Detection(keypoints);
+                if( !descriptors.needed() )
+                    impl.Compute_Keypoints_Orientation(keypoints);
             }
 
             if (!mask.empty())
index 9c30ca9..77a68a5 100644 (file)
@@ -846,6 +846,17 @@ void AKAZEFeatures::Compute_Main_Orientation(KeyPoint& kpt, const std::vector<TE
 
 /* ************************************************************************* */
 /**
+ * @brief This method computes the main orientation for a given keypoints
+ * @param kpts Input keypoints
+ */
+void AKAZEFeatures::Compute_Keypoints_Orientation(std::vector<KeyPoint>& 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
  * the provided keypoint
  * @param kpt Input keypoint
index 14800bc..16a858f 100644 (file)
@@ -54,6 +54,7 @@ public:
   /// Feature description methods
   void Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc);
   static void Compute_Main_Orientation(cv::KeyPoint& kpt, const std::vector<TEvolution>& evolution_);
+  void Compute_Keypoints_Orientation(std::vector<cv::KeyPoint>& kpts) const;
 };
 
 /* ************************************************************************* */
index a235065..9b6d489 100644 (file)
@@ -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<Feature2D> ext = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.001f, 1, 1, KAZE::DIFF_PM_G2);
+    vector<KeyPoint> detAndCompKps;
+    Mat desc;
+    ext->detectAndCompute(testImg, noArray(), detAndCompKps, desc);
+
+    vector<KeyPoint> 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());
+}