akaze: getAngle() -> fastAtan2()

pull/9303/head
Alexander Alekhin 7 years ago
parent 6847cc9f1c
commit f6ceeaa2e5
  1. 4
      modules/features2d/src/kaze/KAZEFeatures.cpp
  2. 25
      modules/features2d/src/kaze/utils.h

@ -606,7 +606,7 @@ void KAZEFeatures::Compute_Main_Orientation(KeyPoint &kpt, const std::vector<TEv
resY[idx] = 0.0; resY[idx] = 0.0;
} }
Ang[idx] = getAngle(resX[idx], resY[idx]); Ang[idx] = fastAtan2(resX[idx], resY[idx]) * (float)(CV_PI / 180.0f);
++idx; ++idx;
} }
} }
@ -638,7 +638,7 @@ void KAZEFeatures::Compute_Main_Orientation(KeyPoint &kpt, const std::vector<TEv
if (sumX*sumX + sumY*sumY > max) { if (sumX*sumX + sumY*sumY > max) {
// store largest orientation // store largest orientation
max = sumX*sumX + sumY*sumY; max = sumX*sumX + sumY*sumY;
kpt.angle = getAngle(sumX, sumY) * 180.f / static_cast<float>(CV_PI); kpt.angle = fastAtan2(sumX, sumY);
} }
} }
} }

@ -1,31 +1,6 @@
#ifndef __OPENCV_FEATURES_2D_KAZE_UTILS_H__ #ifndef __OPENCV_FEATURES_2D_KAZE_UTILS_H__
#define __OPENCV_FEATURES_2D_KAZE_UTILS_H__ #define __OPENCV_FEATURES_2D_KAZE_UTILS_H__
/* ************************************************************************* */
/**
* @brief This function computes the angle from the vector given by (X Y). From 0 to 2*Pi
*/
inline float getAngle(float x, float y) {
if (x >= 0 && y >= 0) {
return atanf(y / x);
}
if (x < 0 && y >= 0) {
return static_cast<float>(CV_PI)-atanf(-y / x);
}
if (x < 0 && y < 0) {
return static_cast<float>(CV_PI)+atanf(y / x);
}
if (x >= 0 && y < 0) {
return static_cast<float>(2.0 * CV_PI) - atanf(-y / x);
}
return 0;
}
/* ************************************************************************* */ /* ************************************************************************* */
/** /**
* @brief This function computes the value of a 2D Gaussian function * @brief This function computes the value of a 2D Gaussian function

Loading…
Cancel
Save