Commit 703e012a authored by Ievgen Khvedchenia's avatar Ievgen Khvedchenia

Prepare KAZE and AKAZE sources for integration

parent 7a594354
......@@ -33,7 +33,7 @@ using namespace cv;
* @param options AKAZE configuration options
* @note This constructor allocates memory for the nonlinear scale space
*/
AKAZE::AKAZE(const AKAZEOptions& options) {
AKAZEFeatures::AKAZEFeatures(const AKAZEOptions& options) {
soffset_ = options.soffset;
factor_size_ = DEFAULT_FACTOR_SIZE;
......@@ -75,7 +75,7 @@ AKAZE::AKAZE(const AKAZEOptions& options) {
/**
* @brief AKAZE destructor
*/
AKAZE::~AKAZE(void) {
AKAZEFeatures::~AKAZEFeatures(void) {
evolution_.clear();
}
......@@ -86,7 +86,7 @@ AKAZE::~AKAZE(void) {
/**
* @brief This method allocates the memory for the nonlinear diffusion evolution
*/
void AKAZE::Allocate_Memory_Evolution(void) {
void AKAZEFeatures::Allocate_Memory_Evolution(void) {
float rfactor = 0.0;
int level_height = 0, level_width = 0;
......@@ -145,7 +145,7 @@ void AKAZE::Allocate_Memory_Evolution(void) {
* @param img Input image for which the nonlinear scale space needs to be created
* @return 0 if the nonlinear scale space was created successfully, -1 otherwise
*/
int AKAZE::Create_Nonlinear_Scale_Space(const cv::Mat &img) {
int AKAZEFeatures::Create_Nonlinear_Scale_Space(const cv::Mat &img) {
double t1 = 0.0, t2 = 0.0;
......@@ -222,7 +222,7 @@ int AKAZE::Create_Nonlinear_Scale_Space(const cv::Mat &img) {
* @brief This method selects interesting keypoints through the nonlinear scale space
* @param kpts Vector of detected keypoints
*/
void AKAZE::Feature_Detection(std::vector<cv::KeyPoint>& kpts) {
void AKAZEFeatures::Feature_Detection(std::vector<cv::KeyPoint>& kpts) {
double t1 = 0.0, t2 = 0.0;
......@@ -242,7 +242,7 @@ void AKAZE::Feature_Detection(std::vector<cv::KeyPoint>& kpts) {
/**
* @brief This method computes the multiscale derivatives for the nonlinear scale space
*/
void AKAZE::Compute_Multiscale_Derivatives(void) {
void AKAZEFeatures::Compute_Multiscale_Derivatives(void) {
double t1 = 0.0, t2 = 0.0;
......@@ -279,7 +279,7 @@ void AKAZE::Compute_Multiscale_Derivatives(void) {
* @brief This method computes the feature detector response for the nonlinear scale space
* @note We use the Hessian determinant as the feature detector response
*/
void AKAZE::Compute_Determinant_Hessian_Response(void) {
void AKAZEFeatures::Compute_Determinant_Hessian_Response(void) {
// Firstly compute the multiscale derivatives
Compute_Multiscale_Derivatives();
......@@ -307,7 +307,7 @@ void AKAZE::Compute_Determinant_Hessian_Response(void) {
* @brief This method finds extrema in the nonlinear scale space
* @param kpts Vector of detected keypoints
*/
void AKAZE::Find_Scale_Space_Extrema(std::vector<cv::KeyPoint>& kpts) {
void AKAZEFeatures::Find_Scale_Space_Extrema(std::vector<cv::KeyPoint>& kpts) {
double t1 = 0.0, t2 = 0.0;
float value = 0.0;
......@@ -418,7 +418,7 @@ void AKAZE::Find_Scale_Space_Extrema(std::vector<cv::KeyPoint>& kpts) {
* @brief This method performs subpixel refinement of the detected keypoints
* @param kpts Vector of detected keypoints
*/
void AKAZE::Do_Subpixel_Refinement(std::vector<cv::KeyPoint>& kpts) {
void AKAZEFeatures::Do_Subpixel_Refinement(std::vector<cv::KeyPoint>& kpts) {
double t1 = 0.0, t2 = 0.0;
float Dx = 0.0, Dy = 0.0, ratio = 0.0;
......@@ -493,7 +493,7 @@ void AKAZE::Do_Subpixel_Refinement(std::vector<cv::KeyPoint>& kpts) {
* @param kpts Vector of keypoints
* @param mdist Maximum distance in pixels
*/
void AKAZE::Feature_Suppression_Distance(std::vector<cv::KeyPoint>& kpts, float mdist) {
void AKAZEFeatures::Feature_Suppression_Distance(std::vector<cv::KeyPoint>& kpts, float mdist) {
vector<KeyPoint> aux;
vector<int> to_delete;
......@@ -545,7 +545,7 @@ void AKAZE::Feature_Suppression_Distance(std::vector<cv::KeyPoint>& kpts, float
* @param kpts Vector of detected keypoints
* @param desc Matrix to store the descriptors
*/
void AKAZE::Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc) {
void AKAZEFeatures::Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc) {
double t1 = 0.0, t2 = 0.0;
......@@ -653,7 +653,7 @@ void AKAZE::Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc)
* @note The orientation is computed using a similar approach as described in the
* original SURF method. See Bay et al., Speeded Up Robust Features, ECCV 2006
*/
void AKAZE::Compute_Main_Orientation_SURF(cv::KeyPoint& kpt) {
void AKAZEFeatures::Compute_Main_Orientation_SURF(cv::KeyPoint& kpt) {
int ix = 0, iy = 0, idx = 0, s = 0, level = 0;
float xf = 0.0, yf = 0.0, gweight = 0.0, ratio = 0.0;
......@@ -728,7 +728,7 @@ void AKAZE::Compute_Main_Orientation_SURF(cv::KeyPoint& kpt) {
* Gaussian weighting is performed. The descriptor is inspired from Bay et al.,
* Speeded Up Robust Features, ECCV, 2006
*/
void AKAZE::Get_SURF_Descriptor_Upright_64(const cv::KeyPoint& kpt, float *desc) {
void AKAZEFeatures::Get_SURF_Descriptor_Upright_64(const cv::KeyPoint& kpt, float *desc) {
float dx = 0.0, dy = 0.0, mdx = 0.0, mdy = 0.0;
float rx = 0.0, ry = 0.0, len = 0.0, xf = 0.0, yf = 0.0;
......@@ -819,7 +819,7 @@ void AKAZE::Get_SURF_Descriptor_Upright_64(const cv::KeyPoint& kpt, float *desc)
* Gaussian weighting is performed. The descriptor is inspired from Bay et al.,
* Speeded Up Robust Features, ECCV, 2006
*/
void AKAZE::Get_SURF_Descriptor_64(const cv::KeyPoint& kpt, float *desc) {
void AKAZEFeatures::Get_SURF_Descriptor_64(const cv::KeyPoint& kpt, float *desc) {
float dx = 0.0, dy = 0.0, mdx = 0.0, mdy = 0.0;
float rx = 0.0, ry = 0.0, rrx = 0.0, rry = 0.0, len = 0.0, xf = 0.0, yf = 0.0;
......@@ -918,7 +918,7 @@ void AKAZE::Get_SURF_Descriptor_64(const cv::KeyPoint& kpt, float *desc) {
* from Agrawal et al., CenSurE: Center Surround Extremas for Realtime Feature Detection and Matching,
* ECCV 2008
*/
void AKAZE::Get_MSURF_Upright_Descriptor_64(const cv::KeyPoint& kpt, float *desc) {
void AKAZEFeatures::Get_MSURF_Upright_Descriptor_64(const cv::KeyPoint& kpt, float *desc) {
float dx = 0.0, dy = 0.0, mdx = 0.0, mdy = 0.0, gauss_s1 = 0.0, gauss_s2 = 0.0;
float rx = 0.0, ry = 0.0, len = 0.0, xf = 0.0, yf = 0.0, ys = 0.0, xs = 0.0;
......@@ -1041,7 +1041,7 @@ void AKAZE::Get_MSURF_Upright_Descriptor_64(const cv::KeyPoint& kpt, float *desc
* from Agrawal et al., CenSurE: Center Surround Extremas for Realtime Feature Detection and Matching,
* ECCV 2008
*/
void AKAZE::Get_MSURF_Descriptor_64(const cv::KeyPoint& kpt, float *desc) {
void AKAZEFeatures::Get_MSURF_Descriptor_64(const cv::KeyPoint& kpt, float *desc) {
float dx = 0.0, dy = 0.0, mdx = 0.0, mdy = 0.0, gauss_s1 = 0.0, gauss_s2 = 0.0;
float rx = 0.0, ry = 0.0, rrx = 0.0, rry = 0.0, len = 0.0, xf = 0.0, yf = 0.0, ys = 0.0, xs = 0.0;
......@@ -1165,7 +1165,7 @@ void AKAZE::Get_MSURF_Descriptor_64(const cv::KeyPoint& kpt, float *desc) {
* @param kpt Input keypoint
* @param desc Descriptor vector
*/
void AKAZE::Get_Upright_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned char *desc) {
void AKAZEFeatures::Get_Upright_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned char *desc) {
float di = 0.0, dx = 0.0, dy = 0.0;
float ri = 0.0, rx = 0.0, ry = 0.0, xf = 0.0, yf = 0.0;
......@@ -1378,7 +1378,7 @@ void AKAZE::Get_Upright_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned c
* @param kpt Input keypoint
* @param desc Descriptor vector
*/
void AKAZE::Get_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned char *desc) {
void AKAZEFeatures::Get_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned char *desc) {
float di = 0.0, dx = 0.0, dy = 0.0, ratio = 0.0;
float ri = 0.0, rx = 0.0, ry = 0.0, rrx = 0.0, rry = 0.0, xf = 0.0, yf = 0.0;
......@@ -1680,7 +1680,7 @@ void AKAZE::Get_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned char *des
* @param kpt Input keypoint
* @param desc Descriptor vector
*/
void AKAZE::Get_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char *desc) {
void AKAZEFeatures::Get_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char *desc) {
float di, dx, dy;
float rx, ry;
......@@ -1772,7 +1772,7 @@ void AKAZE::Get_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char *d
* @param kpt Input keypoint
* @param desc Descriptor vector
*/
void AKAZE::Get_Upright_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char *desc) {
void AKAZEFeatures::Get_Upright_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char *desc) {
float di = 0.0f, dx = 0.0f, dy = 0.0f;
float rx = 0.0f, ry = 0.0f;
......@@ -1851,22 +1851,6 @@ void AKAZE::Get_Upright_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned
//*************************************************************************************
//*************************************************************************************
/**
* @brief This method displays the computation times
*/
void AKAZE::Show_Computation_Times(void) {
cout << "(*) Time Scale Space: " << tscale_ << endl;
cout << "(*) Time Detector: " << tdetector_ << endl;
cout << " - Time Derivatives: " << tderivatives_ << endl;
cout << " - Time Extrema: " << textrema_ << endl;
cout << " - Time Subpixel: " << tsubpixel_ << endl;
cout << "(*) Time Descriptor: " << tdescriptor_ << endl;
}
//*************************************************************************************
//*************************************************************************************
/**
* @brief This function computes a (quasi-random) list of bits to be taken
* from the full descriptor. To speed the extraction, the function creates
......
......@@ -22,7 +22,7 @@
//*************************************************************************************
// AKAZE Class Declaration
class AKAZE {
class AKAZEFeatures {
private:
......@@ -72,10 +72,10 @@ private:
public:
// Constructor
AKAZE(const AKAZEOptions &options);
AKAZEFeatures(const AKAZEOptions &options);
// Destructor
~AKAZE(void);
~AKAZEFeatures(void);
// Setters
void Set_Octave_Max(const int& omax) {
......@@ -144,11 +144,6 @@ public:
void Get_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned char *desc);
void Get_Upright_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char *desc);
void Get_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char *desc);
// Methods for saving some results and showing computation times
void Save_Scale_Space(void);
void Save_Detector_Responses(void);
void Show_Computation_Times(void);
};
//*************************************************************************************
......
#ifndef _CONFIG_H_
#define _CONFIG_H_
#ifndef __OPENCV_FEATURES_2D_AKAZE_CONFIG_HPP__
#define __OPENCV_FEATURES_2D_AKAZE_CONFIG_HPP__
// STL
#include <string>
......@@ -17,7 +17,7 @@
#endif
// Lookup table for 2d gaussian (sigma = 2.5) where (0,0) is top left and (6,6) is bottom right
const float gauss25[7][7] = {
static const float gauss25[7][7] = {
{0.02546481f, 0.02350698f, 0.01849125f, 0.01239505f, 0.00708017f, 0.00344629f, 0.00142946f},
{0.02350698f, 0.02169968f, 0.01706957f, 0.01144208f, 0.00653582f, 0.00318132f, 0.00131956f},
{0.01849125f, 0.01706957f, 0.01342740f, 0.00900066f, 0.00514126f, 0.00250252f, 0.00103800f},
......@@ -29,24 +29,24 @@ const float gauss25[7][7] = {
// Scale Space parameters
const float DEFAULT_SCALE_OFFSET = 1.60f; // Base scale offset (sigma units)
const float DEFAULT_FACTOR_SIZE = 1.5f; // Factor for the multiscale derivatives
const int DEFAULT_OCTAVE_MIN = 0; // Initial octave level (-1 means that the size of the input image is duplicated)
const int DEFAULT_OCTAVE_MAX = 4; // Maximum octave evolution of the image 2^sigma (coarsest scale sigma units)
const int DEFAULT_NSUBLEVELS = 4; // Default number of sublevels per scale level
const int DEFAULT_DIFFUSIVITY_TYPE = 1;
const float KCONTRAST_PERCENTILE = 0.7f;
const int KCONTRAST_NBINS = 300;
const float DEFAULT_SIGMA_SMOOTHING_DERIVATIVES = 1.0f;
const float DEFAULT_KCONTRAST = .01f;
static const float DEFAULT_SCALE_OFFSET = 1.60f; // Base scale offset (sigma units)
static const float DEFAULT_FACTOR_SIZE = 1.5f; // Factor for the multiscale derivatives
static const int DEFAULT_OCTAVE_MIN = 0; // Initial octave level (-1 means that the size of the input image is duplicated)
static const int DEFAULT_OCTAVE_MAX = 4; // Maximum octave evolution of the image 2^sigma (coarsest scale sigma units)
static const int DEFAULT_NSUBLEVELS = 4; // Default number of sublevels per scale level
static const int DEFAULT_DIFFUSIVITY_TYPE = 1;
static const float KCONTRAST_PERCENTILE = 0.7f;
static const int KCONTRAST_NBINS = 300;
static const float DEFAULT_SIGMA_SMOOTHING_DERIVATIVES = 1.0f;
static const float DEFAULT_KCONTRAST = .01f;
// Detector Parameters
const float DEFAULT_DETECTOR_THRESHOLD = 0.001f; // Detector response threshold to accept point
const float DEFAULT_MIN_DETECTOR_THRESHOLD = 0.00001f; // Minimum Detector response threshold to accept point
const int DEFAULT_LDB_DESCRIPTOR_SIZE = 0; // Use 0 for the full descriptor, or the number of bits
const int DEFAULT_LDB_PATTERN_SIZE = 10; // Actual patch size is 2*pattern_size*point.scale;
const int DEFAULT_LDB_CHANNELS = 3;
static const float DEFAULT_DETECTOR_THRESHOLD = 0.001f; // Detector response threshold to accept point
static const float DEFAULT_MIN_DETECTOR_THRESHOLD = 0.00001f; // Minimum Detector response threshold to accept point
static const int DEFAULT_LDB_DESCRIPTOR_SIZE = 0; // Use 0 for the full descriptor, or the number of bits
static const int DEFAULT_LDB_PATTERN_SIZE = 10; // Actual patch size is 2*pattern_size*point.scale;
static const int DEFAULT_LDB_CHANNELS = 3;
// Descriptor Parameters
enum DESCRIPTOR_TYPE
......@@ -59,13 +59,13 @@ enum DESCRIPTOR_TYPE
MLDB = 5
};
const int DEFAULT_DESCRIPTOR = MLDB;
static const int DEFAULT_DESCRIPTOR = MLDB;
// Some debugging options
const bool DEFAULT_SAVE_SCALE_SPACE = false; // For saving the scale space images
const bool DEFAULT_VERBOSITY = false; // Verbosity level (0->no verbosity)
const bool DEFAULT_SHOW_RESULTS = true; // For showing the output image with the detected features plus some ratios
const bool DEFAULT_SAVE_KEYPOINTS = false; // For saving the list of keypoints
static const bool DEFAULT_SAVE_SCALE_SPACE = false; // For saving the scale space images
static const bool DEFAULT_VERBOSITY = false; // Verbosity level (0->no verbosity)
static const bool DEFAULT_SHOW_RESULTS = true; // For showing the output image with the detected features plus some ratios
static const bool DEFAULT_SAVE_KEYPOINTS = false; // For saving the list of keypoints
// Options structure
struct AKAZEOptions
......
This diff is collapsed.
......@@ -23,7 +23,7 @@
//*************************************************************************************
// KAZE Class Declaration
class KAZE {
class KAZEFeatures {
private:
......@@ -69,10 +69,10 @@ private:
public:
// Constructor
KAZE(KAZEOptions& options);
KAZEFeatures(KAZEOptions& options);
// Destructor
~KAZE(void);
~KAZEFeatures(void);
// Public methods for KAZE interface
void Allocate_Memory_Evolution(void);
......@@ -80,11 +80,6 @@ public:
void Feature_Detection(std::vector<cv::KeyPoint>& kpts);
void Feature_Description(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc);
// Methods for saving the scale space set of images and detector responses
void Save_Nonlinear_Scale_Space(void);
void Save_Detector_Responses(void);
void Save_Flow_Responses(void);
private:
// Feature Detection Methods
......
......@@ -6,8 +6,8 @@
* @author Pablo F. Alcantarilla
*/
#ifndef _CONFIG_H_
#define _CONFIG_H_
#ifndef __OPENCV_FEATURES_2D_KAZE_CONFIG_HPP__
#define __OPENCV_FEATURES_2D_KAZE_CONFIG_HPP__
//******************************************************************************
//******************************************************************************
......@@ -38,30 +38,30 @@
#define NMAX_CHAR 400
// Some default options
const float DEFAULT_SCALE_OFFSET = 1.60; // Base scale offset (sigma units)
const float DEFAULT_OCTAVE_MAX = 4.0; // Maximum octave evolution of the image 2^sigma (coarsest scale sigma units)
const int DEFAULT_NSUBLEVELS = 4; // Default number of sublevels per scale level
const float DEFAULT_DETECTOR_THRESHOLD = 0.001; // Detector response threshold to accept point
const float DEFAULT_MIN_DETECTOR_THRESHOLD = 0.00001; // Minimum Detector response threshold to accept point
const int DEFAULT_DESCRIPTOR_MODE = 1; // Descriptor Mode 0->SURF, 1->M-SURF
const bool DEFAULT_USE_FED = true; // 0->AOS, 1->FED
const bool DEFAULT_UPRIGHT = false; // Upright descriptors, not invariant to rotation
const bool DEFAULT_EXTENDED = false; // Extended descriptor, dimension 128
const bool DEFAULT_SAVE_SCALE_SPACE = false; // For saving the scale space images
const bool DEFAULT_VERBOSITY = false; // Verbosity level (0->no verbosity)
const bool DEFAULT_SHOW_RESULTS = true; // For showing the output image with the detected features plus some ratios
const bool DEFAULT_SAVE_KEYPOINTS = false; // For saving the list of keypoints
static const float DEFAULT_SCALE_OFFSET = 1.60; // Base scale offset (sigma units)
static const float DEFAULT_OCTAVE_MAX = 4.0; // Maximum octave evolution of the image 2^sigma (coarsest scale sigma units)
static const int DEFAULT_NSUBLEVELS = 4; // Default number of sublevels per scale level
static const float DEFAULT_DETECTOR_THRESHOLD = 0.001; // Detector response threshold to accept point
static const float DEFAULT_MIN_DETECTOR_THRESHOLD = 0.00001; // Minimum Detector response threshold to accept point
static const int DEFAULT_DESCRIPTOR_MODE = 1; // Descriptor Mode 0->SURF, 1->M-SURF
static const bool DEFAULT_USE_FED = true; // 0->AOS, 1->FED
static const bool DEFAULT_UPRIGHT = false; // Upright descriptors, not invariant to rotation
static const bool DEFAULT_EXTENDED = false; // Extended descriptor, dimension 128
static const bool DEFAULT_SAVE_SCALE_SPACE = false; // For saving the scale space images
static const bool DEFAULT_VERBOSITY = false; // Verbosity level (0->no verbosity)
static const bool DEFAULT_SHOW_RESULTS = true; // For showing the output image with the detected features plus some ratios
static const bool DEFAULT_SAVE_KEYPOINTS = false; // For saving the list of keypoints
// Some important configuration variables
const float DEFAULT_SIGMA_SMOOTHING_DERIVATIVES = 1.0;
const float DEFAULT_KCONTRAST = .01;
const float KCONTRAST_PERCENTILE = 0.7;
const int KCONTRAST_NBINS = 300;
const bool COMPUTE_KCONTRAST = true;
const int DEFAULT_DIFFUSIVITY_TYPE = 1; // 0 -> PM G1, 1 -> PM G2, 2 -> Weickert
const bool USE_CLIPPING_NORMALIZATION = false;
const float CLIPPING_NORMALIZATION_RATIO = 1.6;
const int CLIPPING_NORMALIZATION_NITER = 5;
static const float DEFAULT_SIGMA_SMOOTHING_DERIVATIVES = 1.0;
static const float DEFAULT_KCONTRAST = .01;
static const float KCONTRAST_PERCENTILE = 0.7;
static const int KCONTRAST_NBINS = 300;
static const bool COMPUTE_KCONTRAST = true;
static const int DEFAULT_DIFFUSIVITY_TYPE = 1; // 0 -> PM G1, 1 -> PM G2, 2 -> Weickert
static const bool USE_CLIPPING_NORMALIZATION = false;
static const float CLIPPING_NORMALIZATION_RATIO = 1.6;
static const int CLIPPING_NORMALIZATION_NITER = 5;
//*************************************************************************************
//*************************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment