Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/features2d/src/kaze/AKAZEFeatures.h
16337 views
1
/**
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 "AKAZEConfig.h"
15
16
namespace cv
17
{
18
19
/// A-KAZE nonlinear diffusion filtering evolution
20
template <typename MatType>
21
struct Evolution
22
{
23
Evolution() {
24
etime = 0.0f;
25
esigma = 0.0f;
26
octave = 0;
27
sublevel = 0;
28
sigma_size = 0;
29
octave_ratio = 0.0f;
30
border = 0;
31
}
32
33
template <typename T>
34
explicit Evolution(const Evolution<T> &other) {
35
size = other.size;
36
etime = other.etime;
37
esigma = other.esigma;
38
octave = other.octave;
39
sublevel = other.sublevel;
40
sigma_size = other.sigma_size;
41
octave_ratio = other.octave_ratio;
42
border = other.border;
43
44
other.Lx.copyTo(Lx);
45
other.Ly.copyTo(Ly);
46
other.Lt.copyTo(Lt);
47
other.Lsmooth.copyTo(Lsmooth);
48
other.Ldet.copyTo(Ldet);
49
}
50
51
MatType Lx, Ly; ///< First order spatial derivatives
52
MatType Lt; ///< Evolution image
53
MatType Lsmooth; ///< Smoothed image, used only for computing determinant, released afterwards
54
MatType Ldet; ///< Detector response
55
56
Size size; ///< Size of the layer
57
float etime; ///< Evolution time
58
float esigma; ///< Evolution sigma. For linear diffusion t = sigma^2 / 2
59
int octave; ///< Image octave
60
int sublevel; ///< Image sublevel in each octave
61
int sigma_size; ///< Integer esigma. For computing the feature detector responses
62
float octave_ratio; ///< Scaling ratio of this octave. ratio = 2^octave
63
int border; ///< Width of border where descriptors cannot be computed
64
};
65
66
typedef Evolution<Mat> MEvolution;
67
typedef Evolution<UMat> UEvolution;
68
typedef std::vector<MEvolution> Pyramid;
69
typedef std::vector<UEvolution> UMatPyramid;
70
71
/* ************************************************************************* */
72
// AKAZE Class Declaration
73
class AKAZEFeatures {
74
75
private:
76
77
AKAZEOptions options_; ///< Configuration options for AKAZE
78
Pyramid evolution_; ///< Vector of nonlinear diffusion evolution
79
80
/// FED parameters
81
int ncycles_; ///< Number of cycles
82
bool reordering_; ///< Flag for reordering time steps
83
std::vector<std::vector<float > > tsteps_; ///< Vector of FED dynamic time steps
84
std::vector<int> nsteps_; ///< Vector of number of steps per cycle
85
86
/// Matrices for the M-LDB descriptor computation
87
cv::Mat descriptorSamples_; // List of positions in the grids to sample LDB bits from.
88
cv::Mat descriptorBits_;
89
cv::Mat bitMask_;
90
91
/// Scale Space methods
92
void Allocate_Memory_Evolution();
93
void Find_Scale_Space_Extrema(std::vector<Mat>& keypoints_by_layers);
94
void Do_Subpixel_Refinement(std::vector<Mat>& keypoints_by_layers,
95
std::vector<KeyPoint>& kpts);
96
97
/// Feature description methods
98
void Compute_Keypoints_Orientation(std::vector<cv::KeyPoint>& kpts) const;
99
100
public:
101
/// Constructor with input arguments
102
AKAZEFeatures(const AKAZEOptions& options);
103
void Create_Nonlinear_Scale_Space(InputArray img);
104
void Feature_Detection(std::vector<cv::KeyPoint>& kpts);
105
void Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, OutputArray desc);
106
};
107
108
/* ************************************************************************* */
109
/// Inline functions
110
void generateDescriptorSubsample(cv::Mat& sampleList, cv::Mat& comparisons,
111
int nbits, int pattern_size, int nchannels);
112
113
}
114
115
#endif
116
117