| 217 | |
| 218 | template<typename T> |
| 219 | inline T get_pixel(unsigned x, unsigned y, const float ori, const unsigned size, |
| 220 | const int dist_x, const int dist_y, CParam<T> image, |
| 221 | const unsigned patch_size) { |
| 222 | const af::dim4 idims = image.dims(); |
| 223 | const T* image_ptr = image.get(); |
| 224 | float ori_sin = sin(ori); |
| 225 | float ori_cos = cos(ori); |
| 226 | float patch_scl = (float)size / (float)patch_size; |
| 227 | |
| 228 | // Calculate point coordinates based on orientation and size |
| 229 | x += round(dist_x * patch_scl * ori_cos - dist_y * patch_scl * ori_sin); |
| 230 | y += round(dist_x * patch_scl * ori_sin + dist_y * patch_scl * ori_cos); |
| 231 | |
| 232 | return image_ptr[x * idims[0] + y]; |
| 233 | } |
| 234 | |
| 235 | template<typename T> |
| 236 | void extract_orb(unsigned* desc_out, const unsigned n_feat, float* x_in_out, |