Path: blob/master/modules/features2d/src/kaze/AKAZEFeatures.h
16337 views
/**1* @file AKAZE.h2* @brief Main class for detecting and computing binary descriptors in an3* accelerated nonlinear scale space4* @date Mar 27, 20135* @author Pablo F. Alcantarilla, Jesus Nuevo6*/78#ifndef __OPENCV_FEATURES_2D_AKAZE_FEATURES_H__9#define __OPENCV_FEATURES_2D_AKAZE_FEATURES_H__1011/* ************************************************************************* */12// Includes13#include "AKAZEConfig.h"1415namespace cv16{1718/// A-KAZE nonlinear diffusion filtering evolution19template <typename MatType>20struct Evolution21{22Evolution() {23etime = 0.0f;24esigma = 0.0f;25octave = 0;26sublevel = 0;27sigma_size = 0;28octave_ratio = 0.0f;29border = 0;30}3132template <typename T>33explicit Evolution(const Evolution<T> &other) {34size = other.size;35etime = other.etime;36esigma = other.esigma;37octave = other.octave;38sublevel = other.sublevel;39sigma_size = other.sigma_size;40octave_ratio = other.octave_ratio;41border = other.border;4243other.Lx.copyTo(Lx);44other.Ly.copyTo(Ly);45other.Lt.copyTo(Lt);46other.Lsmooth.copyTo(Lsmooth);47other.Ldet.copyTo(Ldet);48}4950MatType Lx, Ly; ///< First order spatial derivatives51MatType Lt; ///< Evolution image52MatType Lsmooth; ///< Smoothed image, used only for computing determinant, released afterwards53MatType Ldet; ///< Detector response5455Size size; ///< Size of the layer56float etime; ///< Evolution time57float esigma; ///< Evolution sigma. For linear diffusion t = sigma^2 / 258int octave; ///< Image octave59int sublevel; ///< Image sublevel in each octave60int sigma_size; ///< Integer esigma. For computing the feature detector responses61float octave_ratio; ///< Scaling ratio of this octave. ratio = 2^octave62int border; ///< Width of border where descriptors cannot be computed63};6465typedef Evolution<Mat> MEvolution;66typedef Evolution<UMat> UEvolution;67typedef std::vector<MEvolution> Pyramid;68typedef std::vector<UEvolution> UMatPyramid;6970/* ************************************************************************* */71// AKAZE Class Declaration72class AKAZEFeatures {7374private:7576AKAZEOptions options_; ///< Configuration options for AKAZE77Pyramid evolution_; ///< Vector of nonlinear diffusion evolution7879/// FED parameters80int ncycles_; ///< Number of cycles81bool reordering_; ///< Flag for reordering time steps82std::vector<std::vector<float > > tsteps_; ///< Vector of FED dynamic time steps83std::vector<int> nsteps_; ///< Vector of number of steps per cycle8485/// Matrices for the M-LDB descriptor computation86cv::Mat descriptorSamples_; // List of positions in the grids to sample LDB bits from.87cv::Mat descriptorBits_;88cv::Mat bitMask_;8990/// Scale Space methods91void Allocate_Memory_Evolution();92void Find_Scale_Space_Extrema(std::vector<Mat>& keypoints_by_layers);93void Do_Subpixel_Refinement(std::vector<Mat>& keypoints_by_layers,94std::vector<KeyPoint>& kpts);9596/// Feature description methods97void Compute_Keypoints_Orientation(std::vector<cv::KeyPoint>& kpts) const;9899public:100/// Constructor with input arguments101AKAZEFeatures(const AKAZEOptions& options);102void Create_Nonlinear_Scale_Space(InputArray img);103void Feature_Detection(std::vector<cv::KeyPoint>& kpts);104void Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, OutputArray desc);105};106107/* ************************************************************************* */108/// Inline functions109void generateDescriptorSubsample(cv::Mat& sampleList, cv::Mat& comparisons,110int nbits, int pattern_size, int nchannels);111112}113114#endif115116117