blob: 77740b2160f9835ef6cdb0ab04279a34eae92bd2 [file] [log] [blame]
Yash Chainani5458dea2022-06-29 21:05:02 -07001/**
2 * @file AKAZE.h
3 * @brief Main class for detecting and computing binary descriptors in an
4 * accelerated nonlinear scale space
5 * @date Mar 27, 2013
6 * @author Pablo F. Alcantarilla, Jesus Nuevo
7 */
8
9#ifndef __OPENCV_FEATURES_2D_AKAZE_FEATURES_H__
10#define __OPENCV_FEATURES_2D_AKAZE_FEATURES_H__
11
12/* ************************************************************************* */
13// Includes
14#include <vector>
15
16#define AKAZE_USE_CPP11_THREADING
17
18#ifdef AKAZE_USE_CPP11_THREADING
19#include <atomic>
20#include <future>
21#endif
22
23#include <opencv2/core.hpp>
24
25#include "AKAZEConfig.h"
26#include "TEvolution.h"
27
28namespace cv {
29
30/* ************************************************************************* */
31// AKAZE Class Declaration
32class AKAZEFeaturesV2 {
33 private:
34 AKAZEOptionsV2 options_; ///< Configuration options for AKAZE
35 std::vector<TEvolutionV2>
36 evolution_; ///< Vector of nonlinear diffusion evolution
37
38 /// FED parameters
39 bool reordering_; ///< Flag for reordering time steps
40 std::vector<std::vector<float>>
41 tsteps_; ///< Vector of FED dynamic time steps
42
43 /// Matrices for the M-LDB descriptor computation
44 cv::Mat descriptorSamples_; // List of positions in the grids to sample LDB
45 // bits from.
46 cv::Mat descriptorBits_;
47 cv::Mat bitMask_;
48
49 /// Preallocated temporary variables
50 cv::Mat gray_, lx_, ly_;
51 cv::Mat lflow_, lstep_;
52 cv::Mat histgram_, modgs_;
53 std::vector<std::vector<cv::KeyPoint>> kpts_aux_;
54
55#ifdef AKAZE_USE_CPP11_THREADING
56 using task = std::future<void>;
57 std::vector<std::vector<task>> tasklist_;
58 std::vector<std::atomic_int> taskdeps_;
59 std::future<float> kcontrast_;
60#endif
61
62 public:
63 /// Constructor with input arguments
64 AKAZEFeaturesV2(const AKAZEOptionsV2& options);
65
66 /// Getters and Setters
67 void setThreshold(double threshold_) {
68 options_.dthreshold = std::max((float)threshold_, options_.min_dthreshold);
69 };
70 double getThreshold() const { return options_.dthreshold; }
71 void setDiffusivity(int diff_) { options_.diffusivity = diff_; }
72 int getDiffusivity() const { return options_.diffusivity; }
73
74 /// Scale Space methods
75 void Allocate_Memory_Evolution();
76 int Create_Nonlinear_Scale_Space(const cv::Mat& img);
77 float Compute_Base_Evolution_Level(const cv::Mat& img);
78 void Feature_Detection(std::vector<cv::KeyPoint>& kpts);
79 void Compute_Determinant_Hessian_Response(const int level);
80 void Compute_Determinant_Hessian_Response_Single(const int level);
81 void Find_Scale_Space_Extrema(
82 std::vector<std::vector<cv::KeyPoint>>& kpts_aux);
83 void Find_Scale_Space_Extrema_Single(
84 std::vector<std::vector<cv::KeyPoint>>& kpts_aux);
85 void Do_Subpixel_Refinement(std::vector<std::vector<cv::KeyPoint>>& kpts_aux,
86 std::vector<cv::KeyPoint>& kpts);
87
88 /// Feature description methods
89 void Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc);
90};
91
92} // namespace cv
93
94#endif