*/
void AKAZEFeatures::Allocate_Memory_Evolution(void) {
- float rfactor = 0.0;
+ float rfactor = 0.0f;
int level_height = 0, level_width = 0;
// Allocate the dimension of the matrices for the evolution
for (int i = 0; i <= options_.omax - 1; i++) {
- rfactor = 1.0 / pow(2.f, i);
+ rfactor = 1.0f / pow(2.f, i);
level_height = (int)(options_.img_height*rfactor);
level_width = (int)(options_.img_width*rfactor);
step.Lstep = cv::Mat::zeros(level_height, level_width, CV_32F);
step.esigma = options_.soffset*pow(2.f, (float)(j) / (float)(options_.nsublevels) + i);
step.sigma_size = fRound(step.esigma);
- step.etime = 0.5*(step.esigma*step.esigma);
+ step.etime = 0.5f*(step.esigma*step.esigma);
step.octave = i;
step.sublevel = j;
evolution_.push_back(step);
for (size_t i = 1; i < evolution_.size(); i++) {
int naux = 0;
vector<float> tau;
- float ttime = 0.0;
+ float ttime = 0.0f;
ttime = evolution_[i].etime - evolution_[i - 1].etime;
- naux = fed_tau_by_process_time(ttime, 1, 0.25, reordering_, tau);
+ naux = fed_tau_by_process_time(ttime, 1, 0.25f, reordering_, tau);
nsteps_.push_back(naux);
tsteps_.push_back(tau);
ncycles_++;
*/
int AKAZEFeatures::Create_Nonlinear_Scale_Space(const cv::Mat& img) {
- double t1 = 0.0, t2 = 0.0;
+ //double t1 = 0.0, t2 = 0.0;
if (evolution_.size() == 0) {
cerr << "Error generating the nonlinear scale space!!" << endl;
return -1;
}
- t1 = cv::getTickCount();
+ //t1 = cv::getTickCount();
// Copy the original image to the first level of the evolution
img.copyTo(evolution_[0].Lt);
// First compute the kcontrast factor
options_.kcontrast = compute_k_percentile(img, options_.kcontrast_percentile,
- 1.0, options_.kcontrast_nbins, 0, 0);
+ 1.0f, options_.kcontrast_nbins, 0, 0);
- t2 = cv::getTickCount();
- timing_.kcontrast = 1000.0*(t2 - t1) / cv::getTickFrequency();
+ //t2 = cv::getTickCount();
+ //timing_.kcontrast = 1000.0*(t2 - t1) / cv::getTickFrequency();
// Now generate the rest of evolution levels
for (size_t i = 1; i < evolution_.size(); i++) {
if (evolution_[i].octave > evolution_[i - 1].octave) {
halfsample_image(evolution_[i - 1].Lt, evolution_[i].Lt);
- options_.kcontrast = options_.kcontrast*0.75;
+ options_.kcontrast = options_.kcontrast*0.75f;
}
else {
evolution_[i - 1].Lt.copyTo(evolution_[i].Lt);
}
- gaussian_2D_convolution(evolution_[i].Lt, evolution_[i].Lsmooth, 0, 0, 1.0);
+ gaussian_2D_convolution(evolution_[i].Lt, evolution_[i].Lsmooth, 0, 0, 1.0f);
// Compute the Gaussian derivatives Lx and Ly
image_derivatives_scharr(evolution_[i].Lsmooth, evolution_[i].Lx, 1, 0);
}
}
- t2 = cv::getTickCount();
- timing_.scale = 1000.0*(t2 - t1) / cv::getTickFrequency();
+ //t2 = cv::getTickCount();
+ //timing_.scale = 1000.0*(t2 - t1) / cv::getTickFrequency();
return 0;
}
*/
void AKAZEFeatures::Feature_Detection(std::vector<cv::KeyPoint>& kpts) {
- double t1 = 0.0, t2 = 0.0;
+ //double t1 = 0.0, t2 = 0.0;
- t1 = cv::getTickCount();
+ //t1 = cv::getTickCount();
kpts.clear();
Find_Scale_Space_Extrema(kpts);
Do_Subpixel_Refinement(kpts);
- t2 = cv::getTickCount();
- timing_.detector = 1000.0*(t2 - t1) / cv::getTickFrequency();
+ //t2 = cv::getTickCount();
+ //timing_.detector = 1000.0*(t2 - t1) / cv::getTickFrequency();
}
/* ************************************************************************* */
{
public:
explicit MultiscaleDerivativesInvoker(std::vector<TEvolution>& ev, const AKAZEOptions& opt)
- : evolution_(ev)
+ : evolution_(&ev)
, options_(opt)
{
}
void operator()(const cv::Range& range) const
{
+ std::vector<TEvolution>& evolution = *evolution_;
+
for (int i = range.start; i < range.end; i++)
{
- float ratio = pow(2.f, (float)evolution_[i].octave);
- int sigma_size_ = fRound(evolution_[i].esigma * options_.derivative_factor / ratio);
-
- compute_scharr_derivatives(evolution_[i].Lsmooth, evolution_[i].Lx, 1, 0, sigma_size_);
- compute_scharr_derivatives(evolution_[i].Lsmooth, evolution_[i].Ly, 0, 1, sigma_size_);
- compute_scharr_derivatives(evolution_[i].Lx, evolution_[i].Lxx, 1, 0, sigma_size_);
- compute_scharr_derivatives(evolution_[i].Ly, evolution_[i].Lyy, 0, 1, sigma_size_);
- compute_scharr_derivatives(evolution_[i].Lx, evolution_[i].Lxy, 0, 1, sigma_size_);
-
- evolution_[i].Lx = evolution_[i].Lx*((sigma_size_));
- evolution_[i].Ly = evolution_[i].Ly*((sigma_size_));
- evolution_[i].Lxx = evolution_[i].Lxx*((sigma_size_)*(sigma_size_));
- evolution_[i].Lxy = evolution_[i].Lxy*((sigma_size_)*(sigma_size_));
- evolution_[i].Lyy = evolution_[i].Lyy*((sigma_size_)*(sigma_size_));
+ float ratio = pow(2.f, (float)evolution[i].octave);
+ int sigma_size_ = fRound(evolution[i].esigma * options_.derivative_factor / ratio);
+
+ compute_scharr_derivatives(evolution[i].Lsmooth, evolution[i].Lx, 1, 0, sigma_size_);
+ compute_scharr_derivatives(evolution[i].Lsmooth, evolution[i].Ly, 0, 1, sigma_size_);
+ compute_scharr_derivatives(evolution[i].Lx, evolution[i].Lxx, 1, 0, sigma_size_);
+ compute_scharr_derivatives(evolution[i].Ly, evolution[i].Lyy, 0, 1, sigma_size_);
+ compute_scharr_derivatives(evolution[i].Lx, evolution[i].Lxy, 0, 1, sigma_size_);
+
+ evolution[i].Lx = evolution[i].Lx*((sigma_size_));
+ evolution[i].Ly = evolution[i].Ly*((sigma_size_));
+ evolution[i].Lxx = evolution[i].Lxx*((sigma_size_)*(sigma_size_));
+ evolution[i].Lxy = evolution[i].Lxy*((sigma_size_)*(sigma_size_));
+ evolution[i].Lyy = evolution[i].Lyy*((sigma_size_)*(sigma_size_));
}
}
private:
- std::vector<TEvolution> & evolution_;
+ std::vector<TEvolution>* evolution_;
AKAZEOptions options_;
};
*/
void AKAZEFeatures::Compute_Multiscale_Derivatives(void) {
- double t1 = 0.0, t2 = 0.0;
+ //double t1 = 0.0, t2 = 0.0;
- t1 = cv::getTickCount();
+ //t1 = cv::getTickCount();
cv::parallel_for_(cv::Range(0, evolution_.size()), MultiscaleDerivativesInvoker(evolution_, options_));
/*
evolution_[i].Lyy = evolution_[i].Lyy*((sigma_size_)*(sigma_size_));
}
*/
- t2 = cv::getTickCount();
- timing_.derivatives = 1000.0*(t2 - t1) / cv::getTickFrequency();
+ //t2 = cv::getTickCount();
+ //timing_.derivatives = 1000.0*(t2 - t1) / cv::getTickFrequency();
}
/* ************************************************************************* */
Compute_Multiscale_Derivatives();
for (size_t i = 0; i < evolution_.size(); i++) {
- if (options_.verbosity == true) {
- cout << "Computing detector response. Determinant of Hessian. Evolution time: " << evolution_[i].etime << endl;
- }
+
+ //if (options_.verbosity == true) {
+ // cout << "Computing detector response. Determinant of Hessian. Evolution time: " << evolution_[i].etime << endl;
+ //}
for (int ix = 0; ix < evolution_[i].Ldet.rows; ix++) {
for (int jx = 0; jx < evolution_[i].Ldet.cols; jx++) {
*/
void AKAZEFeatures::Find_Scale_Space_Extrema(std::vector<cv::KeyPoint>& kpts) {
- double t1 = 0.0, t2 = 0.0;
+ //double t1 = 0.0, t2 = 0.0;
float value = 0.0;
float dist = 0.0, ratio = 0.0, smax = 0.0;
int npoints = 0, id_repeated = 0;
// Set maximum size
if (options_.descriptor == SURF_UPRIGHT || options_.descriptor == SURF ||
options_.descriptor == MLDB_UPRIGHT || options_.descriptor == MLDB) {
- smax = 10.0*sqrtf(2.0);
+ smax = 10.0f*sqrtf(2.0f);
}
else if (options_.descriptor == MSURF_UPRIGHT || options_.descriptor == MSURF) {
- smax = 12.0*sqrtf(2.0);
+ smax = 12.0f*sqrtf(2.0f);
}
- t1 = cv::getTickCount();
+ //t1 = cv::getTickCount();
for (size_t i = 0; i < evolution_.size(); i++) {
for (int ix = 1; ix < evolution_[i].Ldet.rows - 1; ix++) {
point.class_id = i;
ratio = pow(2.f, point.octave);
sigma_size_ = fRound(point.size / ratio);
- point.pt.x = jx;
- point.pt.y = ix;
+ point.pt.x = static_cast<float>(jx);
+ point.pt.y = static_cast<float>(ix);
// Compare response with the same and lower scale
for (size_t ik = 0; ik < kpts_aux.size(); ik++) {
kpts.push_back(point);
}
- t2 = cv::getTickCount();
- timing_.extrema = 1000.0*(t2 - t1) / cv::getTickFrequency();
+ //t2 = cv::getTickCount();
+ //timing_.extrema = 1000.0*(t2 - t1) / cv::getTickFrequency();
}
/* ************************************************************************* */
*/
void AKAZEFeatures::Do_Subpixel_Refinement(std::vector<cv::KeyPoint>& kpts) {
- double t1 = 0.0, t2 = 0.0;
+ //double t1 = 0.0, t2 = 0.0;
float Dx = 0.0, Dy = 0.0, ratio = 0.0;
float Dxx = 0.0, Dyy = 0.0, Dxy = 0.0;
int x = 0, y = 0;
cv::Mat b = cv::Mat::zeros(2, 1, CV_32F);
cv::Mat dst = cv::Mat::zeros(2, 1, CV_32F);
- t1 = cv::getTickCount();
+ //t1 = cv::getTickCount();
for (size_t i = 0; i < kpts.size(); i++) {
ratio = pow(2.f, kpts[i].octave);
y = fRound(kpts[i].pt.y / ratio);
// Compute the gradient
- Dx = (0.5)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x + 1)
+ Dx = (0.5f)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x + 1)
- *(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x - 1));
- Dy = (0.5)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x)
+ Dy = (0.5f)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x)
- *(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x));
// Compute the Hessian
Dxx = (*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x + 1)
+ *(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x - 1)
- - 2.0*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x)));
+ - 2.0f*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x)));
Dyy = (*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x)
+ *(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x)
- - 2.0*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x)));
+ - 2.0f*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x)));
- Dxy = (0.25)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x + 1)
+ Dxy = (0.25f)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x + 1)
+ (*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x - 1)))
- - (0.25)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x + 1)
+ - (0.25f)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x + 1)
+ (*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x - 1)));
// Solve the linear system
cv::solve(A, b, dst, DECOMP_LU);
- if (fabs(*(dst.ptr<float>(0))) <= 1.0 && fabs(*(dst.ptr<float>(1))) <= 1.0) {
+ if (fabs(*(dst.ptr<float>(0))) <= 1.0f && fabs(*(dst.ptr<float>(1))) <= 1.0f) {
kpts[i].pt.x = x + (*(dst.ptr<float>(0)));
kpts[i].pt.y = y + (*(dst.ptr<float>(1)));
- kpts[i].pt.x *= powf(2.f, evolution_[kpts[i].class_id].octave);
- kpts[i].pt.y *= powf(2.f, evolution_[kpts[i].class_id].octave);
+ kpts[i].pt.x *= powf(2.f, (float)evolution_[kpts[i].class_id].octave);
+ kpts[i].pt.y *= powf(2.f, (float)evolution_[kpts[i].class_id].octave);
kpts[i].angle = 0.0;
// In OpenCV the size of a keypoint its the diameter
- kpts[i].size *= 2.0;
+ kpts[i].size *= 2.0f;
}
// Delete the point since its not stable
else {
}
}
- t2 = cv::getTickCount();
- timing_.subpixel = 1000.0*(t2 - t1) / cv::getTickFrequency();
+ //t2 = cv::getTickCount();
+ //timing_.subpixel = 1000.0*(t2 - t1) / cv::getTickFrequency();
}
/* ************************************************************************* */
{
public:
SURF_Descriptor_Upright_64_Invoker(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc, std::vector<TEvolution>& evolution, AKAZEOptions& options)
- : keypoints_(kpts)
- , descriptors_(desc)
- , evolution_(evolution)
- , options_(options)
+ : keypoints_(&kpts)
+ , descriptors_(&desc)
+ , evolution_(&evolution)
+ , options_(&options)
{
}
{
for (int i = range.start; i < range.end; i++)
{
- Get_SURF_Descriptor_Upright_64(keypoints_[i], descriptors_.ptr<float>(i));
+ Get_SURF_Descriptor_Upright_64((*keypoints_)[i], descriptors_->ptr<float>(i));
}
}
void Get_SURF_Descriptor_Upright_64(const cv::KeyPoint& kpt, float* desc) const;
private:
- std::vector<cv::KeyPoint>& keypoints_;
- cv::Mat& descriptors_;
- std::vector<TEvolution>& evolution_;
- AKAZEOptions& options_;
+ std::vector<cv::KeyPoint>* keypoints_;
+ cv::Mat* descriptors_;
+ std::vector<TEvolution>* evolution_;
+ AKAZEOptions* options_;
};
class SURF_Descriptor_64_Invoker : public cv::ParallelLoopBody
{
public:
SURF_Descriptor_64_Invoker(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc, std::vector<TEvolution>& evolution, AKAZEOptions& options)
- : keypoints_(kpts)
- , descriptors_(desc)
- , evolution_(evolution)
- , options_(options)
+ : keypoints_(&kpts)
+ , descriptors_(&desc)
+ , evolution_(&evolution)
+ , options_(&options)
{
}
{
for (int i = range.start; i < range.end; i++)
{
- AKAZEFeatures::Compute_Main_Orientation(keypoints_[i], evolution_);
- Get_SURF_Descriptor_64(keypoints_[i], descriptors_.ptr<float>(i));
+ AKAZEFeatures::Compute_Main_Orientation((*keypoints_)[i], *evolution_);
+ Get_SURF_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i));
}
}
void Get_SURF_Descriptor_64(const cv::KeyPoint& kpt, float* desc) const;
private:
- std::vector<cv::KeyPoint>& keypoints_;
- cv::Mat& descriptors_;
- std::vector<TEvolution>& evolution_;
- AKAZEOptions& options_;
+ std::vector<cv::KeyPoint>* keypoints_;
+ cv::Mat* descriptors_;
+ std::vector<TEvolution>* evolution_;
+ AKAZEOptions* options_;
};
class MSURF_Upright_Descriptor_64_Invoker : public cv::ParallelLoopBody
{
public:
MSURF_Upright_Descriptor_64_Invoker(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc, std::vector<TEvolution>& evolution, AKAZEOptions& options)
- : keypoints_(kpts)
- , descriptors_(desc)
- , evolution_(evolution)
- , options_(options)
+ : keypoints_(&kpts)
+ , descriptors_(&desc)
+ , evolution_(&evolution)
+ , options_(&options)
{
}
{
for (int i = range.start; i < range.end; i++)
{
- Get_MSURF_Upright_Descriptor_64(keypoints_[i], descriptors_.ptr<float>(i));
+ Get_MSURF_Upright_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i));
}
}
void Get_MSURF_Upright_Descriptor_64(const cv::KeyPoint& kpt, float* desc) const;
private:
- std::vector<cv::KeyPoint>& keypoints_;
- cv::Mat& descriptors_;
- std::vector<TEvolution>& evolution_;
- AKAZEOptions& options_;
+ std::vector<cv::KeyPoint>* keypoints_;
+ cv::Mat* descriptors_;
+ std::vector<TEvolution>* evolution_;
+ AKAZEOptions* options_;
};
class MSURF_Descriptor_64_Invoker : public cv::ParallelLoopBody
{
public:
MSURF_Descriptor_64_Invoker(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc, std::vector<TEvolution>& evolution, AKAZEOptions& options)
- : keypoints_(kpts)
- , descriptors_(desc)
- , evolution_(evolution)
- , options_(options)
+ : keypoints_(&kpts)
+ , descriptors_(&desc)
+ , evolution_(&evolution)
+ , options_(&options)
{
}
{
for (int i = range.start; i < range.end; i++)
{
- AKAZEFeatures::Compute_Main_Orientation(keypoints_[i], evolution_);
- Get_MSURF_Descriptor_64(keypoints_[i], descriptors_.ptr<float>(i));
+ AKAZEFeatures::Compute_Main_Orientation((*keypoints_)[i], *evolution_);
+ Get_MSURF_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i));
}
}
void Get_MSURF_Descriptor_64(const cv::KeyPoint& kpt, float* desc) const;
private:
- std::vector<cv::KeyPoint>& keypoints_;
- cv::Mat& descriptors_;
- std::vector<TEvolution>& evolution_;
- AKAZEOptions& options_;
+ std::vector<cv::KeyPoint>* keypoints_;
+ cv::Mat* descriptors_;
+ std::vector<TEvolution>* evolution_;
+ AKAZEOptions* options_;
};
class Upright_MLDB_Full_Descriptor_Invoker : public cv::ParallelLoopBody
{
public:
Upright_MLDB_Full_Descriptor_Invoker(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc, std::vector<TEvolution>& evolution, AKAZEOptions& options)
- : keypoints_(kpts)
- , descriptors_(desc)
- , evolution_(evolution)
- , options_(options)
+ : keypoints_(&kpts)
+ , descriptors_(&desc)
+ , evolution_(&evolution)
+ , options_(&options)
{
}
{
for (int i = range.start; i < range.end; i++)
{
- Get_Upright_MLDB_Full_Descriptor(keypoints_[i], descriptors_.ptr<unsigned char>(i));
+ Get_Upright_MLDB_Full_Descriptor((*keypoints_)[i], descriptors_->ptr<unsigned char>(i));
}
}
void Get_Upright_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned char* desc) const;
private:
- std::vector<cv::KeyPoint>& keypoints_;
- cv::Mat& descriptors_;
- std::vector<TEvolution>& evolution_;
- AKAZEOptions& options_;
+ std::vector<cv::KeyPoint>* keypoints_;
+ cv::Mat* descriptors_;
+ std::vector<TEvolution>* evolution_;
+ AKAZEOptions* options_;
};
class Upright_MLDB_Descriptor_Subset_Invoker : public cv::ParallelLoopBody
AKAZEOptions& options,
cv::Mat descriptorSamples,
cv::Mat descriptorBits)
- : keypoints_(kpts)
- , descriptors_(desc)
- , evolution_(evolution)
- , options_(options)
+ : keypoints_(&kpts)
+ , descriptors_(&desc)
+ , evolution_(&evolution)
+ , options_(&options)
, descriptorSamples_(descriptorSamples)
, descriptorBits_(descriptorBits)
{
{
for (int i = range.start; i < range.end; i++)
{
- Get_Upright_MLDB_Descriptor_Subset(keypoints_[i], descriptors_.ptr<unsigned char>(i));
+ Get_Upright_MLDB_Descriptor_Subset((*keypoints_)[i], descriptors_->ptr<unsigned char>(i));
}
}
void Get_Upright_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char* desc) const;
private:
- std::vector<cv::KeyPoint>& keypoints_;
- cv::Mat& descriptors_;
- std::vector<TEvolution>& evolution_;
- AKAZEOptions& options_;
+ std::vector<cv::KeyPoint>* keypoints_;
+ cv::Mat* descriptors_;
+ std::vector<TEvolution>* evolution_;
+ AKAZEOptions* options_;
cv::Mat descriptorSamples_; // List of positions in the grids to sample LDB bits from.
cv::Mat descriptorBits_;
{
public:
MLDB_Full_Descriptor_Invoker(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc, std::vector<TEvolution>& evolution, AKAZEOptions& options)
- : keypoints_(kpts)
- , descriptors_(desc)
- , evolution_(evolution)
- , options_(options)
+ : keypoints_(&kpts)
+ , descriptors_(&desc)
+ , evolution_(&evolution)
+ , options_(&options)
{
}
{
for (int i = range.start; i < range.end; i++)
{
- AKAZEFeatures::Compute_Main_Orientation(keypoints_[i], evolution_);
- Get_MLDB_Full_Descriptor(keypoints_[i], descriptors_.ptr<unsigned char>(i));
+ AKAZEFeatures::Compute_Main_Orientation((*keypoints_)[i], *evolution_);
+ Get_MLDB_Full_Descriptor((*keypoints_)[i], descriptors_->ptr<unsigned char>(i));
}
}
void Get_MLDB_Full_Descriptor(const cv::KeyPoint& kpt, unsigned char* desc) const;
private:
- std::vector<cv::KeyPoint>& keypoints_;
- cv::Mat& descriptors_;
- std::vector<TEvolution>& evolution_;
- AKAZEOptions& options_;
+ std::vector<cv::KeyPoint>* keypoints_;
+ cv::Mat* descriptors_;
+ std::vector<TEvolution>* evolution_;
+ AKAZEOptions* options_;
};
class MLDB_Descriptor_Subset_Invoker : public cv::ParallelLoopBody
AKAZEOptions& options,
cv::Mat descriptorSamples,
cv::Mat descriptorBits)
- : keypoints_(kpts)
- , descriptors_(desc)
- , evolution_(evolution)
- , options_(options)
+ : keypoints_(&kpts)
+ , descriptors_(&desc)
+ , evolution_(&evolution)
+ , options_(&options)
, descriptorSamples_(descriptorSamples)
, descriptorBits_(descriptorBits)
{
{
for (int i = range.start; i < range.end; i++)
{
- AKAZEFeatures::Compute_Main_Orientation(keypoints_[i], evolution_);
- Get_MLDB_Descriptor_Subset(keypoints_[i], descriptors_.ptr<unsigned char>(i));
+ AKAZEFeatures::Compute_Main_Orientation((*keypoints_)[i], *evolution_);
+ Get_MLDB_Descriptor_Subset((*keypoints_)[i], descriptors_->ptr<unsigned char>(i));
}
}
void Get_MLDB_Descriptor_Subset(const cv::KeyPoint& kpt, unsigned char* desc) const;
private:
- std::vector<cv::KeyPoint>& keypoints_;
- cv::Mat& descriptors_;
- std::vector<TEvolution>& evolution_;
- AKAZEOptions& options_;
+ std::vector<cv::KeyPoint>* keypoints_;
+ cv::Mat* descriptors_;
+ std::vector<TEvolution>* evolution_;
+ AKAZEOptions* options_;
cv::Mat descriptorSamples_; // List of positions in the grids to sample LDB bits from.
cv::Mat descriptorBits_;
*/
void AKAZEFeatures::Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc) {
- double t1 = 0.0, t2 = 0.0;
+ //double t1 = 0.0, t2 = 0.0;
- t1 = cv::getTickCount();
+ //t1 = cv::getTickCount();
// Allocate memory for the matrix with the descriptors
if (options_.descriptor < MLDB_UPRIGHT) {
// We use the full length binary descriptor -> 486 bits
if (options_.descriptor_size == 0) {
int t = (6 + 36 + 120)*options_.descriptor_channels;
- desc = cv::Mat::zeros(kpts.size(), ceil(t / 8.), CV_8UC1);
+ desc = cv::Mat::zeros(kpts.size(), (int)ceil(t / 8.), CV_8UC1);
}
else {
// We use the random bit selection length binary descriptor
- desc = cv::Mat::zeros(kpts.size(), ceil(options_.descriptor_size / 8.), CV_8UC1);
+ desc = cv::Mat::zeros(kpts.size(), (int)ceil(options_.descriptor_size / 8.), CV_8UC1);
}
}
break;
}
- t2 = cv::getTickCount();
- timing_.descriptor = 1000.0*(t2 - t1) / cv::getTickFrequency();
+ //t2 = cv::getTickCount();
+ //timing_.descriptor = 1000.0*(t2 - t1) / cv::getTickFrequency();
}
/* ************************************************************************* */
// Get the information from the keypoint
level = kpt.class_id;
ratio = (float)(1 << evolution_[level].octave);
- s = fRound(0.5*kpt.size / ratio);
+ s = fRound(0.5f*kpt.size / ratio);
xf = kpt.pt.x / ratio;
yf = kpt.pt.y / ratio;
}
// Loop slides pi/3 window around feature point
- for (ang1 = 0; ang1 < 2.0*CV_PI; ang1 += 0.15f) {
- ang2 = (ang1 + CV_PI / 3.0f > 2.0*CV_PI ? ang1 - 5.0f*CV_PI / 3.0f : ang1 + CV_PI / 3.0f);
+ for (ang1 = 0; ang1 < (float)(2.0 * CV_PI); ang1 += 0.15f) {
+ ang2 = (ang1 + (float)(CV_PI / 3.0) > (float)(2.0*CV_PI) ? ang1 - (float)(5.0*CV_PI / 3.0) : ang1 + (float)(CV_PI / 3.0));
sumX = sumY = 0.f;
for (size_t k = 0; k < Ang.size(); ++k) {
sumY += resY[k];
}
else if (ang2 < ang1 &&
- ((ang > 0 && ang < ang2) || (ang > ang1 && ang < 2.0*CV_PI))) {
+ ((ang > 0 && ang < ang2) || (ang > ang1 && ang < 2.0f*CV_PI))) {
sumX += resX[k];
sumY += resY[k];
}
int x1 = 0, y1 = 0, x2 = 0, y2 = 0, sample_step = 0, pattern_size = 0, dcount = 0;
int scale = 0, dsize = 0, level = 0;
+ const std::vector<TEvolution>& evolution = *evolution_;
+
// Set the descriptor size and the sample and pattern sizes
dsize = 64;
sample_step = 5;
// Get the information from the keypoint
ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5*kpt.size / ratio);
+ scale = fRound(0.5f*kpt.size / ratio);
level = kpt.class_id;
yf = kpt.pt.y / ratio;
xf = kpt.pt.x / ratio;
sample_y = yf + l*scale;
sample_x = xf + k*scale;
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
fx = sample_x - x1;
fy = sample_y - y1;
- res1 = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
- res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
- res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ res1 = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ res2 = *(evolution[level].Lx.ptr<float>(y1)+x2);
+ res3 = *(evolution[level].Lx.ptr<float>(y2)+x1);
+ res4 = *(evolution[level].Lx.ptr<float>(y2)+x2);
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
- res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
- res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
- res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
- res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ res1 = *(evolution[level].Ly.ptr<float>(y1)+x1);
+ res2 = *(evolution[level].Ly.ptr<float>(y1)+x2);
+ res3 = *(evolution[level].Ly.ptr<float>(y2)+x1);
+ res4 = *(evolution[level].Ly.ptr<float>(y2)+x2);
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Sum the derivatives to the cumulative descriptor
dx += rx;
sample_step = 5;
pattern_size = 10;
+ const std::vector<TEvolution>& evolution = *evolution_;
+
// Get the information from the keypoint
ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5*kpt.size / ratio);
+ scale = fRound(0.5f*kpt.size / ratio);
angle = kpt.angle;
level = kpt.class_id;
yf = kpt.pt.y / ratio;
sample_y = yf + (l*scale*co + k*scale*si);
sample_x = xf + (-l*scale*si + k*scale*co);
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
fx = sample_x - x1;
fy = sample_y - y1;
- res1 = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
- res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
- res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ res1 = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ res2 = *(evolution[level].Lx.ptr<float>(y1)+x2);
+ res3 = *(evolution[level].Lx.ptr<float>(y2)+x1);
+ res4 = *(evolution[level].Lx.ptr<float>(y2)+x2);
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
- res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
- res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
- res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
- res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ res1 = *(evolution[level].Ly.ptr<float>(y1)+x1);
+ res2 = *(evolution[level].Ly.ptr<float>(y1)+x2);
+ res3 = *(evolution[level].Ly.ptr<float>(y2)+x1);
+ res4 = *(evolution[level].Ly.ptr<float>(y2)+x2);
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Get the x and y derivatives on the rotated axis
rry = rx*co + ry*si;
int scale = 0, dsize = 0, level = 0;
// Subregion centers for the 4x4 gaussian weighting
- float cx = -0.5, cy = 0.5;
+ float cx = -0.5f, cy = 0.5f;
+
+ const std::vector<TEvolution>& evolution = *evolution_;
// Set the descriptor size and the sample and pattern sizes
dsize = 64;
// Get the information from the keypoint
ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5*kpt.size / ratio);
+ scale = fRound(0.5f*kpt.size / ratio);
level = kpt.class_id;
yf = kpt.pt.y / ratio;
xf = kpt.pt.x / ratio;
j = -8;
i = i - 4;
- cx += 1.0;
- cy = -0.5;
+ cx += 1.0f;
+ cy = -0.5f;
while (j < pattern_size) {
dx = dy = mdx = mdy = 0.0;
- cy += 1.0;
+ cy += 1.0f;
j = j - 4;
ky = i + sample_step;
sample_x = l*scale + xf;
//Get the gaussian weighted x and y responses
- gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.50*scale);
+ gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.50f*scale);
y1 = (int)(sample_y - .5);
x1 = (int)(sample_x - .5);
fx = sample_x - x1;
fy = sample_y - y1;
- res1 = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
- res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
- res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ res1 = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ res2 = *(evolution[level].Lx.ptr<float>(y1)+x2);
+ res3 = *(evolution[level].Lx.ptr<float>(y2)+x1);
+ res4 = *(evolution[level].Lx.ptr<float>(y2)+x2);
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
- res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
- res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
- res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
- res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ res1 = *(evolution[level].Ly.ptr<float>(y1)+x1);
+ res2 = *(evolution[level].Ly.ptr<float>(y1)+x2);
+ res3 = *(evolution[level].Ly.ptr<float>(y2)+x1);
+ res4 = *(evolution[level].Ly.ptr<float>(y2)+x2);
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
rx = gauss_s1*rx;
ry = gauss_s1*ry;
int scale = 0, dsize = 0, level = 0;
// Subregion centers for the 4x4 gaussian weighting
- float cx = -0.5, cy = 0.5;
+ float cx = -0.5f, cy = 0.5f;
+
+ const std::vector<TEvolution>& evolution = *evolution_;
// Set the descriptor size and the sample and pattern sizes
dsize = 64;
// Get the information from the keypoint
ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5*kpt.size / ratio);
+ scale = fRound(0.5f*kpt.size / ratio);
angle = kpt.angle;
level = kpt.class_id;
yf = kpt.pt.y / ratio;
j = -8;
i = i - 4;
- cx += 1.0;
- cy = -0.5;
+ cx += 1.0f;
+ cy = -0.5f;
while (j < pattern_size) {
dx = dy = mdx = mdy = 0.0;
- cy += 1.0;
+ cy += 1.0f;
j = j - 4;
ky = i + sample_step;
sample_x = xf + (-l*scale*si + k*scale*co);
// Get the gaussian weighted x and y responses
- gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5*scale);
+ gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5f*scale);
- y1 = fRound(sample_y - .5);
- x1 = fRound(sample_x - .5);
+ y1 = fRound(sample_y - 0.5f);
+ x1 = fRound(sample_x - 0.5f);
- y2 = fRound(sample_y + .5);
- x2 = fRound(sample_x + .5);
+ y2 = fRound(sample_y + 0.5f);
+ x2 = fRound(sample_x + 0.5f);
fx = sample_x - x1;
fy = sample_y - y1;
- res1 = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
- res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
- res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ res1 = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ res2 = *(evolution[level].Lx.ptr<float>(y1)+x2);
+ res3 = *(evolution[level].Lx.ptr<float>(y2)+x1);
+ res4 = *(evolution[level].Lx.ptr<float>(y2)+x2);
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
- res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
- res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
- res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
- res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ res1 = *(evolution[level].Ly.ptr<float>(y1)+x1);
+ res2 = *(evolution[level].Ly.ptr<float>(y1)+x2);
+ res3 = *(evolution[level].Ly.ptr<float>(y2)+x1);
+ res4 = *(evolution[level].Ly.ptr<float>(y2)+x2);
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Get the x and y derivatives on the rotated axis
rry = gauss_s1*(rx*co + ry*si);
int level = 0, nsamples = 0, scale = 0;
int dcount1 = 0, dcount2 = 0;
+ const AKAZEOptions & options = *options_;
+ const std::vector<TEvolution>& evolution = *evolution_;
+
// Matrices for the M-LDB descriptor
- cv::Mat values_1 = cv::Mat::zeros(4, options_.descriptor_channels, CV_32FC1);
- cv::Mat values_2 = cv::Mat::zeros(9, options_.descriptor_channels, CV_32FC1);
- cv::Mat values_3 = cv::Mat::zeros(16, options_.descriptor_channels, CV_32FC1);
+ cv::Mat values_1 = cv::Mat::zeros(4, options.descriptor_channels, CV_32FC1);
+ cv::Mat values_2 = cv::Mat::zeros(9, options.descriptor_channels, CV_32FC1);
+ cv::Mat values_3 = cv::Mat::zeros(16, options.descriptor_channels, CV_32FC1);
// Get the information from the keypoint
ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5*kpt.size / ratio);
+ scale = fRound(0.5f*kpt.size / ratio);
level = kpt.class_id;
yf = kpt.pt.y / ratio;
xf = kpt.pt.x / ratio;
// First 2x2 grid
- pattern_size = options_.descriptor_pattern_size;
+ pattern_size = options_->descriptor_pattern_size;
sample_step = pattern_size;
for (int i = -pattern_size; i < pattern_size; i += sample_step) {
y1 = fRound(sample_y);
x1 = fRound(sample_x);
- ri = *(evolution_[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution_[level].Ly.ptr<float>(y1)+x1);
+ ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
+ rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
di += ri;
dx += rx;
}
// Second 3x3 grid
- sample_step = ceil(pattern_size*2. / 3.);
+ sample_step = static_cast<int>(ceil(pattern_size*2. / 3.));
dcount2 = 0;
for (int i = -pattern_size; i < pattern_size; i += sample_step) {
y1 = fRound(sample_y);
x1 = fRound(sample_x);
- ri = *(evolution_[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution_[level].Ly.ptr<float>(y1)+x1);
+ ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
+ rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
di += ri;
dx += rx;
y1 = fRound(sample_y);
x1 = fRound(sample_x);
- ri = *(evolution_[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution_[level].Ly.ptr<float>(y1)+x1);
+ ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
+ rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
di += ri;
dx += rx;
int level = 0, nsamples = 0, scale = 0;
int dcount1 = 0, dcount2 = 0;
+ const AKAZEOptions & options = *options_;
+ const std::vector<TEvolution>& evolution = *evolution_;
+
// Matrices for the M-LDB descriptor
- cv::Mat values_1 = cv::Mat::zeros(4, options_.descriptor_channels, CV_32FC1);
- cv::Mat values_2 = cv::Mat::zeros(9, options_.descriptor_channels, CV_32FC1);
- cv::Mat values_3 = cv::Mat::zeros(16, options_.descriptor_channels, CV_32FC1);
+ cv::Mat values_1 = cv::Mat::zeros(4, options.descriptor_channels, CV_32FC1);
+ cv::Mat values_2 = cv::Mat::zeros(9, options.descriptor_channels, CV_32FC1);
+ cv::Mat values_3 = cv::Mat::zeros(16, options.descriptor_channels, CV_32FC1);
// Get the information from the keypoint
ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5*kpt.size / ratio);
+ scale = fRound(0.5f*kpt.size / ratio);
angle = kpt.angle;
level = kpt.class_id;
yf = kpt.pt.y / ratio;
si = sin(angle);
// First 2x2 grid
- pattern_size = options_.descriptor_pattern_size;
+ pattern_size = options.descriptor_pattern_size;
sample_step = pattern_size;
for (int i = -pattern_size; i < pattern_size; i += sample_step) {
di = dx = dy = 0.0;
nsamples = 0;
- for (float k = i; k < i + sample_step; k++) {
- for (float l = j; l < j + sample_step; l++) {
+ for (float k = (float)i; k < i + sample_step; k++) {
+ for (float l = (float)j; l < j + sample_step; l++) {
// Get the coordinates of the sample point
sample_y = yf + (l*scale*co + k*scale*si);
y1 = fRound(sample_y);
x1 = fRound(sample_x);
- ri = *(evolution_[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution_[level].Ly.ptr<float>(y1)+x1);
+ ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
+ rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
di += ri;
- if (options_.descriptor_channels == 2) {
+ if (options.descriptor_channels == 2) {
dx += sqrtf(rx*rx + ry*ry);
}
- else if (options_.descriptor_channels == 3) {
+ else if (options.descriptor_channels == 3) {
// Get the x and y derivatives on the rotated axis
rry = rx*co + ry*si;
rrx = -rx*si + ry*co;
dy /= nsamples;
*(values_1.ptr<float>(dcount2)) = di;
- if (options_.descriptor_channels > 1) {
+ if (options.descriptor_channels > 1) {
*(values_1.ptr<float>(dcount2)+1) = dx;
}
- if (options_.descriptor_channels > 2) {
+ if (options.descriptor_channels > 2) {
*(values_1.ptr<float>(dcount2)+2) = dy;
}
}
}
- if (options_.descriptor_channels > 1) {
+ if (options.descriptor_channels > 1) {
for (int i = 0; i < 4; i++) {
for (int j = i + 1; j < 4; j++) {
if (*(values_1.ptr<float>(i)+1) > *(values_1.ptr<float>(j)+1)) {
}
}
- if (options_.descriptor_channels > 2) {
+ if (options.descriptor_channels > 2) {
for (int i = 0; i < 4; i++) {
for (int j = i + 1; j < 4; j++) {
if (*(values_1.ptr<float>(i)+2) > *(values_1.ptr<float>(j)+2)) {
}
// Second 3x3 grid
- sample_step = ceil(pattern_size*2. / 3.);
+ sample_step = static_cast<int>(ceil(pattern_size*2. / 3.));
dcount2 = 0;
for (int i = -pattern_size; i < pattern_size; i += sample_step) {
y1 = fRound(sample_y);
x1 = fRound(sample_x);
- ri = *(evolution_[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution_[level].Ly.ptr<float>(y1)+x1);
+ ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
+ rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
di += ri;
- if (options_.descriptor_channels == 2) {
+ if (options.descriptor_channels == 2) {
dx += sqrtf(rx*rx + ry*ry);
}
- else if (options_.descriptor_channels == 3) {
+ else if (options.descriptor_channels == 3) {
// Get the x and y derivatives on the rotated axis
rry = rx*co + ry*si;
rrx = -rx*si + ry*co;
dy /= nsamples;
*(values_2.ptr<float>(dcount2)) = di;
- if (options_.descriptor_channels > 1) {
+ if (options.descriptor_channels > 1) {
*(values_2.ptr<float>(dcount2)+1) = dx;
}
- if (options_.descriptor_channels > 2) {
+ if (options.descriptor_channels > 2) {
*(values_2.ptr<float>(dcount2)+2) = dy;
}
}
}
- if (options_.descriptor_channels > 1) {
+ if (options.descriptor_channels > 1) {
for (int i = 0; i < 9; i++) {
for (int j = i + 1; j < 9; j++) {
if (*(values_2.ptr<float>(i)+1) > *(values_2.ptr<float>(j)+1)) {
}
}
- if (options_.descriptor_channels > 2) {
+ if (options.descriptor_channels > 2) {
for (int i = 0; i < 9; i++) {
for (int j = i + 1; j < 9; j++) {
if (*(values_2.ptr<float>(i)+2) > *(values_2.ptr<float>(j)+2)) {
y1 = fRound(sample_y);
x1 = fRound(sample_x);
- ri = *(evolution_[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution_[level].Ly.ptr<float>(y1)+x1);
+ ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
+ rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
di += ri;
- if (options_.descriptor_channels == 2) {
+ if (options.descriptor_channels == 2) {
dx += sqrtf(rx*rx + ry*ry);
}
- else if (options_.descriptor_channels == 3) {
+ else if (options.descriptor_channels == 3) {
// Get the x and y derivatives on the rotated axis
rry = rx*co + ry*si;
rrx = -rx*si + ry*co;
dy /= nsamples;
*(values_3.ptr<float>(dcount2)) = di;
- if (options_.descriptor_channels > 1)
+ if (options.descriptor_channels > 1)
*(values_3.ptr<float>(dcount2)+1) = dx;
- if (options_.descriptor_channels > 2)
+ if (options.descriptor_channels > 2)
*(values_3.ptr<float>(dcount2)+2) = dy;
dcount2++;
}
}
- if (options_.descriptor_channels > 1) {
+ if (options.descriptor_channels > 1) {
for (int i = 0; i < 16; i++) {
for (int j = i + 1; j < 16; j++) {
if (*(values_3.ptr<float>(i)+1) > *(values_3.ptr<float>(j)+1)) {
}
}
- if (options_.descriptor_channels > 2) {
+ if (options.descriptor_channels > 2) {
for (int i = 0; i < 16; i++) {
for (int j = i + 1; j < 16; j++) {
if (*(values_3.ptr<float>(i)+2) > *(values_3.ptr<float>(j)+2)) {
float sample_x = 0.f, sample_y = 0.f;
int x1 = 0, y1 = 0;
+ const AKAZEOptions & options = *options_;
+ const std::vector<TEvolution>& evolution = *evolution_;
+
// Get the information from the keypoint
float ratio = (float)(1 << kpt.octave);
- int scale = fRound(0.5*kpt.size / ratio);
+ int scale = fRound(0.5f*kpt.size / ratio);
float angle = kpt.angle;
- float level = kpt.class_id;
+ int level = kpt.class_id;
float yf = kpt.pt.y / ratio;
float xf = kpt.pt.x / ratio;
float co = cos(angle);
float si = sin(angle);
// Allocate memory for the matrix of values
- cv::Mat values = cv::Mat_<float>::zeros((4 + 9 + 16)*options_.descriptor_channels, 1);
+ cv::Mat values = cv::Mat_<float>::zeros((4 + 9 + 16)*options.descriptor_channels, 1);
// Sample everything, but only do the comparisons
vector<int> steps(3);
- steps.at(0) = options_.descriptor_pattern_size;
- steps.at(1) = ceil(2.f*options_.descriptor_pattern_size / 3.f);
- steps.at(2) = options_.descriptor_pattern_size / 2;
+ steps.at(0) = options.descriptor_pattern_size;
+ steps.at(1) = (int)ceil(2.f*options.descriptor_pattern_size / 3.f);
+ steps.at(2) = options.descriptor_pattern_size / 2;
for (int i = 0; i < descriptorSamples_.rows; i++) {
const int *coords = descriptorSamples_.ptr<int>(i);
y1 = fRound(sample_y);
x1 = fRound(sample_x);
- di += *(evolution_[level].Lt.ptr<float>(y1)+x1);
+ di += *(evolution[level].Lt.ptr<float>(y1)+x1);
- if (options_.descriptor_channels > 1) {
- rx = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution_[level].Ly.ptr<float>(y1)+x1);
+ if (options.descriptor_channels > 1) {
+ rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
- if (options_.descriptor_channels == 2) {
+ if (options.descriptor_channels == 2) {
dx += sqrtf(rx*rx + ry*ry);
}
- else if (options_.descriptor_channels == 3) {
+ else if (options.descriptor_channels == 3) {
// Get the x and y derivatives on the rotated axis
dx += rx*co + ry*si;
dy += -rx*si + ry*co;
}
}
- *(values.ptr<float>(options_.descriptor_channels*i)) = di;
+ *(values.ptr<float>(options.descriptor_channels*i)) = di;
- if (options_.descriptor_channels == 2) {
- *(values.ptr<float>(options_.descriptor_channels*i + 1)) = dx;
+ if (options.descriptor_channels == 2) {
+ *(values.ptr<float>(options.descriptor_channels*i + 1)) = dx;
}
- else if (options_.descriptor_channels == 3) {
- *(values.ptr<float>(options_.descriptor_channels*i + 1)) = dx;
- *(values.ptr<float>(options_.descriptor_channels*i + 2)) = dy;
+ else if (options.descriptor_channels == 3) {
+ *(values.ptr<float>(options.descriptor_channels*i + 1)) = dx;
+ *(values.ptr<float>(options.descriptor_channels*i + 2)) = dy;
}
}
float sample_x = 0.0f, sample_y = 0.0f;
int x1 = 0, y1 = 0;
+ const AKAZEOptions & options = *options_;
+ const std::vector<TEvolution>& evolution = *evolution_;
+
// Get the information from the keypoint
float ratio = (float)(1 << kpt.octave);
- int scale = fRound(0.5*kpt.size / ratio);
- float level = kpt.class_id;
+ int scale = fRound(0.5f*kpt.size / ratio);
+ int level = kpt.class_id;
float yf = kpt.pt.y / ratio;
float xf = kpt.pt.x / ratio;
// Allocate memory for the matrix of values
- Mat values = cv::Mat_<float>::zeros((4 + 9 + 16)*options_.descriptor_channels, 1);
+ Mat values = cv::Mat_<float>::zeros((4 + 9 + 16)*options.descriptor_channels, 1);
vector<int> steps(3);
- steps.at(0) = options_.descriptor_pattern_size;
- steps.at(1) = ceil(2.f*options_.descriptor_pattern_size / 3.f);
- steps.at(2) = options_.descriptor_pattern_size / 2;
+ steps.at(0) = options.descriptor_pattern_size;
+ steps.at(1) = static_cast<int>(ceil(2.f*options.descriptor_pattern_size / 3.f));
+ steps.at(2) = options.descriptor_pattern_size / 2;
for (int i = 0; i < descriptorSamples_.rows; i++) {
const int *coords = descriptorSamples_.ptr<int>(i);
y1 = fRound(sample_y);
x1 = fRound(sample_x);
- di += *(evolution_[level].Lt.ptr<float>(y1)+x1);
+ di += *(evolution[level].Lt.ptr<float>(y1)+x1);
- if (options_.descriptor_channels > 1) {
- rx = *(evolution_[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution_[level].Ly.ptr<float>(y1)+x1);
+ if (options.descriptor_channels > 1) {
+ rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
+ ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
- if (options_.descriptor_channels == 2) {
+ if (options.descriptor_channels == 2) {
dx += sqrtf(rx*rx + ry*ry);
}
- else if (options_.descriptor_channels == 3) {
+ else if (options.descriptor_channels == 3) {
dx += rx;
dy += ry;
}
}
}
- *(values.ptr<float>(options_.descriptor_channels*i)) = di;
+ *(values.ptr<float>(options.descriptor_channels*i)) = di;
- if (options_.descriptor_channels == 2) {
- *(values.ptr<float>(options_.descriptor_channels*i + 1)) = dx;
+ if (options.descriptor_channels == 2) {
+ *(values.ptr<float>(options.descriptor_channels*i + 1)) = dx;
}
- else if (options_.descriptor_channels == 3) {
- *(values.ptr<float>(options_.descriptor_channels*i + 1)) = dx;
- *(values.ptr<float>(options_.descriptor_channels*i + 2)) = dy;
+ else if (options.descriptor_channels == 3) {
+ *(values.ptr<float>(options.descriptor_channels*i + 1)) = dx;
+ *(values.ptr<float>(options.descriptor_channels*i + 2)) = dy;
}
}
/**
* @brief This method displays the computation times
*/
-void AKAZEFeatures::Show_Computation_Times() const {
- cout << "(*) Time Scale Space: " << timing_.scale << endl;
- cout << "(*) Time Detector: " << timing_.detector << endl;
- cout << " - Time Derivatives: " << timing_.derivatives << endl;
- cout << " - Time Extrema: " << timing_.extrema << endl;
- cout << " - Time Subpixel: " << timing_.subpixel << endl;
- cout << "(*) Time Descriptor: " << timing_.descriptor << endl;
- cout << endl;
-}
+//void AKAZEFeatures::Show_Computation_Times() const {
+// cout << "(*) Time Scale Space: " << timing_.scale << endl;
+// cout << "(*) Time Detector: " << timing_.detector << endl;
+// cout << " - Time Derivatives: " << timing_.derivatives << endl;
+// cout << " - Time Extrema: " << timing_.extrema << endl;
+// cout << " - Time Subpixel: " << timing_.subpixel << endl;
+// cout << "(*) Time Descriptor: " << timing_.descriptor << endl;
+// cout << endl;
+//}
/* ************************************************************************* */
/**
for (size_t i = 0, c = 0; i < 3; i++) {
int gdiv = i + 2; //grid divisions, per row
int gsz = gdiv*gdiv;
- int psz = ceil(2.*pattern_size / (float)gdiv);
+ int psz = (int)ceil(2.f*pattern_size / (float)gdiv);
for (int j = 0; j < gsz; j++) {
for (int k = j + 1; k < gsz; k++, c++) {
}
srand(1024);
- Mat_<int> comps = Mat_<int>(nchannels*ceil(nbits / (float)nchannels), 2);
+ Mat_<int> comps = Mat_<int>(nchannels * (int)ceil(nbits / (float)nchannels), 2);
comps = 1000;
// Select some samples. A sample includes all channels
int count = 0;
- size_t npicks = ceil(nbits / (float)nchannels);
+ size_t npicks = (size_t)ceil(nbits / (float)nchannels);
Mat_<int> samples(29, 3);
Mat_<int> fullcopy = fullM.clone();
samples = -1;
}
if (x < 0 && y >= 0) {
- return CV_PI - atanf(-y / x);
+ return static_cast<float>(CV_PI) - atanf(-y / x);
}
if (x < 0 && y < 0) {
- return CV_PI + atanf(y / x);
+ return static_cast<float>(CV_PI) + atanf(y / x);
}
if (x >= 0 && y < 0) {
- return 2.0*CV_PI - atanf(-y / x);
+ return static_cast<float>(2.0 * CV_PI) - atanf(-y / x);
}
return 0;
kcontrast_ = DEFAULT_KCONTRAST;
ncycles_ = 0;
reordering_ = true;
- tkcontrast_ = 0.0;
- tnlscale_ = 0.0;
- tdetector_ = 0.0;
- tmderivatives_ = 0.0;
- tdresponse_ = 0.0;
- tdescriptor_ = 0.0;
+ //tkcontrast_ = 0.0;
+ //tnlscale_ = 0.0;
+ //tdetector_ = 0.0;
+ //tmderivatives_ = 0.0;
+ //tdresponse_ = 0.0;
+ //tdescriptor_ = 0.0;
// Now allocate memory for the evolution
Allocate_Memory_Evolution();
aux.Lsmooth = cv::Mat::zeros(img_height_, img_width_, CV_32F);
aux.Lstep = cv::Mat::zeros(img_height_, img_width_, CV_32F);
aux.Ldet = cv::Mat::zeros(img_height_, img_width_, CV_32F);
- aux.esigma = soffset_*pow((float)2.0, (float)(j) / (float)(nsublevels_)+i);
- aux.etime = 0.5*(aux.esigma*aux.esigma);
+ aux.esigma = soffset_*pow((float)2.0f, (float)(j) / (float)(nsublevels_)+i);
+ aux.etime = 0.5f*(aux.esigma*aux.esigma);
aux.sigma_size = fRound(aux.esigma);
- aux.octave = i;
- aux.sublevel = j;
+ aux.octave = (float)i;
+ aux.sublevel = (float)j;
evolution_.push_back(aux);
}
}
vector<float> tau;
float ttime = 0.0;
ttime = evolution_[i].etime - evolution_[i - 1].etime;
- naux = fed_tau_by_process_time(ttime, 1, 0.25, reordering_, tau);
+ naux = fed_tau_by_process_time(ttime, 1, 0.25f, reordering_, tau);
nsteps_.push_back(naux);
tsteps_.push_back(tau);
ncycles_++;
*/
int KAZEFeatures::Create_Nonlinear_Scale_Space(const cv::Mat &img) {
- double t2 = 0.0, t1 = 0.0;
+ //double t2 = 0.0, t1 = 0.0;
if (evolution_.size() == 0) {
cout << "Error generating the nonlinear scale space!!" << endl;
return -1;
}
- t1 = getTickCount();
+ //t1 = getTickCount();
// Copy the original image to the first level of the evolution
img.copyTo(evolution_[0].Lt);
// Firstly compute the kcontrast factor
Compute_KContrast(evolution_[0].Lt, KCONTRAST_PERCENTILE);
- t2 = getTickCount();
- tkcontrast_ = 1000.0*(t2 - t1) / getTickFrequency();
+ //t2 = getTickCount();
+ //tkcontrast_ = 1000.0*(t2 - t1) / getTickFrequency();
if (verbosity_ == true) {
cout << "Computed image evolution step. Evolution time: " << evolution_[0].etime <<
}
}
- t2 = getTickCount();
- tnlscale_ = 1000.0*(t2 - t1) / getTickFrequency();
+ //t2 = getTickCount();
+ //tnlscale_ = 1000.0*(t2 - t1) / getTickFrequency();
return 0;
}
*/
void KAZEFeatures::Compute_KContrast(const cv::Mat &img, const float &kpercentile) {
- if (verbosity_ == true) {
- cout << "Computing Kcontrast factor." << endl;
- }
+ //if (verbosity_ == true) {
+ // cout << "Computing Kcontrast factor." << endl;
+ //}
- if (COMPUTE_KCONTRAST == true) {
+ if (COMPUTE_KCONTRAST) {
kcontrast_ = compute_k_percentile(img, kpercentile, sderivatives_, KCONTRAST_NBINS, 0, 0);
}
- if (verbosity_ == true) {
- cout << "kcontrast = " << kcontrast_ << endl;
- cout << endl << "Now computing the nonlinear scale space!!" << endl;
- }
+ //if (verbosity_ == true) {
+ // cout << "kcontrast = " << kcontrast_ << endl;
+ // cout << endl << "Now computing the nonlinear scale space!!" << endl;
+ //}
}
//*************************************************************************************
*/
void KAZEFeatures::Compute_Multiscale_Derivatives(void)
{
- double t2 = 0.0, t1 = 0.0;
- t1 = getTickCount();
+ //double t2 = 0.0, t1 = 0.0;
+ //t1 = getTickCount();
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (size_t i = 0; i < evolution_.size(); i++) {
- if (verbosity_ == true) {
- cout << "Computing multiscale derivatives. Evolution time: " << evolution_[i].etime
- << " Step (pixels): " << evolution_[i].sigma_size << endl;
- }
+ //if (verbosity_ == true) {
+ // cout << "Computing multiscale derivatives. Evolution time: " << evolution_[i].etime
+ // << " Step (pixels): " << evolution_[i].sigma_size << endl;
+ //}
// Compute multiscale derivatives for the detector
compute_scharr_derivatives(evolution_[i].Lsmooth, evolution_[i].Lx, 1, 0, evolution_[i].sigma_size);
evolution_[i].Lyy = evolution_[i].Lyy*((evolution_[i].sigma_size)*(evolution_[i].sigma_size));
}
- t2 = getTickCount();
- tmderivatives_ = 1000.0*(t2 - t1) / getTickFrequency();
+ //t2 = getTickCount();
+ //tmderivatives_ = 1000.0*(t2 - t1) / getTickFrequency();
}
//*************************************************************************************
*/
void KAZEFeatures::Compute_Detector_Response(void) {
- double t2 = 0.0, t1 = 0.0;
+ //double t2 = 0.0, t1 = 0.0;
float lxx = 0.0, lxy = 0.0, lyy = 0.0;
- t1 = getTickCount();
+ //t1 = getTickCount();
// Firstly compute the multiscale derivatives
Compute_Multiscale_Derivatives();
for (size_t i = 0; i < evolution_.size(); i++) {
// Determinant of the Hessian
- if (verbosity_ == true) {
- cout << "Computing detector response. Determinant of Hessian. Evolution time: " << evolution_[i].etime << endl;
- }
+ //if (verbosity_ == true) {
+ // cout << "Computing detector response. Determinant of Hessian. Evolution time: " << evolution_[i].etime << endl;
+ //}
for (int ix = 0; ix < img_height_; ix++) {
for (int jx = 0; jx < img_width_; jx++) {
}
}
- t2 = getTickCount();
- tdresponse_ = 1000.0*(t2 - t1) / getTickFrequency();
+ //t2 = getTickCount();
+ //tdresponse_ = 1000.0*(t2 - t1) / getTickFrequency();
}
//*************************************************************************************
*/
void KAZEFeatures::Feature_Detection(std::vector<cv::KeyPoint>& kpts) {
- double t2 = 0.0, t1 = 0.0;
- t1 = getTickCount();
+ //double t2 = 0.0, t1 = 0.0;
+ //t1 = getTickCount();
kpts.clear();
// Perform some subpixel refinement
Do_Subpixel_Refinement(kpts);
- t2 = getTickCount();
- tdetector_ = 1000.0*(t2 - t1) / getTickFrequency();
+ //t2 = getTickCount();
+ //tdetector_ = 1000.0*(t2 - t1) / getTickFrequency();
}
//*************************************************************************************
// Add the point of interest!!
if (is_extremum == true) {
KeyPoint point;
- point.pt.x = jx;
- point.pt.y = ix;
+ point.pt.x = (float)jx;
+ point.pt.y = (float)ix;
point.response = fabs(value);
point.size = evolution_[level].esigma;
- point.octave = evolution_[level].octave;
+ point.octave = (int)evolution_[level].octave;
point.class_id = level;
// We use the angle field for the sublevel value
Mat A = Mat::zeros(3, 3, CV_32F);
Mat b = Mat::zeros(3, 1, CV_32F);
Mat dst = Mat::zeros(3, 1, CV_32F);
- double t2 = 0.0, t1 = 0.0;
+ //double t2 = 0.0, t1 = 0.0;
- t1 = cv::getTickCount();
+ //t1 = cv::getTickCount();
vector<KeyPoint> kpts_(kpts);
for (size_t i = 0; i < kpts_.size(); i++) {
- x = kpts_[i].pt.x;
- y = kpts_[i].pt.y;
+ x = static_cast<int>(kpts_[i].pt.x);
+ y = static_cast<int>(kpts_[i].pt.y);
// Compute the gradient
- Dx = (1.0 / (2.0*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x + step)
+ Dx = (1.0f / (2.0f*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x + step)
- *(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x - step));
- Dy = (1.0 / (2.0*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y + step) + x)
+ Dy = (1.0f / (2.0f*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y + step) + x)
- *(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y - step) + x));
- Ds = 0.5*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y)+x)
+ Ds = 0.5f*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y)+x)
- *(evolution_[kpts_[i].class_id - 1].Ldet.ptr<float>(y)+x));
// Compute the Hessian
- Dxx = (1.0 / (step*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x + step)
+ Dxx = (1.0f / (step*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x + step)
+ *(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x - step)
- - 2.0*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x)));
+ - 2.0f*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x)));
- Dyy = (1.0 / (step*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y + step) + x)
+ Dyy = (1.0f / (step*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y + step) + x)
+ *(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y - step) + x)
- - 2.0*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x)));
+ - 2.0f*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x)));
Dss = *(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y)+x)
+ *(evolution_[kpts_[i].class_id - 1].Ldet.ptr<float>(y)+x)
- - 2.0*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x));
+ - 2.0f*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y)+x));
- Dxy = (1.0 / (4.0*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y + step) + x + step)
+ Dxy = (1.0f / (4.0f*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y + step) + x + step)
+ (*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y - step) + x - step)))
- - (1.0 / (4.0*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y - step) + x + step)
+ - (1.0f / (4.0f*step))*(*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y - step) + x + step)
+ (*(evolution_[kpts_[i].class_id].Ldet.ptr<float>(y + step) + x - step)));
- Dxs = (1.0 / (4.0*step))*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y)+x + step)
+ Dxs = (1.0f / (4.0f*step))*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y)+x + step)
+ (*(evolution_[kpts_[i].class_id - 1].Ldet.ptr<float>(y)+x - step)))
- - (1.0 / (4.0*step))*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y)+x - step)
+ - (1.0f / (4.0f*step))*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y)+x - step)
+ (*(evolution_[kpts_[i].class_id - 1].Ldet.ptr<float>(y)+x + step)));
- Dys = (1.0 / (4.0*step))*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y + step) + x)
+ Dys = (1.0f / (4.0f*step))*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y + step) + x)
+ (*(evolution_[kpts_[i].class_id - 1].Ldet.ptr<float>(y - step) + x)))
- - (1.0 / (4.0*step))*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y - step) + x)
+ - (1.0f / (4.0f*step))*(*(evolution_[kpts_[i].class_id + 1].Ldet.ptr<float>(y - step) + x)
+ (*(evolution_[kpts_[i].class_id - 1].Ldet.ptr<float>(y + step) + x)));
// Solve the linear system
solve(A, b, dst, DECOMP_LU);
- if (fabs(*(dst.ptr<float>(0))) <= 1.0 && fabs(*(dst.ptr<float>(1))) <= 1.0 && fabs(*(dst.ptr<float>(2))) <= 1.0) {
+ if (fabs(*(dst.ptr<float>(0))) <= 1.0f && fabs(*(dst.ptr<float>(1))) <= 1.0f && fabs(*(dst.ptr<float>(2))) <= 1.0f) {
kpts_[i].pt.x += *(dst.ptr<float>(0));
kpts_[i].pt.y += *(dst.ptr<float>(1));
dsc = kpts_[i].octave + (kpts_[i].angle + *(dst.ptr<float>(2))) / ((float)(nsublevels_));
// In OpenCV the size of a keypoint is the diameter!!
- kpts_[i].size = 2.0*soffset_*pow((float)2.0, dsc);
+ kpts_[i].size = 2.0f*soffset_*pow((float)2.0f, dsc);
kpts_[i].angle = 0.0;
}
// Set the points to be deleted after the for loop
}
}
- t2 = getTickCount();
- tsubpixel_ = 1000.0*(t2 - t1) / getTickFrequency();
+ //t2 = getTickCount();
+ //tsubpixel_ = 1000.0*(t2 - t1) / getTickFrequency();
}
//*************************************************************************************
*/
void KAZEFeatures::Feature_Description(std::vector<cv::KeyPoint> &kpts, cv::Mat &desc) {
- double t2 = 0.0, t1 = 0.0;
- t1 = getTickCount();
+ //double t2 = 0.0, t1 = 0.0;
+ //t1 = getTickCount();
// Allocate memory for the matrix of descriptors
if (use_extended_ == true) {
}
}
- t2 = getTickCount();
- tdescriptor_ = 1000.0*(t2 - t1) / getTickFrequency();
+ //t2 = getTickCount();
+ //tdescriptor_ = 1000.0*(t2 - t1) / getTickFrequency();
}
//*************************************************************************************
xf = kpt.pt.x;
yf = kpt.pt.y;
level = kpt.class_id;
- s = fRound(kpt.size / 2.0);
+ s = fRound(kpt.size / 2.0f);
// Calculate derivatives responses for points within radius of 6*scale
for (int i = -6; i <= 6; ++i) {
ix = fRound(xf + i*s);
if (iy >= 0 && iy < img_height_ && ix >= 0 && ix < img_width_) {
- gweight = gaussian(iy - yf, ix - xf, 2.5*s);
+ gweight = gaussian(iy - yf, ix - xf, 2.5f*s);
resX[idx] = gweight*(*(evolution_[level].Lx.ptr<float>(iy)+ix));
resY[idx] = gweight*(*(evolution_[level].Ly.ptr<float>(iy)+ix));
}
}
// Loop slides pi/3 window around feature point
- for (ang1 = 0; ang1 < 2.0*CV_PI; ang1 += 0.15f) {
- ang2 = (ang1 + CV_PI / 3.0f > 2.0*CV_PI ? ang1 - 5.0f*CV_PI / 3.0f : ang1 + CV_PI / 3.0f);
+ for (ang1 = 0; ang1 < 2.0f*CV_PI; ang1 += 0.15f) {
+ ang2 = (ang1 + (float)(CV_PI / 3.0) > (float)(2.0*CV_PI) ? ang1 - (float)(5.0*CV_PI / 3.0) : ang1 + (float)(CV_PI / 3.0));
sumX = sumY = 0.f;
for (size_t k = 0; k < Ang.size(); ++k) {
sumY += resY[k];
}
else if (ang2 < ang1 &&
- ((ang > 0 && ang < ang2) || (ang > ang1 && ang < 2.0*CV_PI))) {
+ ((ang > 0 && ang < ang2) || (ang > ang1 && ang < (float)(2.0*CV_PI)))) {
sumX += resX[k];
sumY += resY[k];
}
yf = kpt.pt.y;
xf = kpt.pt.x;
level = kpt.class_id;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
// Calculate descriptor for this interest point
for (int i = -pattern_size; i < pattern_size; i += sample_step) {
sample_y = k*scale + yf;
sample_x = l*scale + xf;
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - .5f);
+ x1 = (int)(sample_x - .5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + .5f);
+ x2 = (int)(sample_x + .5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Sum the derivatives to the cumulative descriptor
dx += rx;
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
angle = kpt.angle;
level = kpt.class_id;
co = cos(angle);
sample_y = yf + (l*scale*co + k*scale*si);
sample_x = xf + (-l*scale*si + k*scale*co);
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - .5f);
+ x1 = (int)(sample_x - .5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + .5f);
+ x2 = (int)(sample_x + .5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Get the x and y derivatives on the rotated axis
rry = rx*co + ry*si;
int dsize = 0, scale = 0, level = 0;
// Subregion centers for the 4x4 gaussian weighting
- float cx = -0.5, cy = 0.5;
+ float cx = -0.5f, cy = 0.5f;
// Set the descriptor size and the sample and pattern sizes
dsize = 64;
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
level = kpt.class_id;
i = -8;
j = -8;
i = i - 4;
- cx += 1.0;
- cy = -0.5;
+ cx += 1.0f;
+ cy = -0.5f;
while (j < pattern_size) {
dx = dy = mdx = mdy = 0.0;
- cy += 1.0;
+ cy += 1.0f;
j = j - 4;
ky = i + sample_step;
sample_x = l*scale + xf;
//Get the gaussian weighted x and y responses
- gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5*scale);
+ gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5f*scale);
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
rx = gauss_s1*rx;
ry = gauss_s1*ry;
int dsize = 0, scale = 0, level = 0;
// Subregion centers for the 4x4 gaussian weighting
- float cx = -0.5, cy = 0.5;
+ float cx = -0.5f, cy = 0.5f;
// Set the descriptor size and the sample and pattern sizes
dsize = 64;
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
angle = kpt.angle;
level = kpt.class_id;
co = cos(angle);
j = -8;
i = i - 4;
- cx += 1.0;
- cy = -0.5;
+ cx += 1.0f;
+ cy = -0.5f;
while (j < pattern_size) {
dx = dy = mdx = mdy = 0.0;
- cy += 1.0;
+ cy += 1.0f;
j = j - 4;
ky = i + sample_step;
sample_x = xf + (-l*scale*si + k*scale*co);
// Get the gaussian weighted x and y responses
- gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5*scale);
- y1 = fRound(sample_y - .5);
- x1 = fRound(sample_x - .5);
+ gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5f*scale);
+ y1 = fRound(sample_y - 0.5f);
+ x1 = fRound(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Get the x and y derivatives on the rotated axis
rry = gauss_s1*(rx*co + ry*si);
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
level = kpt.class_id;
// Calculate descriptor for this interest point
sample_y = yf + l*scale;
sample_x = xf + k*scale;
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
modg = pow(rx, 2) + pow(ry, 2);
res2 = *(evolution_[level].Lxx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lxx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lxx.ptr<float>(y2)+x2);
- rxx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rxx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Lxy.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Lxy.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lxy.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lxy.ptr<float>(y2)+x2);
- rxy = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rxy = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Lyy.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Lyy.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lyy.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lyy.ptr<float>(y2)+x2);
- ryy = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ryy = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Lww = (Lx^2 * Lxx + 2*Lx*Lxy*Ly + Ly^2*Lyy) / (Lx^2 + Ly^2)
- lww = (pow(rx, 2)*rxx + 2.0*rx*rxy*ry + pow(ry, 2)*ryy) / (modg);
+ lww = (pow(rx, 2)*rxx + 2.0f*rx*rxy*ry + pow(ry, 2)*ryy) / (modg);
// Lvv = (-2*Lx*Lxy*Ly + Lxx*Ly^2 + Lx^2*Lyy) / (Lx^2 + Ly^2)
- lvv = (-2.0*rx*rxy*ry + rxx*pow(ry, 2) + pow(rx, 2)*ryy) / (modg);
+ lvv = (-2.0f*rx*rxy*ry + rxx*pow(ry, 2) + pow(rx, 2)*ryy) / (modg);
}
else {
lww = 0.0;
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
angle = kpt.angle;
level = kpt.class_id;
co = cos(angle);
sample_y = yf + (l*scale*co + k*scale*si);
sample_x = xf + (-l*scale*si + k*scale*co);
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
modg = pow(rx, 2) + pow(ry, 2);
res2 = *(evolution_[level].Lxx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lxx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lxx.ptr<float>(y2)+x2);
- rxx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rxx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Lxy.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Lxy.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lxy.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lxy.ptr<float>(y2)+x2);
- rxy = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rxy = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Lyy.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Lyy.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lyy.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lyy.ptr<float>(y2)+x2);
- ryy = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ryy = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Lww = (Lx^2 * Lxx + 2*Lx*Lxy*Ly + Ly^2*Lyy) / (Lx^2 + Ly^2)
- lww = (pow(rx, 2)*rxx + 2.0*rx*rxy*ry + pow(ry, 2)*ryy) / (modg);
+ lww = (pow(rx, 2)*rxx + 2.0f*rx*rxy*ry + pow(ry, 2)*ryy) / (modg);
// Lvv = (-2*Lx*Lxy*Ly + Lxx*Ly^2 + Lx^2*Lyy) / (Lx^2 + Ly^2)
- lvv = (-2.0*rx*rxy*ry + rxx*pow(ry, 2) + pow(rx, 2)*ryy) / (modg);
+ lvv = (-2.0f*rx*rxy*ry + rxx*pow(ry, 2) + pow(rx, 2)*ryy) / (modg);
}
else {
lww = 0.0;
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
level = kpt.class_id;
// Calculate descriptor for this interest point
sample_y = k*scale + yf;
sample_x = l*scale + xf;
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Sum the derivatives to the cumulative descriptor
if (ry >= 0.0) {
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
angle = kpt.angle;
level = kpt.class_id;
co = cos(angle);
sample_y = yf + (l*scale*co + k*scale*si);
sample_x = xf + (-l*scale*si + k*scale*co);
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Get the x and y derivatives on the rotated axis
rry = rx*co + ry*si;
int dsize = 0, scale = 0, level = 0;
// Subregion centers for the 4x4 gaussian weighting
- float cx = -0.5, cy = 0.5;
+ float cx = -0.5f, cy = 0.5f;
// Set the descriptor size and the sample and pattern sizes
dsize = 128;
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
level = kpt.class_id;
i = -8;
j = -8;
i = i - 4;
- cx += 1.0;
- cy = -0.5;
+ cx += 1.0f;
+ cy = -0.5f;
while (j < pattern_size) {
dxp = dxn = mdxp = mdxn = 0.0;
dyp = dyn = mdyp = mdyn = 0.0;
- cy += 1.0;
+ cy += 1.0f;
j = j - 4;
ky = i + sample_step;
sample_x = l*scale + xf;
//Get the gaussian weighted x and y responses
- gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.50*scale);
+ gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5f*scale);
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
rx = gauss_s1*rx;
ry = gauss_s1*ry;
int dsize = 0, scale = 0, level = 0;
// Subregion centers for the 4x4 gaussian weighting
- float cx = -0.5, cy = 0.5;
+ float cx = -0.5f, cy = 0.5f;
// Set the descriptor size and the sample and pattern sizes
dsize = 128;
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
angle = kpt.angle;
level = kpt.class_id;
co = cos(angle);
j = -8;
i = i - 4;
- cx += 1.0;
- cy = -0.5;
+ cx += 1.0f;
+ cy = -0.5f;
while (j < pattern_size) {
sample_x = xf + (-l*scale*si + k*scale*co);
// Get the gaussian weighted x and y responses
- gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5*scale);
+ gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5f*scale);
- y1 = fRound(sample_y - .5);
- x1 = fRound(sample_x - .5);
+ y1 = fRound(sample_y - 0.5f);
+ x1 = fRound(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Get the x and y derivatives on the rotated axis
rry = gauss_s1*(rx*co + ry*si);
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
level = kpt.class_id;
// Calculate descriptor for this interest point
sample_y = k*scale + yf;
sample_x = l*scale + xf;
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
modg = pow(rx, 2) + pow(ry, 2);
res2 = *(evolution_[level].Lxx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lxx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lxx.ptr<float>(y2)+x2);
- rxx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rxx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Lxy.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Lxy.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lxy.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lxy.ptr<float>(y2)+x2);
- rxy = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rxy = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Lyy.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Lyy.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lyy.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lyy.ptr<float>(y2)+x2);
- ryy = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ryy = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Lww = (Lx^2 * Lxx + 2*Lx*Lxy*Ly + Ly^2*Lyy) / (Lx^2 + Ly^2)
- lww = (pow(rx, 2)*rxx + 2.0*rx*rxy*ry + pow(ry, 2)*ryy) / (modg);
+ lww = (pow(rx, 2)*rxx + 2.0f*rx*rxy*ry + pow(ry, 2)*ryy) / (modg);
// Lvv = (-2*Lx*Lxy*Ly + Lxx*Ly^2 + Lx^2*Lyy) / (Lx^2 + Ly^2)
- lvv = (-2.0*rx*rxy*ry + rxx*pow(ry, 2) + pow(rx, 2)*ryy) / (modg);
+ lvv = (-2.0f*rx*rxy*ry + rxx*pow(ry, 2) + pow(rx, 2)*ryy) / (modg);
}
else {
lww = 0.0;
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0);
+ scale = fRound(kpt.size / 2.0f);
angle = kpt.angle;
level = kpt.class_id;
co = cos(angle);
sample_y = yf + (l*scale*co + k*scale*si);
sample_x = xf + (-l*scale*si + k*scale*co);
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = (int)(sample_y - 0.5f);
+ x1 = (int)(sample_x - 0.5f);
checkDescriptorLimits(x1, y1, img_width_, img_height_);
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ y2 = (int)(sample_y + 0.5f);
+ x2 = (int)(sample_x + 0.5f);
checkDescriptorLimits(x2, y2, img_width_, img_height_);
res2 = *(evolution_[level].Lx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lx.ptr<float>(y2)+x2);
- rx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Ly.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Ly.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Ly.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Ly.ptr<float>(y2)+x2);
- ry = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
modg = pow(rx, 2) + pow(ry, 2);
res2 = *(evolution_[level].Lxx.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lxx.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lxx.ptr<float>(y2)+x2);
- rxx = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rxx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Lxy.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Lxy.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lxy.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lxy.ptr<float>(y2)+x2);
- rxy = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ rxy = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
res1 = *(evolution_[level].Lyy.ptr<float>(y1)+x1);
res2 = *(evolution_[level].Lyy.ptr<float>(y1)+x2);
res3 = *(evolution_[level].Lyy.ptr<float>(y2)+x1);
res4 = *(evolution_[level].Lyy.ptr<float>(y2)+x2);
- ryy = (1.0 - fx)*(1.0 - fy)*res1 + fx*(1.0 - fy)*res2 + (1.0 - fx)*fy*res3 + fx*fy*res4;
+ ryy = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Lww = (Lx^2 * Lxx + 2*Lx*Lxy*Ly + Ly^2*Lyy) / (Lx^2 + Ly^2)
- lww = (pow(rx, 2)*rxx + 2.0*rx*rxy*ry + pow(ry, 2)*ryy) / (modg);
+ lww = (pow(rx, 2)*rxx + 2.0f*rx*rxy*ry + pow(ry, 2)*ryy) / (modg);
// Lvv = (-2*Lx*Lxy*Ly + Lxx*Ly^2 + Lx^2*Lyy) / (Lx^2 + Ly^2)
- lvv = (-2.0*rx*rxy*ry + rxx*pow(ry, 2) + pow(rx, 2)*ryy) / (modg);
+ lvv = (-2.0f*rx*rxy*ry + rxx*pow(ry, 2) + pow(rx, 2)*ryy) / (modg);
}
else {
lww = 0.0;
AOS_Columns(Ldprev, c, stepsize);
#endif
- Ld = 0.5*(Lty_ + Ltx_.t());
+ Ld = 0.5f*(Lty_ + Ltx_.t());
}
//*************************************************************************************
// a = 1 + t.*p; (p is -1*p)
// b = -t.*q;
- ay_ = 1.0 + stepsize*py_; // p is -1*p
+ ay_ = 1.0f + stepsize*py_; // p is -1*p
by_ = -stepsize*qr_;
// Do Thomas algorithm to solve the linear system of equations
}
// a = 1 + t.*p';
- ax_ = 1.0 + stepsize*px_.t();
+ ax_ = 1.0f + stepsize*px_.t();
// b = -t.*q';
bx_ = -stepsize*qc_.t();
}
if (x < 0 && y >= 0) {
- return CV_PI - atan(-y / x);
+ return (float)CV_PI - atan(-y / x);
}
if (x < 0 && y < 0) {
- return CV_PI + atan(y / x);
+ return (float)CV_PI + atan(y / x);
}
if (x >= 0 && y < 0) {
- return 2.0*CV_PI - atan(-y / x);
+ return 2.0f * (float)CV_PI - atan(-y / x);
}
return 0;
*/
inline void clippingDescriptor(float *desc, const int& dsize, const int& niter, const float& ratio) {
- float cratio = ratio / sqrt(dsize);
+ float cratio = ratio / sqrtf(static_cast<float>(dsize));
float len = 0.0;
for (int i = 0; i < niter; i++) {