Skip to content

Commit 8cf047a

Browse files
Merge branch '2-fix_kpt_cal' into 'main'
キーポイント角度計算の不具合修正 See merge request tech/adaskit/cuda-efficient-features!1
2 parents 7347d64 + f5190a6 commit 8cf047a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

modules/cuda_efficient_features/src/cuda_efficient_features.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,6 @@ static void createMask(GpuMat& mask, Size imgSize, int border, Stream& stream)
181181
mask(ROI).setTo(Scalar::all(255), stream);
182182
}
183183

184-
static inline float convertToDegree(float angle)
185-
{
186-
constexpr float PI = static_cast<float>(CV_PI);
187-
if (angle < 0)
188-
angle += 2.f * PI;
189-
return (180.f / PI) * angle;
190-
}
191-
192184
class EfficientFeaturesImpl : public EfficientFeatures
193185
{
194186
public:
@@ -349,7 +341,7 @@ class EfficientFeaturesImpl : public EfficientFeatures
349341
KeyPoint kpt;
350342
kpt.pt = Point2f(points[i][0], points[i][1]);
351343
kpt.response = responses[i];
352-
kpt.angle = convertToDegree(angles[i]);
344+
kpt.angle = angles[i];
353345
kpt.octave = octaves[i];
354346
kpt.size = sizes[i];
355347
dst[i] = kpt;

modules/cuda_efficient_features/src/cuda_efficient_features.cu

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ static __device__ inline int distanceSq(short2 pt1, short2 pt2)
5151
return dx * dx + dy * dy;
5252
}
5353

54+
static __device__ inline float convertToDegree(float angle)
55+
{
56+
constexpr float PI = static_cast<float>(CV_PI);
57+
if (angle < 0)
58+
angle += 2.f * PI;
59+
return (180.f / PI) * angle;
60+
}
61+
5462
static __device__ inline bool IsMaxPoint(int idx1, const short2* points, const float* responses,
5563
const int* blockPtr, const int* pointIds, int gridW, int gridH, int imageRadius, int blockRadius)
5664
{
@@ -160,7 +168,7 @@ static __device__ float IC_Angle(PtrStepb image, short2 pt)
160168
m_01 += dy * y_sum;
161169
}
162170

163-
return ::atan2f((float)m_01, (float)m_10);
171+
return convertToDegree(::atan2f((float)m_01, (float)m_10));
164172
}
165173

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

0 commit comments

Comments
 (0)