forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatch_template.cpp
More file actions
57 lines (46 loc) · 1.79 KB
/
match_template.cpp
File metadata and controls
57 lines (46 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <match_template.hpp>
#include <kernel/match_template.hpp>
#include <platform.hpp>
#include <queue.hpp>
#include <af/dim4.hpp>
#include <functional>
using af::dim4;
namespace cpu {
template<typename To, typename Ti>
using matchFunc = std::function<void(Param<To>, CParam<Ti>, CParam<Ti>)>;
template<typename inType, typename outType>
Array<outType> match_template(const Array<inType> &sImg,
const Array<inType> &tImg,
const af::matchType mType) {
static const matchFunc<outType, inType> funcs[6] = {
kernel::matchTemplate<outType, inType, AF_SAD>,
kernel::matchTemplate<outType, inType, AF_ZSAD>,
kernel::matchTemplate<outType, inType, AF_LSAD>,
kernel::matchTemplate<outType, inType, AF_SSD>,
kernel::matchTemplate<outType, inType, AF_ZSSD>,
kernel::matchTemplate<outType, inType, AF_LSSD>,
};
Array<outType> out = createEmptyArray<outType>(sImg.dims());
getQueue().enqueue(funcs[static_cast<int>(mType)], out, sImg, tImg);
return out;
}
#define INSTANTIATE(in_t, out_t) \
template Array<out_t> match_template<in_t, out_t>( \
const Array<in_t> &, const Array<in_t> &, const af::matchType);
INSTANTIATE(double, double)
INSTANTIATE(float, float)
INSTANTIATE(char, float)
INSTANTIATE(int, float)
INSTANTIATE(uint, float)
INSTANTIATE(uchar, float)
INSTANTIATE(short, float)
INSTANTIATE(ushort, float)
} // namespace cpu