| 37 | } |
| 38 | |
| 39 | af_err af_match_template(af_array* out, const af_array search_img, |
| 40 | const af_array template_img, |
| 41 | const af_match_type m_type) { |
| 42 | try { |
| 43 | ARG_ASSERT(3, (m_type >= AF_SAD && m_type <= AF_LSSD)); |
| 44 | |
| 45 | const ArrayInfo& sInfo = getInfo(search_img); |
| 46 | const ArrayInfo& tInfo = getInfo(template_img); |
| 47 | |
| 48 | dim4 const& sDims = sInfo.dims(); |
| 49 | dim4 const& tDims = tInfo.dims(); |
| 50 | |
| 51 | dim_t sNumDims = sDims.ndims(); |
| 52 | dim_t tNumDims = tDims.ndims(); |
| 53 | ARG_ASSERT(1, (sNumDims >= 2)); |
| 54 | ARG_ASSERT(2, (tNumDims == 2)); |
| 55 | |
| 56 | af_dtype sType = sInfo.getType(); |
| 57 | ARG_ASSERT(1, (sType == tInfo.getType())); |
| 58 | |
| 59 | af_array output = 0; |
| 60 | switch (sType) { |
| 61 | case f64: |
| 62 | output = |
| 63 | match_template<double>(search_img, template_img, m_type); |
| 64 | break; |
| 65 | case f32: |
| 66 | output = |
| 67 | match_template<float>(search_img, template_img, m_type); |
| 68 | break; |
| 69 | case s32: |
| 70 | output = match_template<int>(search_img, template_img, m_type); |
| 71 | break; |
| 72 | case u32: |
| 73 | output = match_template<uint>(search_img, template_img, m_type); |
| 74 | break; |
| 75 | case s16: |
| 76 | output = |
| 77 | match_template<short>(search_img, template_img, m_type); |
| 78 | break; |
| 79 | case u16: |
| 80 | output = |
| 81 | match_template<ushort>(search_img, template_img, m_type); |
| 82 | break; |
| 83 | case b8: |
| 84 | output = match_template<char>(search_img, template_img, m_type); |
| 85 | break; |
| 86 | case s8: |
| 87 | output = |
| 88 | match_template<schar>(search_img, template_img, m_type); |
| 89 | break; |
| 90 | case u8: |
| 91 | output = |
| 92 | match_template<uchar>(search_img, template_img, m_type); |
| 93 | break; |
| 94 | default: TYPE_ERROR(1, sType); |
| 95 | } |
| 96 | std::swap(*out, output); |
no test coverage detected