Program Listing for File KAZE.h

Return to documentation for file (aslam_cv2/aslam_cv_detector/include/kaze/KAZE.h)

#pragma once

/* ************************************************************************* */
#include "KAZEConfig.h"
#include "nldiffusion_functions.h"
#include "fed.h"
#include "utils.h"

/* ************************************************************************* */
namespace libKAZE {

  struct KAZETiming {

    KAZETiming() {
      kcontrast = 0.0;
      scale = 0.0;
      derivatives = 0.0;
      detector = 0.0;
      extrema = 0.0;
      subpixel = 0.0;
      descriptor = 0.0;
    }

    double kcontrast;
    double scale;
    double derivatives;
    double detector;
    double extrema;
    double subpixel;
    double descriptor;
  };

  class KAZE {

  private:

    KAZEOptions options_;
    std::vector<TEvolution> evolution_;

    std::vector<std::vector<cv::KeyPoint> > kpts_par_;

    int ncycles_;
    bool reordering_;
    std::vector<std::vector<float > > tsteps_;
    std::vector<int> nsteps_;

    cv::Mat Ltx_, Lty_, px_, py_, ax_, ay_, bx_, by_, qr_, qc_;

    KAZETiming timing_;

  public:

    KAZE(KAZEOptions& options);

    ~KAZE();

    void Allocate_Memory_Evolution();

    int Create_Nonlinear_Scale_Space(const cv::Mat& img);

    void Feature_Detection(std::vector<cv::KeyPoint>& kpts);

    void Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc);

    void Save_Scale_Space();

    void Save_Detector_Responses();

  private:

    void Compute_KContrast(const cv::Mat& img);

    void Compute_Multiscale_Derivatives();

    void Compute_Detector_Response();

    void Determinant_Hessian_Parallel(std::vector<cv::KeyPoint>& kpts);

    void Find_Extremum_Threading(const int level);

    void Do_Subpixel_Refinement(std::vector<cv::KeyPoint>& kpts);

    void AOS_Step_Scalar(cv::Mat& Ld, const cv::Mat& Ldprev, const cv::Mat& c, const float stepsize);

    void AOS_Rows(const cv::Mat& Ldprev, const cv::Mat& c, const float stepsize);

    void AOS_Columns(const cv::Mat& Ldprev, const cv::Mat& c, const float stepsize);

    void Thomas(const cv::Mat& a, const cv::Mat& b, const cv::Mat& Ld, cv::Mat& x);

    void Compute_Main_Orientation(cv::KeyPoint& kpt);

    void Get_SURF_Upright_Descriptor_64(const cv::KeyPoint& kpt, float* desc);
    void Get_SURF_Descriptor_64(const cv::KeyPoint& kpt, float* desc);
    void Get_SURF_Upright_Descriptor_128(const cv::KeyPoint& kpt, float* desc);
    void Get_SURF_Descriptor_128(const cv::KeyPoint& kpt, float* desc);

    void Get_MSURF_Upright_Descriptor_64(const cv::KeyPoint& kpt, float* desc);
    void Get_MSURF_Descriptor_64(const cv::KeyPoint& kpt, float* desc);
    void Get_MSURF_Upright_Descriptor_128(const cv::KeyPoint& kpt, float* desc);
    void Get_MSURF_Descriptor_128(const cv::KeyPoint& kpt, float* desc);

    void Get_GSURF_Upright_Descriptor_64(const cv::KeyPoint& kpt, float* desc);
    void Get_GSURF_Descriptor_64(const cv::KeyPoint& kpt, float* desc);
    void Get_GSURF_Upright_Descriptor_128(const cv::KeyPoint& kpt, float* desc);
    void Get_GSURF_Descriptor_128(const cv::KeyPoint& kpt, float* desc);

  public:

    KAZETiming Get_Computation_Times() const {
      return timing_;
    }
  };

  /* ************************************************************************* */
  float gaussian(float x, float y, float sig);

  void checkDescriptorLimits(int& x, int& y, const int width, const int height);

  int fRound(const float flt);
}