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

Function locate_features_core

src/backend/cuda/kernel/fast.hpp:110–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109template<typename T, int arc_length>
110__device__ void locate_features_core(T *local_image, float *score,
111 const unsigned idim0, const unsigned idim1,
112 const float thr, int x, int y,
113 const unsigned edge,
114 cudaTextureObject_t luTable) {
115 if (x >= idim0 - edge || y >= idim1 - edge) return;
116
117 score[y * idim0 + x] = 0.f;
118
119 float p = local_image[idx(0, 0)];
120
121 // Start by testing opposite pixels of the circle that will result in
122 // a non-kepoint
123 int d = test_pixel<T>(local_image, p, thr, -3, 0) |
124 test_pixel<T>(local_image, p, thr, 3, 0);
125 if (d == 0) return;
126
127 d &= test_pixel<T>(local_image, p, thr, -2, 2) |
128 test_pixel<T>(local_image, p, thr, 2, -2);
129 d &= test_pixel<T>(local_image, p, thr, 0, 3) |
130 test_pixel<T>(local_image, p, thr, 0, -3);
131 d &= test_pixel<T>(local_image, p, thr, 2, 2) |
132 test_pixel<T>(local_image, p, thr, -2, -2);
133 if (d == 0) return;
134
135 d &= test_pixel<T>(local_image, p, thr, -3, 1) |
136 test_pixel<T>(local_image, p, thr, 3, -1);
137 d &= test_pixel<T>(local_image, p, thr, -1, 3) |
138 test_pixel<T>(local_image, p, thr, 1, -3);
139 d &= test_pixel<T>(local_image, p, thr, 1, 3) |
140 test_pixel<T>(local_image, p, thr, -1, -3);
141 d &= test_pixel<T>(local_image, p, thr, 3, 1) |
142 test_pixel<T>(local_image, p, thr, -3, -1);
143 if (d == 0) return;
144
145 int bright = 0, dark = 0;
146 float s_bright = 0, s_dark = 0;
147
148// Force less loop unrolls to control maximum number of registers and
149// launch more blocks
150#pragma unroll 4
151 for (int i = 0; i < 16; i++) {
152 // Get pixel from the circle
153 float p_x = local_image[idx(idx_x(i), idx_y(i))];
154
155 // Compute binary vectors with responses for each pixel on circle
156 bright |= test_greater(p_x, p, thr) << i;
157 dark |= test_smaller(p_x, p, thr) << i;
158
159 // Compute scores for brighter and darker pixels
160 float weight = abs_diff(p_x, p) - thr;
161 s_bright += test_greater(p_x, p, thr) * weight;
162 s_dark += test_smaller(p_x, p, thr) * weight;
163 }
164
165 // Checks LUT to verify if there is a segment for which all pixels are much
166 // brighter or much darker than central pixel p.
167 if (lookup(bright, luTable) >= arc_length ||

Callers

nothing calls this directly

Calls 8

idxFunction · 0.70
idx_xFunction · 0.70
idx_yFunction · 0.70
test_greaterFunction · 0.70
test_smallerFunction · 0.70
abs_diffFunction · 0.70
lookupFunction · 0.70
max_valFunction · 0.70

Tested by

no test coverage detected