MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / computeGLOHDescriptor

Function computeGLOHDescriptor

src/backend/cuda/kernel/sift.hpp:824–984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

822// III-B of Mikolajczyk and Schmid paper.
823template<typename T>
824__global__ void computeGLOHDescriptor(
825 float* desc_out, const unsigned desc_len, const unsigned histsz,
826 const float* x_in, const float* y_in, const unsigned* layer_in,
827 const float* response_in, const float* size_in, const float* ori_in,
828 const unsigned total_feat, const CParam<T> gauss_octave, const int d,
829 const unsigned rb, const unsigned ab, const unsigned hb, const float scale,
830 const int n_layers) {
831 const int tid_x = threadIdx.x;
832 const int tid_y = threadIdx.y;
833 const int bsz_x = blockDim.x;
834 const int bsz_y = blockDim.y;
835
836 const int f = blockIdx.y * bsz_y + tid_y;
837
838 SharedMemory<float> shared;
839 float* shrdMem = shared.getPointer();
840 float* desc = shrdMem;
841 float* accum = shrdMem + desc_len * histsz;
842
843 for (int i = tid_x; i < desc_len * histsz; i += bsz_x)
844 desc[tid_y * desc_len + i] = 0.f;
845 __syncthreads();
846
847 if (f < total_feat) {
848 const unsigned layer = layer_in[f];
849 float ori = (360.f - ori_in[f]) * PI_VAL / 180.f;
850 ori = (ori > PI_VAL) ? ori - PI_VAL * 2 : ori;
851 const float size = size_in[f];
852 const int fx = round(x_in[f] * scale);
853 const int fy = round(y_in[f] * scale);
854
855 const int dim0 = gauss_octave.dims[0];
856 const int dim1 = gauss_octave.dims[1];
857 const int imel = dim0 * dim1;
858
859 // Points img to correct Gaussian pyramid layer
860 const T* img_ptr = gauss_octave.ptr + layer * imel;
861
862 float cos_t = cosf(ori);
863 float sin_t = sinf(ori);
864 float hist_bins_per_rad = hb / (PI_VAL * 2.f);
865 float polar_bins_per_rad = ab / (PI_VAL * 2.f);
866 float exp_denom = GLOHRadii[rb - 1] * 0.5f;
867
868 float hist_width = DESCR_SCL_FCTR * size * scale * 0.5f;
869
870 // Keep same descriptor radius used for SIFT
871 int radius = hist_width * sqrt(2.f) * (d + 1.f) * 0.5f + 0.5f;
872
873 // Alternative radius size calculation, changing the radius weight
874 // (rw) in the range of 0.25f-0.75f gives different results,
875 // increasing it tends to show a better recall rate but with a
876 // smaller amount of correct matches
877 // float rw = 0.5f;
878 // int radius = hist_width * GLOHRadii[rb-1] * rw + 0.5f;
879
880 int len = radius * 2 + 1;
881 const int hist_off = (tid_x % histsz) * desc_len;

Callers

nothing calls this directly

Calls 9

roundFunction · 0.85
sqrtFunction · 0.85
atan2Function · 0.85
expFunction · 0.85
floorFunction · 0.85
atomicAddFunction · 0.85
normalizeGLOHDescFunction · 0.85
getPointerMethod · 0.80
minFunction · 0.50

Tested by

no test coverage detected