Skip to content

Commit

Permalink
Merge branch '2-fix_kpt_cal' into 'main'
Browse files Browse the repository at this point in the history
キーポイント角度計算の不具合修正

See merge request tech/adaskit/cuda-efficient-features!1
  • Loading branch information
atakagi-fixstars committed Jan 22, 2024
2 parents 7347d64 + f5190a6 commit 8cf047a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 1 addition & 9 deletions modules/cuda_efficient_features/src/cuda_efficient_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,6 @@ static void createMask(GpuMat& mask, Size imgSize, int border, Stream& stream)
mask(ROI).setTo(Scalar::all(255), stream);
}

static inline float convertToDegree(float angle)
{
constexpr float PI = static_cast<float>(CV_PI);
if (angle < 0)
angle += 2.f * PI;
return (180.f / PI) * angle;
}

class EfficientFeaturesImpl : public EfficientFeatures
{
public:
Expand Down Expand Up @@ -349,7 +341,7 @@ class EfficientFeaturesImpl : public EfficientFeatures
KeyPoint kpt;
kpt.pt = Point2f(points[i][0], points[i][1]);
kpt.response = responses[i];
kpt.angle = convertToDegree(angles[i]);
kpt.angle = angles[i];
kpt.octave = octaves[i];
kpt.size = sizes[i];
dst[i] = kpt;
Expand Down
10 changes: 9 additions & 1 deletion modules/cuda_efficient_features/src/cuda_efficient_features.cu
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ static __device__ inline int distanceSq(short2 pt1, short2 pt2)
return dx * dx + dy * dy;
}

static __device__ inline float convertToDegree(float angle)
{
constexpr float PI = static_cast<float>(CV_PI);
if (angle < 0)
angle += 2.f * PI;
return (180.f / PI) * angle;
}

static __device__ inline bool IsMaxPoint(int idx1, const short2* points, const float* responses,
const int* blockPtr, const int* pointIds, int gridW, int gridH, int imageRadius, int blockRadius)
{
Expand Down Expand Up @@ -160,7 +168,7 @@ static __device__ float IC_Angle(PtrStepb image, short2 pt)
m_01 += dy * y_sum;
}

return ::atan2f((float)m_01, (float)m_10);
return convertToDegree(::atan2f((float)m_01, (float)m_10));
}

__global__ void nptPerBlockKernel(const short2* points, int npoints, int* nptPerBlock, int gridStep)
Expand Down

0 comments on commit 8cf047a

Please sign in to comment.