| 60 | |
| 61 | template<typename T> |
| 62 | void locate_features(CParam<T> in, Param<float> score, Param<float> x_out, |
| 63 | Param<float> y_out, Param<float> score_out, |
| 64 | unsigned *count, float const thr, |
| 65 | unsigned const arc_length, unsigned const nonmax, |
| 66 | unsigned const max_feat, unsigned const edge) { |
| 67 | af::dim4 in_dims = in.dims(); |
| 68 | T const *in_ptr = in.get(); |
| 69 | |
| 70 | for (int y = edge; y < (int)(in_dims[0] - edge); y++) { |
| 71 | for (int x = edge; x < (int)(in_dims[1] - edge); x++) { |
| 72 | float p = in_ptr[idx(y, x, in_dims[0])]; |
| 73 | |
| 74 | // Start by testing opposite pixels of the circle that will result |
| 75 | // in a non-kepoint |
| 76 | int d; |
| 77 | d = test_pixel<T>(in_ptr, p, thr, y - 3, x, in_dims[0]) | |
| 78 | test_pixel<T>(in_ptr, p, thr, y + 3, x, in_dims[0]); |
| 79 | if (d == 0) continue; |
| 80 | |
| 81 | d &= test_pixel<T>(in_ptr, p, thr, y - 2, x + 2, in_dims[0]) | |
| 82 | test_pixel<T>(in_ptr, p, thr, y + 2, x - 2, in_dims[0]); |
| 83 | d &= test_pixel<T>(in_ptr, p, thr, y, x + 3, in_dims[0]) | |
| 84 | test_pixel<T>(in_ptr, p, thr, y, x - 3, in_dims[0]); |
| 85 | d &= test_pixel<T>(in_ptr, p, thr, y + 2, x + 2, in_dims[0]) | |
| 86 | test_pixel<T>(in_ptr, p, thr, y - 2, x - 2, in_dims[0]); |
| 87 | if (d == 0) continue; |
| 88 | |
| 89 | d &= test_pixel<T>(in_ptr, p, thr, y - 3, x + 1, in_dims[0]) | |
| 90 | test_pixel<T>(in_ptr, p, thr, y + 3, x - 1, in_dims[0]); |
| 91 | d &= test_pixel<T>(in_ptr, p, thr, y - 1, x + 3, in_dims[0]) | |
| 92 | test_pixel<T>(in_ptr, p, thr, y + 1, x - 3, in_dims[0]); |
| 93 | d &= test_pixel<T>(in_ptr, p, thr, y + 1, x + 3, in_dims[0]) | |
| 94 | test_pixel<T>(in_ptr, p, thr, y - 1, x - 3, in_dims[0]); |
| 95 | d &= test_pixel<T>(in_ptr, p, thr, y + 3, x + 1, in_dims[0]) | |
| 96 | test_pixel<T>(in_ptr, p, thr, y - 3, x - 1, in_dims[0]); |
| 97 | if (d == 0) continue; |
| 98 | |
| 99 | int sum = 0; |
| 100 | |
| 101 | // Sum responses [-1, 0 or 1] of first arc_length pixels |
| 102 | for (int i = 0; i < static_cast<int>(arc_length); i++) |
| 103 | sum += test_pixel<T>(in_ptr, p, thr, y + idx_y(i), x + idx_x(i), |
| 104 | in_dims[0]); |
| 105 | |
| 106 | // Test maximum and mininmum responses of first segment of |
| 107 | // arc_length pixels |
| 108 | int max_sum = 0, min_sum = 0; |
| 109 | max_sum = std::max(max_sum, sum); |
| 110 | min_sum = std::min(min_sum, sum); |
| 111 | |
| 112 | // Sum responses and test the remaining 16-arc_length pixels of the |
| 113 | // circle |
| 114 | for (int i = arc_length; i < 16; i++) { |
| 115 | sum -= test_pixel<T>(in_ptr, p, thr, y + idx_y(i - arc_length), |
| 116 | x + idx_x(i - arc_length), in_dims[0]); |
| 117 | sum += test_pixel<T>(in_ptr, p, thr, y + idx_y(i), x + idx_x(i), |
| 118 | in_dims[0]); |
| 119 | max_sum = std::max(max_sum, sum); |
nothing calls this directly
no test coverage detected