| 95 | } |
| 96 | |
| 97 | af_err af_gloh(af_features* feat, af_array* desc, const af_array in, |
| 98 | const unsigned n_layers, const float contrast_thr, |
| 99 | const float edge_thr, const float init_sigma, |
| 100 | const bool double_input, const float img_scale, |
| 101 | const float feature_ratio) { |
| 102 | try { |
| 103 | const ArrayInfo& info = getInfo(in); |
| 104 | af::dim4 dims = info.dims(); |
| 105 | |
| 106 | ARG_ASSERT(2, (dims[0] >= 15 && dims[1] >= 15 && dims[2] == 1 && |
| 107 | dims[3] == 1)); |
| 108 | ARG_ASSERT(3, n_layers > 0); |
| 109 | ARG_ASSERT(4, contrast_thr > 0.0f); |
| 110 | ARG_ASSERT(5, edge_thr >= 1.0f); |
| 111 | ARG_ASSERT(6, init_sigma > 0.5f); |
| 112 | ARG_ASSERT(8, img_scale > 0.0f); |
| 113 | ARG_ASSERT(9, feature_ratio > 0.0f); |
| 114 | |
| 115 | dim_t in_ndims = dims.ndims(); |
| 116 | DIM_ASSERT(1, (in_ndims == 2)); |
| 117 | |
| 118 | af_array tmp_desc; |
| 119 | af_dtype type = info.getType(); |
| 120 | switch (type) { |
| 121 | case f32: |
| 122 | sift<float, float>(*feat, tmp_desc, in, n_layers, contrast_thr, |
| 123 | edge_thr, init_sigma, double_input, |
| 124 | img_scale, feature_ratio, true); |
| 125 | break; |
| 126 | case f64: |
| 127 | sift<double, double>( |
| 128 | *feat, tmp_desc, in, n_layers, contrast_thr, edge_thr, |
| 129 | init_sigma, double_input, img_scale, feature_ratio, true); |
| 130 | break; |
| 131 | default: TYPE_ERROR(1, type); |
| 132 | } |
| 133 | std::swap(*desc, tmp_desc); |
| 134 | } |
| 135 | CATCHALL; |
| 136 | |
| 137 | return AF_SUCCESS; |
| 138 | } |