Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/gapi/src/backends/fluid/gfluidutils.hpp
16344 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
//
5
// Copyright (C) 2018 Intel Corporation
6
7
8
#ifndef GFLUIDUTILS_HPP
9
#define GFLUIDUTILS_HPP
10
11
#include <limits>
12
#include <type_traits>
13
#include <opencv2/gapi/util/compiler_hints.hpp> //UNUSED
14
#include <opencv2/gapi/own/saturate.hpp>
15
16
namespace cv {
17
namespace gapi {
18
namespace fluid {
19
20
using cv::gapi::own::saturate;
21
using cv::gapi::own::ceild;
22
using cv::gapi::own::floord;
23
using cv::gapi::own::roundd;
24
using cv::gapi::own::rintd;
25
26
//--------------------------------
27
//
28
// Macros for mappig of data types
29
//
30
//--------------------------------
31
32
#define UNARY_(DST, SRC, OP, ...) \
33
if (cv::DataType<DST>::depth == dst.meta().depth && \
34
cv::DataType<SRC>::depth == src.meta().depth) \
35
{ \
36
GAPI_DbgAssert(dst.length() == src.length()); \
37
GAPI_DbgAssert(dst.meta().chan == src.meta().chan); \
38
\
39
OP<DST, SRC>(__VA_ARGS__); \
40
return; \
41
}
42
43
// especial unary operation: dst is always 8UC1 image
44
#define INRANGE_(DST, SRC, OP, ...) \
45
if (cv::DataType<DST>::depth == dst.meta().depth && \
46
cv::DataType<SRC>::depth == src.meta().depth) \
47
{ \
48
GAPI_DbgAssert(dst.length() == src.length()); \
49
GAPI_DbgAssert(dst.meta().chan == 1); \
50
\
51
OP<DST, SRC>(__VA_ARGS__); \
52
return; \
53
}
54
55
#define BINARY_(DST, SRC1, SRC2, OP, ...) \
56
if (cv::DataType<DST>::depth == dst.meta().depth && \
57
cv::DataType<SRC1>::depth == src1.meta().depth && \
58
cv::DataType<SRC2>::depth == src2.meta().depth) \
59
{ \
60
GAPI_DbgAssert(dst.length() == src1.length()); \
61
GAPI_DbgAssert(dst.length() == src2.length()); \
62
\
63
GAPI_DbgAssert(dst.meta().chan == src1.meta().chan); \
64
GAPI_DbgAssert(dst.meta().chan == src2.meta().chan); \
65
\
66
OP<DST, SRC1, SRC2>(__VA_ARGS__); \
67
return; \
68
}
69
70
// especial ternary operation: src3 has only one channel
71
#define SELECT_(DST, SRC1, SRC2, SRC3, OP, ...) \
72
if (cv::DataType<DST>::depth == dst.meta().depth && \
73
cv::DataType<SRC1>::depth == src1.meta().depth && \
74
cv::DataType<SRC2>::depth == src2.meta().depth && \
75
cv::DataType<SRC3>::depth == src3.meta().depth) \
76
{ \
77
GAPI_DbgAssert(dst.length() == src1.length()); \
78
GAPI_DbgAssert(dst.length() == src2.length()); \
79
GAPI_DbgAssert(dst.length() == src3.length()); \
80
\
81
GAPI_DbgAssert(dst.meta().chan == src1.meta().chan); \
82
GAPI_DbgAssert(dst.meta().chan == src2.meta().chan); \
83
GAPI_DbgAssert( 1 == src3.meta().chan); \
84
\
85
OP<DST, SRC1, SRC2, SRC3>(__VA_ARGS__); \
86
return; \
87
}
88
89
} // namespace fluid
90
} // namespace gapi
91
} // namespace cv
92
93
#endif // GFLUIDUTILS_HPP
94
95