Path: blob/master/modules/gapi/src/backends/fluid/gfluidutils.hpp
16344 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.3//4// Copyright (C) 2018 Intel Corporation567#ifndef GFLUIDUTILS_HPP8#define GFLUIDUTILS_HPP910#include <limits>11#include <type_traits>12#include <opencv2/gapi/util/compiler_hints.hpp> //UNUSED13#include <opencv2/gapi/own/saturate.hpp>1415namespace cv {16namespace gapi {17namespace fluid {1819using cv::gapi::own::saturate;20using cv::gapi::own::ceild;21using cv::gapi::own::floord;22using cv::gapi::own::roundd;23using cv::gapi::own::rintd;2425//--------------------------------26//27// Macros for mappig of data types28//29//--------------------------------3031#define UNARY_(DST, SRC, OP, ...) \32if (cv::DataType<DST>::depth == dst.meta().depth && \33cv::DataType<SRC>::depth == src.meta().depth) \34{ \35GAPI_DbgAssert(dst.length() == src.length()); \36GAPI_DbgAssert(dst.meta().chan == src.meta().chan); \37\38OP<DST, SRC>(__VA_ARGS__); \39return; \40}4142// especial unary operation: dst is always 8UC1 image43#define INRANGE_(DST, SRC, OP, ...) \44if (cv::DataType<DST>::depth == dst.meta().depth && \45cv::DataType<SRC>::depth == src.meta().depth) \46{ \47GAPI_DbgAssert(dst.length() == src.length()); \48GAPI_DbgAssert(dst.meta().chan == 1); \49\50OP<DST, SRC>(__VA_ARGS__); \51return; \52}5354#define BINARY_(DST, SRC1, SRC2, OP, ...) \55if (cv::DataType<DST>::depth == dst.meta().depth && \56cv::DataType<SRC1>::depth == src1.meta().depth && \57cv::DataType<SRC2>::depth == src2.meta().depth) \58{ \59GAPI_DbgAssert(dst.length() == src1.length()); \60GAPI_DbgAssert(dst.length() == src2.length()); \61\62GAPI_DbgAssert(dst.meta().chan == src1.meta().chan); \63GAPI_DbgAssert(dst.meta().chan == src2.meta().chan); \64\65OP<DST, SRC1, SRC2>(__VA_ARGS__); \66return; \67}6869// especial ternary operation: src3 has only one channel70#define SELECT_(DST, SRC1, SRC2, SRC3, OP, ...) \71if (cv::DataType<DST>::depth == dst.meta().depth && \72cv::DataType<SRC1>::depth == src1.meta().depth && \73cv::DataType<SRC2>::depth == src2.meta().depth && \74cv::DataType<SRC3>::depth == src3.meta().depth) \75{ \76GAPI_DbgAssert(dst.length() == src1.length()); \77GAPI_DbgAssert(dst.length() == src2.length()); \78GAPI_DbgAssert(dst.length() == src3.length()); \79\80GAPI_DbgAssert(dst.meta().chan == src1.meta().chan); \81GAPI_DbgAssert(dst.meta().chan == src2.meta().chan); \82GAPI_DbgAssert( 1 == src3.meta().chan); \83\84OP<DST, SRC1, SRC2, SRC3>(__VA_ARGS__); \85return; \86}8788} // namespace fluid89} // namespace gapi90} // namespace cv9192#endif // GFLUIDUTILS_HPP939495