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

Function af_harris

src/api/c/harris.cpp:52–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52af_err af_harris(af_features *out, const af_array in,
53 const unsigned max_corners, const float min_response,
54 const float sigma, const unsigned block_size,
55 const float k_thr) {
56 try {
57 const ArrayInfo &info = getInfo(in);
58 dim4 dims = info.dims();
59 dim_t in_ndims = dims.ndims();
60
61 unsigned filter_len = (block_size == 0)
62 ? static_cast<unsigned>(floor(6.f * sigma))
63 : block_size;
64 if (block_size == 0 && filter_len % 2 == 0) { filter_len--; }
65
66 const unsigned edge =
67 (block_size > 0) ? block_size / 2 : filter_len / 2;
68
69 DIM_ASSERT(1, (in_ndims == 2));
70 ARG_ASSERT(1, (dims[0] >= (dim_t)(2 * edge + 1) ||
71 dims[1] >= (dim_t)(2 * edge + 1)));
72 ARG_ASSERT(3, (max_corners > 0) || (min_response > 0.0f));
73 ARG_ASSERT(7, (k_thr >= 0.01f));
74 // Upper limits for sigma and block_size are due to convolve2 template
75 // at maximum length of 31 elements for the filter in OpenCL
76 ARG_ASSERT(4, (block_size > 2) || (sigma >= 0.5f && sigma <= 5.f));
77 ARG_ASSERT(5, (block_size <= 32));
78
79 af_dtype type = info.getType();
80 switch (type) {
81 case f64:
82 *out = harris<double, double>(in, max_corners, min_response,
83 sigma, filter_len, k_thr);
84 break;
85 case f32:
86 *out = harris<float, float>(in, max_corners, min_response,
87 sigma, filter_len, k_thr);
88 break;
89 default: TYPE_ERROR(1, type);
90 }
91 }
92 CATCHALL;
93
94 return AF_SUCCESS;
95}

Callers 2

harrisTestFunction · 0.50
harrisFunction · 0.50

Calls 4

floorFunction · 0.85
dimsMethod · 0.45
ndimsMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected