Updated fluid to 4.3.0 (#1422)
This commit is contained in:
parent
6fcad95c71
commit
d6c412ca40
@ -1 +1 @@
|
||||
570fed327bed540cdd50d60f1a3eee93
|
||||
72f63b276e710e3c626e0ab3c072fdfd
|
||||
|
@ -44,6 +44,7 @@ set(gapi_srcs
|
||||
src/api/gorigin.cpp
|
||||
src/api/gmat.cpp
|
||||
src/api/garray.cpp
|
||||
src/api/gopaque.cpp
|
||||
src/api/gscalar.cpp
|
||||
src/api/gkernel.cpp
|
||||
src/api/gbackend.cpp
|
||||
@ -147,17 +148,21 @@ if(TARGET opencv_test_gapi)
|
||||
endif()
|
||||
|
||||
if(HAVE_FREETYPE)
|
||||
ocv_target_compile_definitions(opencv_gapi PRIVATE -DHAVE_FREETYPE)
|
||||
ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_FREETYPE)
|
||||
ocv_target_link_libraries(opencv_gapi PRIVATE ${FREETYPE_LIBRARIES})
|
||||
ocv_target_include_directories(opencv_gapi PRIVATE ${FREETYPE_INCLUDE_DIRS})
|
||||
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_FREETYPE)
|
||||
if(TARGET opencv_test_gapi)
|
||||
ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_FREETYPE)
|
||||
endif()
|
||||
ocv_target_link_libraries(${the_module} PRIVATE ${FREETYPE_LIBRARIES})
|
||||
ocv_target_include_directories(${the_module} PRIVATE ${FREETYPE_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(HAVE_PLAIDML)
|
||||
ocv_target_compile_definitions(opencv_gapi PRIVATE -DHAVE_PLAIDML)
|
||||
ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_PLAIDML)
|
||||
ocv_target_link_libraries(opencv_gapi PRIVATE ${PLAIDML_LIBRARIES})
|
||||
ocv_target_include_directories(opencv_gapi SYSTEM PRIVATE ${PLAIDML_INCLUDE_DIRS})
|
||||
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_PLAIDML)
|
||||
if(TARGET opencv_test_gapi)
|
||||
ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_PLAIDML)
|
||||
endif()
|
||||
ocv_target_link_libraries(${the_module} PRIVATE ${PLAIDML_LIBRARIES})
|
||||
ocv_target_include_directories(${the_module} SYSTEM PRIVATE ${PLAIDML_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
ocv_add_perf_tests()
|
||||
|
@ -1,8 +1,3 @@
|
||||
if(ANDROID)
|
||||
# FIXME: Android build will be enabled separately
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(ade_src_dir "${OpenCV_BINARY_DIR}/3rdparty/ade")
|
||||
set(ade_filename "v0.1.1f.zip")
|
||||
set(ade_subdir "ade-0.1.1f")
|
||||
|
@ -485,6 +485,22 @@ namespace core {
|
||||
return (ddepth < 0 ? in : in.withDepth(ddepth));
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GWarpPerspective, <GMat(GMat, const Mat&, Size, int, int, const cv::Scalar&)>, "org.opencv.core.warpPerspective") {
|
||||
static GMatDesc outMeta(GMatDesc in, const Mat&, Size dsize, int, int borderMode, const cv::Scalar&) {
|
||||
GAPI_Assert((borderMode == cv::BORDER_CONSTANT || borderMode == cv::BORDER_REPLICATE) &&
|
||||
"cv::gapi::warpPerspective supports only cv::BORDER_CONSTANT and cv::BORDER_REPLICATE border modes");
|
||||
return in.withType(in.depth, in.chan).withSize(dsize);
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GWarpAffine, <GMat(GMat, const Mat&, Size, int, int, const cv::Scalar&)>, "org.opencv.core.warpAffine") {
|
||||
static GMatDesc outMeta(GMatDesc in, const Mat&, Size dsize, int, int border_mode, const cv::Scalar&) {
|
||||
GAPI_Assert(border_mode != cv::BORDER_TRANSPARENT &&
|
||||
"cv::BORDER_TRANSPARENT mode is not supported in cv::gapi::warpAffine");
|
||||
return in.withType(in.depth, in.chan).withSize(dsize);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//! @addtogroup gapi_math
|
||||
@ -1653,6 +1669,55 @@ number of channels as src and the depth =ddepth.
|
||||
*/
|
||||
GAPI_EXPORTS GMat normalize(const GMat& src, double alpha, double beta,
|
||||
int norm_type, int ddepth = -1);
|
||||
|
||||
/** @brief Applies a perspective transformation to an image.
|
||||
|
||||
The function warpPerspective transforms the source image using the specified matrix:
|
||||
|
||||
\f[\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} ,
|
||||
\frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\f]
|
||||
|
||||
when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert
|
||||
and then put in the formula above instead of M. The function cannot operate in-place.
|
||||
|
||||
@param src input image.
|
||||
@param M \f$3\times 3\f$ transformation matrix.
|
||||
@param dsize size of the output image.
|
||||
@param flags combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the
|
||||
optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation (
|
||||
\f$\texttt{dst}\rightarrow\texttt{src}\f$ ).
|
||||
@param borderMode pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE).
|
||||
@param borderValue value used in case of a constant border; by default, it equals 0.
|
||||
|
||||
@sa warpAffine, resize, remap, getRectSubPix, perspectiveTransform
|
||||
*/
|
||||
GAPI_EXPORTS GMat warpPerspective(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR,
|
||||
int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar());
|
||||
|
||||
/** @brief Applies an affine transformation to an image.
|
||||
|
||||
The function warpAffine transforms the source image using the specified matrix:
|
||||
|
||||
\f[\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\f]
|
||||
|
||||
when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted
|
||||
with #invertAffineTransform and then put in the formula above instead of M. The function cannot
|
||||
operate in-place.
|
||||
|
||||
@param src input image.
|
||||
@param M \f$2\times 3\f$ transformation matrix.
|
||||
@param dsize size of the output image.
|
||||
@param flags combination of interpolation methods (see #InterpolationFlags) and the optional
|
||||
flag #WARP_INVERSE_MAP that means that M is the inverse transformation (
|
||||
\f$\texttt{dst}\rightarrow\texttt{src}\f$ ).
|
||||
@param borderMode pixel extrapolation method (see #BorderTypes);
|
||||
borderMode=#BORDER_TRANSPARENT isn't supported
|
||||
@param borderValue value used in case of a constant border; by default, it is 0.
|
||||
|
||||
@sa warpPerspective, resize, remap, getRectSubPix, transform
|
||||
*/
|
||||
GAPI_EXPORTS GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR,
|
||||
int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar());
|
||||
//! @} gapi_transform
|
||||
|
||||
} //namespace gapi
|
||||
|
@ -72,6 +72,17 @@ namespace cpu
|
||||
*/
|
||||
GAPI_EXPORTS cv::gapi::GBackend backend();
|
||||
/** @} */
|
||||
|
||||
class GOCVFunctor;
|
||||
|
||||
//! @cond IGNORED
|
||||
template<typename K, typename Callable>
|
||||
GOCVFunctor ocv_kernel(const Callable& c);
|
||||
|
||||
template<typename K, typename Callable>
|
||||
GOCVFunctor ocv_kernel(Callable& c);
|
||||
//! @endcond
|
||||
|
||||
} // namespace cpu
|
||||
} // namespace gapi
|
||||
|
||||
@ -88,15 +99,20 @@ public:
|
||||
const cv::gapi::own::Mat& inMat(int input);
|
||||
cv::gapi::own::Mat& outMatR(int output); // FIXME: Avoid cv::gapi::own::Mat m = ctx.outMatR()
|
||||
|
||||
const cv::gapi::own::Scalar& inVal(int input);
|
||||
cv::gapi::own::Scalar& outValR(int output); // FIXME: Avoid cv::gapi::own::Scalar s = ctx.outValR()
|
||||
const cv::Scalar& inVal(int input);
|
||||
cv::Scalar& outValR(int output); // FIXME: Avoid cv::Scalar s = ctx.outValR()
|
||||
template<typename T> std::vector<T>& outVecR(int output) // FIXME: the same issue
|
||||
{
|
||||
return outVecRef(output).wref<T>();
|
||||
}
|
||||
template<typename T> T& outOpaqueR(int output) // FIXME: the same issue
|
||||
{
|
||||
return outOpaqueRef(output).wref<T>();
|
||||
}
|
||||
|
||||
protected:
|
||||
detail::VectorRef& outVecRef(int output);
|
||||
detail::OpaqueRef& outOpaqueRef(int output);
|
||||
|
||||
std::vector<GArg> m_args;
|
||||
|
||||
@ -139,18 +155,37 @@ template<> struct get_in<cv::GMatP>
|
||||
};
|
||||
template<> struct get_in<cv::GScalar>
|
||||
{
|
||||
static cv::Scalar get(GCPUContext &ctx, int idx) { return to_ocv(ctx.inVal(idx)); }
|
||||
static cv::Scalar get(GCPUContext &ctx, int idx) { return ctx.inVal(idx); }
|
||||
};
|
||||
template<typename U> struct get_in<cv::GArray<U> >
|
||||
{
|
||||
static const std::vector<U>& get(GCPUContext &ctx, int idx) { return ctx.inArg<VectorRef>(idx).rref<U>(); }
|
||||
};
|
||||
template<typename U> struct get_in<cv::GOpaque<U> >
|
||||
{
|
||||
static const U& get(GCPUContext &ctx, int idx) { return ctx.inArg<OpaqueRef>(idx).rref<U>(); }
|
||||
};
|
||||
|
||||
//FIXME(dm): GArray<Mat>/GArray<GMat> conversion should be done more gracefully in the system
|
||||
template<> struct get_in<cv::GArray<cv::GMat> >: public get_in<cv::GArray<cv::Mat> >
|
||||
{
|
||||
};
|
||||
|
||||
//FIXME(dm): GArray<Scalar>/GArray<GScalar> conversion should be done more gracefully in the system
|
||||
template<> struct get_in<cv::GArray<cv::GScalar> >: public get_in<cv::GArray<cv::Scalar> >
|
||||
{
|
||||
};
|
||||
|
||||
//FIXME(dm): GOpaque<Mat>/GOpaque<GMat> conversion should be done more gracefully in the system
|
||||
template<> struct get_in<cv::GOpaque<cv::GMat> >: public get_in<cv::GOpaque<cv::Mat> >
|
||||
{
|
||||
};
|
||||
|
||||
//FIXME(dm): GOpaque<Scalar>/GOpaque<GScalar> conversion should be done more gracefully in the system
|
||||
template<> struct get_in<cv::GOpaque<cv::GScalar> >: public get_in<cv::GOpaque<cv::Mat> >
|
||||
{
|
||||
};
|
||||
|
||||
template<class T> struct get_in
|
||||
{
|
||||
static T get(GCPUContext &ctx, int idx) { return ctx.inArg<T>(idx); }
|
||||
@ -173,23 +208,12 @@ struct tracked_cv_mat{
|
||||
}
|
||||
};
|
||||
|
||||
struct scalar_wrapper
|
||||
{
|
||||
scalar_wrapper(cv::gapi::own::Scalar& s) : m_s{cv::gapi::own::to_ocv(s)}, m_org_s(s) {};
|
||||
operator cv::Scalar& () { return m_s; }
|
||||
void writeBack() const { m_org_s = to_own(m_s); }
|
||||
|
||||
cv::Scalar m_s;
|
||||
cv::gapi::own::Scalar& m_org_s;
|
||||
};
|
||||
|
||||
template<typename... Outputs>
|
||||
void postprocess(Outputs&... outs)
|
||||
{
|
||||
struct
|
||||
{
|
||||
void operator()(tracked_cv_mat* bm) { bm->validate(); }
|
||||
void operator()(scalar_wrapper* sw) { sw->writeBack(); }
|
||||
void operator()(...) { }
|
||||
|
||||
} validate;
|
||||
@ -216,10 +240,9 @@ template<> struct get_out<cv::GMatP>
|
||||
};
|
||||
template<> struct get_out<cv::GScalar>
|
||||
{
|
||||
static scalar_wrapper get(GCPUContext &ctx, int idx)
|
||||
static cv::Scalar& get(GCPUContext &ctx, int idx)
|
||||
{
|
||||
auto& s = ctx.outValR(idx);
|
||||
return {s};
|
||||
return ctx.outValR(idx);
|
||||
}
|
||||
};
|
||||
template<typename U> struct get_out<cv::GArray<U>>
|
||||
@ -229,6 +252,13 @@ template<typename U> struct get_out<cv::GArray<U>>
|
||||
return ctx.outVecR<U>(idx);
|
||||
}
|
||||
};
|
||||
template<typename U> struct get_out<cv::GOpaque<U>>
|
||||
{
|
||||
static U& get(GCPUContext &ctx, int idx)
|
||||
{
|
||||
return ctx.outOpaqueR<U>(idx);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename, typename, typename>
|
||||
struct OCVCallHelper;
|
||||
@ -248,6 +278,12 @@ struct OCVCallHelper<Impl, std::tuple<Ins...>, std::tuple<Outs...> >
|
||||
Impl::run(std::forward<Inputs>(ins)..., outs...);
|
||||
postprocess(outs...);
|
||||
}
|
||||
|
||||
template<typename... Outputs>
|
||||
static void call(Impl& impl, Inputs&&... ins, Outputs&&... outs)
|
||||
{
|
||||
impl(std::forward<Inputs>(ins)..., outs...);
|
||||
}
|
||||
};
|
||||
|
||||
template<int... IIs, int... OIs>
|
||||
@ -259,7 +295,17 @@ struct OCVCallHelper<Impl, std::tuple<Ins...>, std::tuple<Outs...> >
|
||||
//them to parameters of ad-hoc function
|
||||
//Convert own::Scalar to cv::Scalar before call kernel and run kernel
|
||||
//convert cv::Scalar to own::Scalar after call kernel and write back results
|
||||
call_and_postprocess<decltype(get_in<Ins>::get(ctx, IIs))...>::call(get_in<Ins>::get(ctx, IIs)..., get_out<Outs>::get(ctx, OIs)...);
|
||||
call_and_postprocess<decltype(get_in<Ins>::get(ctx, IIs))...>
|
||||
::call(get_in<Ins>::get(ctx, IIs)...,
|
||||
get_out<Outs>::get(ctx, OIs)...);
|
||||
}
|
||||
|
||||
template<int... IIs, int... OIs>
|
||||
static void call_impl(cv::GCPUContext &ctx, Impl& impl, detail::Seq<IIs...>, detail::Seq<OIs...>)
|
||||
{
|
||||
call_and_postprocess<decltype(cv::detail::get_in<Ins>::get(ctx, IIs))...>
|
||||
::call(impl, cv::detail::get_in<Ins>::get(ctx, IIs)...,
|
||||
cv::detail::get_out<Outs>::get(ctx, OIs)...);
|
||||
}
|
||||
|
||||
static void call(GCPUContext &ctx)
|
||||
@ -268,6 +314,16 @@ struct OCVCallHelper<Impl, std::tuple<Ins...>, std::tuple<Outs...> >
|
||||
typename detail::MkSeq<sizeof...(Ins)>::type(),
|
||||
typename detail::MkSeq<sizeof...(Outs)>::type());
|
||||
}
|
||||
|
||||
// NB: Same as call but calling the object
|
||||
// This necessary for kernel implementations that have a state
|
||||
// and are represented as an object
|
||||
static void callFunctor(cv::GCPUContext &ctx, Impl& impl)
|
||||
{
|
||||
call_impl(ctx, impl,
|
||||
typename detail::MkSeq<sizeof...(Ins)>::type(),
|
||||
typename detail::MkSeq<sizeof...(Outs)>::type());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@ -287,6 +343,39 @@ public:
|
||||
|
||||
#define GAPI_OCV_KERNEL(Name, API) struct Name: public cv::GCPUKernelImpl<Name, API>
|
||||
|
||||
class gapi::cpu::GOCVFunctor : public gapi::GFunctor
|
||||
{
|
||||
public:
|
||||
using Impl = std::function<void(GCPUContext &)>;
|
||||
|
||||
GOCVFunctor(const char* id, const Impl& impl)
|
||||
: gapi::GFunctor(id), impl_{GCPUKernel(impl)}
|
||||
{
|
||||
}
|
||||
|
||||
GKernelImpl impl() const override { return impl_; }
|
||||
gapi::GBackend backend() const override { return gapi::cpu::backend(); }
|
||||
|
||||
private:
|
||||
GKernelImpl impl_;
|
||||
};
|
||||
|
||||
//! @cond IGNORED
|
||||
template<typename K, typename Callable>
|
||||
gapi::cpu::GOCVFunctor gapi::cpu::ocv_kernel(Callable& c)
|
||||
{
|
||||
using P = detail::OCVCallHelper<Callable, typename K::InArgs, typename K::OutArgs>;
|
||||
return GOCVFunctor(K::id(), std::bind(&P::callFunctor, std::placeholders::_1, std::ref(c)));
|
||||
}
|
||||
|
||||
template<typename K, typename Callable>
|
||||
gapi::cpu::GOCVFunctor gapi::cpu::ocv_kernel(const Callable& c)
|
||||
{
|
||||
using P = detail::OCVCallHelper<Callable, typename K::InArgs, typename K::OutArgs>;
|
||||
return GOCVFunctor(K::id(), std::bind(&P::callFunctor, std::placeholders::_1, c));
|
||||
}
|
||||
//! @endcond
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GCPUKERNEL_HPP
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <opencv2/gapi/gmat.hpp>
|
||||
|
||||
#include <opencv2/gapi/util/optional.hpp>
|
||||
#include <opencv2/gapi/own/scalar.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp>
|
||||
|
||||
namespace cv {
|
||||
@ -27,13 +26,11 @@ namespace fluid {
|
||||
|
||||
struct Border
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
// This constructor is required to support existing kernels which are part of G-API
|
||||
Border(int _type, cv::Scalar _val) : type(_type), value(to_own(_val)) {};
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
Border(int _type, cv::gapi::own::Scalar _val) : type(_type), value(_val) {};
|
||||
Border(int _type, cv::Scalar _val) : type(_type), value(_val) {};
|
||||
|
||||
int type;
|
||||
cv::gapi::own::Scalar value;
|
||||
cv::Scalar value;
|
||||
};
|
||||
|
||||
using BorderOpt = util::optional<Border>;
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <opencv2/gapi/gcommon.hpp>
|
||||
#include <opencv2/gapi/gkernel.hpp>
|
||||
#include <opencv2/gapi/garg.hpp>
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
|
||||
#include <opencv2/gapi/fluid/gfluidbuffer.hpp>
|
||||
|
||||
@ -109,7 +108,7 @@ public:
|
||||
*/
|
||||
struct GFluidOutputRois
|
||||
{
|
||||
std::vector<cv::gapi::own::Rect> rois;
|
||||
std::vector<cv::Rect> rois;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -179,17 +178,10 @@ template<> struct fluid_get_in<cv::GMat>
|
||||
template<> struct fluid_get_in<cv::GScalar>
|
||||
{
|
||||
// FIXME: change to return by reference when moved to own::Scalar
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
static const cv::Scalar get(const cv::GArgs &in_args, int idx)
|
||||
{
|
||||
return cv::gapi::own::to_ocv(in_args[idx].unsafe_get<cv::gapi::own::Scalar>());
|
||||
return in_args[idx].unsafe_get<cv::Scalar>();
|
||||
}
|
||||
#else
|
||||
static const cv::gapi::own::Scalar get(const cv::GArgs &in_args, int idx)
|
||||
{
|
||||
return in_args[idx].get<cv::gapi::own::Scalar>();
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
};
|
||||
|
||||
template<typename U> struct fluid_get_in<cv::GArray<U>>
|
||||
@ -200,6 +192,14 @@ template<typename U> struct fluid_get_in<cv::GArray<U>>
|
||||
}
|
||||
};
|
||||
|
||||
template<typename U> struct fluid_get_in<cv::GOpaque<U>>
|
||||
{
|
||||
static const U& get(const cv::GArgs &in_args, int idx)
|
||||
{
|
||||
return in_args.at(idx).unsafe_get<cv::detail::OpaqueRef>().rref<U>();
|
||||
}
|
||||
};
|
||||
|
||||
template<class T> struct fluid_get_in
|
||||
{
|
||||
static const T& get(const cv::GArgs &in_args, int idx)
|
||||
|
@ -20,9 +20,9 @@
|
||||
#include <opencv2/gapi/gmat.hpp>
|
||||
#include <opencv2/gapi/gscalar.hpp>
|
||||
#include <opencv2/gapi/garray.hpp>
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
#include <opencv2/gapi/gtype_traits.hpp>
|
||||
#include <opencv2/gapi/gmetaarg.hpp>
|
||||
#include <opencv2/gapi/own/scalar.hpp>
|
||||
#include <opencv2/gapi/streaming/source.hpp>
|
||||
|
||||
namespace cv {
|
||||
@ -90,13 +90,13 @@ using GArgs = std::vector<GArg>;
|
||||
using GRunArg = util::variant<
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::Mat,
|
||||
cv::Scalar,
|
||||
cv::UMat,
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
cv::gapi::wip::IStreamSource::Ptr,
|
||||
cv::gapi::own::Mat,
|
||||
cv::gapi::own::Scalar,
|
||||
cv::detail::VectorRef
|
||||
cv::Scalar,
|
||||
cv::detail::VectorRef,
|
||||
cv::detail::OpaqueRef
|
||||
>;
|
||||
using GRunArgs = std::vector<GRunArg>;
|
||||
|
||||
@ -123,12 +123,12 @@ struct Data: public GRunArg
|
||||
using GRunArgP = util::variant<
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::Mat*,
|
||||
cv::Scalar*,
|
||||
cv::UMat*,
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
cv::gapi::own::Mat*,
|
||||
cv::gapi::own::Scalar*,
|
||||
cv::detail::VectorRef
|
||||
cv::Scalar*,
|
||||
cv::detail::VectorRef,
|
||||
cv::detail::OpaqueRef
|
||||
>;
|
||||
using GRunArgsP = std::vector<GRunArgP>;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <opencv2/gapi/gmat.hpp> // GMat
|
||||
#include <opencv2/gapi/gscalar.hpp> // GScalar
|
||||
#include <opencv2/gapi/garray.hpp> // GArray<T>
|
||||
#include <opencv2/gapi/gopaque.hpp> // GOpaque<T>
|
||||
|
||||
namespace cv {
|
||||
|
||||
@ -46,6 +47,11 @@ public:
|
||||
return GArray<T>(yieldArray(output));
|
||||
}
|
||||
|
||||
template<class T> GOpaque<T> yieldOpaque(int output = 0)
|
||||
{
|
||||
return GOpaque<T>(yieldOpaque(output));
|
||||
}
|
||||
|
||||
// Internal use only
|
||||
Priv& priv();
|
||||
const Priv& priv() const;
|
||||
@ -55,8 +61,9 @@ protected:
|
||||
|
||||
void setArgs(std::vector<GArg> &&args);
|
||||
|
||||
// Public version returns a typed array, this one is implementation detail
|
||||
// Public versions return a typed array or opaque, those are implementation details
|
||||
detail::GArrayU yieldArray(int output = 0);
|
||||
detail::GOpaqueU yieldOpaque(int output = 0);
|
||||
};
|
||||
|
||||
} // namespace cv
|
||||
|
@ -44,6 +44,7 @@ enum class GShape: int
|
||||
GMAT,
|
||||
GSCALAR,
|
||||
GARRAY,
|
||||
GOPAQUE,
|
||||
};
|
||||
|
||||
struct GCompileArg;
|
||||
|
@ -65,6 +65,16 @@ template<typename U> struct get_compound_in<cv::GArray<U>>
|
||||
}
|
||||
};
|
||||
|
||||
template<typename U> struct get_compound_in<cv::GOpaque<U>>
|
||||
{
|
||||
static cv::GOpaque<U> get(GCompoundContext &ctx, int idx)
|
||||
{
|
||||
auto opaq = cv::GOpaque<U>();
|
||||
ctx.m_args[idx] = GArg(opaq);
|
||||
return opaq;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename, typename, typename>
|
||||
struct GCompoundCallHelper;
|
||||
|
||||
|
@ -74,6 +74,10 @@ namespace detail
|
||||
{
|
||||
static inline cv::GArray<U> yield(cv::GCall &call, int i) { return call.yieldArray<U>(i); }
|
||||
};
|
||||
template<typename U> struct Yield<cv::GOpaque<U> >
|
||||
{
|
||||
static inline cv::GOpaque<U> yield(cv::GCall &call, int i) { return call.yieldOpaque<U>(i); }
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@ -87,7 +91,8 @@ namespace detail
|
||||
template<> struct MetaType<cv::GMat> { using type = GMatDesc; };
|
||||
template<> struct MetaType<cv::GMatP> { using type = GMatDesc; };
|
||||
template<> struct MetaType<cv::GScalar> { using type = GScalarDesc; };
|
||||
template<typename U> struct MetaType<cv::GArray<U> > { using type = GArrayDesc; };
|
||||
template<typename U> struct MetaType<cv::GArray<U> > { using type = GArrayDesc; };
|
||||
template<typename U> struct MetaType<cv::GOpaque<U> > { using type = GOpaqueDesc; };
|
||||
template<typename T> struct MetaType { using type = T; }; // opaque args passed as-is
|
||||
|
||||
// 2. Hacky test based on MetaType to check if we operate on G-* type or not
|
||||
@ -223,6 +228,20 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
// This tiny class eliminates the semantic difference between
|
||||
// GKernelType and GKernelTypeM.
|
||||
template<typename, typename> class KernelTypeMedium;
|
||||
|
||||
template<typename K, typename... R, typename... Args>
|
||||
class KernelTypeMedium<K, std::function<std::tuple<R...>(Args...)>> :
|
||||
public cv::GKernelTypeM<K, std::function<std::tuple<R...>(Args...)>> {};
|
||||
|
||||
template<typename K, typename R, typename... Args>
|
||||
class KernelTypeMedium<K, std::function<R(Args...)>> :
|
||||
public cv::GKernelType<K, std::function<R(Args...)>> {};
|
||||
} // namespace detail
|
||||
|
||||
} // namespace cv
|
||||
|
||||
|
||||
@ -251,12 +270,12 @@ public:
|
||||
*
|
||||
* @param Class type name for this operation.
|
||||
* @param API an `std::function<>`-like signature for the operation;
|
||||
* return type is a single value.
|
||||
* return type is a single value or a tuple of multiple values.
|
||||
* @param Id string identifier for the operation. Must be unique.
|
||||
*/
|
||||
#define G_TYPED_KERNEL_HELPER(Class, API, Id) \
|
||||
G_ID_HELPER_BODY(Class, Id) \
|
||||
struct Class final: public cv::GKernelType<Class, std::function API >, \
|
||||
#define G_TYPED_KERNEL_HELPER(Class, API, Id) \
|
||||
G_ID_HELPER_BODY(Class, Id) \
|
||||
struct Class final: public cv::detail::KernelTypeMedium<Class, std::function API >, \
|
||||
public G_ID_HELPER_CLASS(Class)
|
||||
// {body} is to be defined by user
|
||||
|
||||
@ -306,68 +325,17 @@ G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _
|
||||
G_TYPED_KERNEL_HELPER)(Class, __VA_ARGS__)) \
|
||||
|
||||
/**
|
||||
* Helper for G_TYPED_KERNEL_M declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api)
|
||||
* for more details.
|
||||
* Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api) for more details.
|
||||
*
|
||||
* @param Class type name for this operation.
|
||||
* @param API an `std::function<>`-like signature for the operation;
|
||||
* return type is a tuple of multiple values.
|
||||
* @param Id string identifier for the operation. Must be unique.
|
||||
*/
|
||||
#define G_TYPED_KERNEL_M_HELPER(Class, API, Id) \
|
||||
G_ID_HELPER_BODY(Class, Id) \
|
||||
struct Class final: public cv::GKernelTypeM<Class, std::function API >, \
|
||||
public G_ID_HELPER_CLASS(Class)
|
||||
// {body} is to be defined by user
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_2(Class, _1, _2, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_3(Class, _1, _2, _3, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_4(Class, _1, _2, _3, _4, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_5(Class, _1, _2, _3, _4, _5, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_6(Class, _1, _2, _3, _4, _5, _6, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_7(Class, _1, _2, _3, _4, _5, _6, _7, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_8(Class, _1, _2, _3, _4, _5, _6, _7, _8, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_9(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_10(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), Id)
|
||||
|
||||
/**
|
||||
* Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api)
|
||||
* for more details.
|
||||
* @deprecated This macro is deprecated in favor of `G_TYPED_KERNEL` that is used for declaring any
|
||||
* G-API Operation.
|
||||
*
|
||||
* @param Class type name for this operation.
|
||||
*/
|
||||
#define G_TYPED_KERNEL_M(Class, ...) __WRAP_VAARGS(GET_G_TYPED_KERNEL(__VA_ARGS__, \
|
||||
G_TYPED_KERNEL_M_HELPER_10, \
|
||||
G_TYPED_KERNEL_M_HELPER_9, \
|
||||
G_TYPED_KERNEL_M_HELPER_8, \
|
||||
G_TYPED_KERNEL_M_HELPER_7, \
|
||||
G_TYPED_KERNEL_M_HELPER_6, \
|
||||
G_TYPED_KERNEL_M_HELPER_5, \
|
||||
G_TYPED_KERNEL_M_HELPER_4, \
|
||||
G_TYPED_KERNEL_M_HELPER_3, \
|
||||
G_TYPED_KERNEL_M_HELPER_2, \
|
||||
G_TYPED_KERNEL_M_HELPER)(Class, __VA_ARGS__)) \
|
||||
// {body} is to be defined by user
|
||||
#define G_TYPED_KERNEL_M G_TYPED_KERNEL
|
||||
|
||||
#define G_API_OP G_TYPED_KERNEL
|
||||
#define G_API_OP_M G_TYPED_KERNEL_M
|
||||
#define G_API_OP_M G_API_OP
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@ -415,6 +383,20 @@ namespace std
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
class GFunctor
|
||||
{
|
||||
public:
|
||||
virtual cv::GKernelImpl impl() const = 0;
|
||||
virtual cv::gapi::GBackend backend() const = 0;
|
||||
const char* id() const { return m_id; }
|
||||
|
||||
virtual ~GFunctor() = default;
|
||||
protected:
|
||||
GFunctor(const char* id) : m_id(id) { };
|
||||
private:
|
||||
const char* m_id;
|
||||
};
|
||||
|
||||
/** \addtogroup gapi_compile_args
|
||||
* @{
|
||||
*/
|
||||
@ -492,6 +474,10 @@ namespace gapi {
|
||||
}
|
||||
|
||||
public:
|
||||
void include(const GFunctor& functor)
|
||||
{
|
||||
m_id_kernels[functor.id()] = std::make_pair(functor.backend(), functor.impl());
|
||||
}
|
||||
/**
|
||||
* @brief Returns total number of kernels
|
||||
* in the package (across all backends included)
|
||||
@ -650,6 +636,15 @@ namespace gapi {
|
||||
return pkg;
|
||||
};
|
||||
|
||||
template<typename... FF>
|
||||
GKernelPackage kernels(FF&... functors)
|
||||
{
|
||||
GKernelPackage pkg;
|
||||
int unused[] = { 0, (pkg.include(functors), 0)... };
|
||||
cv::util::suppress_unused_warning(unused);
|
||||
return pkg;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
// FYI - this function is already commented above
|
||||
|
@ -14,8 +14,6 @@
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/gcommon.hpp> // GShape
|
||||
|
||||
#include <opencv2/gapi/own/types.hpp> // cv::gapi::own::Size
|
||||
#include <opencv2/gapi/own/convert.hpp> // to_own
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
|
||||
// TODO GAPI_EXPORTS or so
|
||||
@ -46,6 +44,7 @@ struct GOrigin;
|
||||
* cv::GMat | cv::Mat
|
||||
* cv::GScalar | cv::Scalar
|
||||
* `cv::GArray<T>` | std::vector<T>
|
||||
* `cv::GOpaque<T>` | T
|
||||
*/
|
||||
class GAPI_EXPORTS GMat
|
||||
{
|
||||
@ -81,11 +80,11 @@ struct GAPI_EXPORTS GMatDesc
|
||||
// FIXME: Default initializers in C++14
|
||||
int depth;
|
||||
int chan;
|
||||
cv::gapi::own::Size size; // NB.: no multi-dimensional cases covered yet
|
||||
cv::Size size; // NB.: no multi-dimensional cases covered yet
|
||||
bool planar;
|
||||
std::vector<int> dims; // FIXME: Maybe it's real questionable to have it here
|
||||
|
||||
GMatDesc(int d, int c, cv::gapi::own::Size s, bool p = false)
|
||||
GMatDesc(int d, int c, cv::Size s, bool p = false)
|
||||
: depth(d), chan(c), size(s), planar(p) {}
|
||||
|
||||
GMatDesc(int d, const std::vector<int> &dd)
|
||||
@ -121,23 +120,13 @@ struct GAPI_EXPORTS GMatDesc
|
||||
// Meta combinator: return a new GMatDesc which differs in size by delta
|
||||
// (all other fields are taken unchanged from this GMatDesc)
|
||||
// FIXME: a better name?
|
||||
GMatDesc withSizeDelta(cv::gapi::own::Size delta) const
|
||||
GMatDesc withSizeDelta(cv::Size delta) const
|
||||
{
|
||||
GMatDesc desc(*this);
|
||||
desc.size += delta;
|
||||
return desc;
|
||||
}
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
GMatDesc withSizeDelta(cv::Size delta) const
|
||||
{
|
||||
return withSizeDelta(to_own(delta));
|
||||
}
|
||||
|
||||
GMatDesc withSize(cv::Size sz) const
|
||||
{
|
||||
return withSize(to_own(sz));
|
||||
}
|
||||
|
||||
bool canDescribe(const cv::Mat& mat) const;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
// Meta combinator: return a new GMatDesc which differs in size by delta
|
||||
@ -146,10 +135,10 @@ struct GAPI_EXPORTS GMatDesc
|
||||
// This is an overload.
|
||||
GMatDesc withSizeDelta(int dx, int dy) const
|
||||
{
|
||||
return withSizeDelta(cv::gapi::own::Size{dx,dy});
|
||||
return withSizeDelta(cv::Size{dx,dy});
|
||||
}
|
||||
|
||||
GMatDesc withSize(cv::gapi::own::Size sz) const
|
||||
GMatDesc withSize(cv::Size sz) const
|
||||
{
|
||||
GMatDesc desc(*this);
|
||||
desc.size = sz;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <opencv2/gapi/gmat.hpp>
|
||||
#include <opencv2/gapi/gscalar.hpp>
|
||||
#include <opencv2/gapi/garray.hpp>
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@ -36,6 +37,7 @@ using GMetaArg = util::variant
|
||||
, GMatDesc
|
||||
, GScalarDesc
|
||||
, GArrayDesc
|
||||
, GOpaqueDesc
|
||||
>;
|
||||
GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const GMetaArg &);
|
||||
|
||||
@ -52,6 +54,7 @@ namespace detail
|
||||
template<> struct is_meta_descr<GMatDesc> : std::true_type {};
|
||||
template<> struct is_meta_descr<GScalarDesc> : std::true_type {};
|
||||
template<> struct is_meta_descr<GArrayDesc> : std::true_type {};
|
||||
template<> struct is_meta_descr<GOpaqueDesc> : std::true_type {};
|
||||
|
||||
template<typename... Ts>
|
||||
using are_meta_descrs = all_satisfy<is_meta_descr, Ts...>;
|
||||
|
289
inference-engine/thirdparty/fluid/modules/gapi/include/opencv2/gapi/gopaque.hpp
vendored
Normal file
289
inference-engine/thirdparty/fluid/modules/gapi/include/opencv2/gapi/gopaque.hpp
vendored
Normal file
@ -0,0 +1,289 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_GOPAQUE_HPP
|
||||
#define OPENCV_GAPI_GOPAQUE_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
#include <memory>
|
||||
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
|
||||
#include <opencv2/gapi/util/variant.hpp>
|
||||
#include <opencv2/gapi/util/throw.hpp>
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
// Forward declaration; GNode and GOrigin are an internal
|
||||
// (user-inaccessible) classes.
|
||||
class GNode;
|
||||
struct GOrigin;
|
||||
|
||||
template<typename T> class GOpaque;
|
||||
|
||||
/**
|
||||
* \addtogroup gapi_meta_args
|
||||
* @{
|
||||
*/
|
||||
struct GOpaqueDesc
|
||||
{
|
||||
// FIXME: Body
|
||||
// FIXME: Also implement proper operator== then
|
||||
bool operator== (const GOpaqueDesc&) const { return true; }
|
||||
};
|
||||
template<typename U> GOpaqueDesc descr_of(const U &) { return {};}
|
||||
static inline GOpaqueDesc empty_gopaque_desc() {return {}; }
|
||||
/** @} */
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GOpaqueDesc &desc);
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// ConstructOpaque is a callback which stores information about T and is used by
|
||||
// G-API runtime to construct an object in host memory (T remains opaque for G-API).
|
||||
// ConstructOpaque is carried into G-API internals by GOpaqueU.
|
||||
// Currently it is suitable for Host (CPU) plugins only, real offload may require
|
||||
// more information for manual memory allocation on-device.
|
||||
class OpaqueRef;
|
||||
using ConstructOpaque = std::function<void(OpaqueRef&)>;
|
||||
|
||||
// FIXME: garray.hpp already contains hint classes (for actual T type verification),
|
||||
// need to think where it can be moved (currently opaque uses it from garray)
|
||||
|
||||
// This class strips type information from GOpaque<T> and makes it usable
|
||||
// in the G-API graph compiler (expression unrolling, graph generation, etc).
|
||||
// Part of GProtoArg.
|
||||
class GAPI_EXPORTS GOpaqueU
|
||||
{
|
||||
public:
|
||||
GOpaqueU(const GNode &n, std::size_t out); // Operation result constructor
|
||||
|
||||
template <typename T>
|
||||
bool holds() const; // Check if was created from GOpaque<T>
|
||||
|
||||
GOrigin& priv(); // Internal use only
|
||||
const GOrigin& priv() const; // Internal use only
|
||||
|
||||
protected:
|
||||
GOpaqueU(); // Default constructor
|
||||
template<class> friend class cv::GOpaque; // (available for GOpaque<T> only)
|
||||
|
||||
void setConstructFcn(ConstructOpaque &&cv); // Store T-aware constructor
|
||||
|
||||
template <typename T>
|
||||
void specifyType(); // Store type of initial GOpaque<T>
|
||||
|
||||
std::shared_ptr<GOrigin> m_priv;
|
||||
std::shared_ptr<TypeHintBase> m_hint;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool GOpaqueU::holds() const{
|
||||
GAPI_Assert(m_hint != nullptr);
|
||||
using U = typename std::decay<T>::type;
|
||||
return dynamic_cast<TypeHint<U>*>(m_hint.get()) != nullptr;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void GOpaqueU::specifyType(){
|
||||
m_hint.reset(new TypeHint<typename std::decay<T>::type>);
|
||||
};
|
||||
|
||||
// This class represents a typed object reference.
|
||||
// Depending on origins, this reference may be either "just a" reference to
|
||||
// an object created externally, OR actually own the underlying object
|
||||
// (be value holder).
|
||||
class BasicOpaqueRef
|
||||
{
|
||||
public:
|
||||
cv::GOpaqueDesc m_desc;
|
||||
virtual ~BasicOpaqueRef() {}
|
||||
|
||||
virtual void mov(BasicOpaqueRef &ref) = 0;
|
||||
};
|
||||
|
||||
template<typename T> class OpaqueRefT final: public BasicOpaqueRef
|
||||
{
|
||||
using empty_t = util::monostate;
|
||||
using ro_ext_t = const T *;
|
||||
using rw_ext_t = T *;
|
||||
using rw_own_t = T ;
|
||||
util::variant<empty_t, ro_ext_t, rw_ext_t, rw_own_t> m_ref;
|
||||
|
||||
inline bool isEmpty() const { return util::holds_alternative<empty_t>(m_ref); }
|
||||
inline bool isROExt() const { return util::holds_alternative<ro_ext_t>(m_ref); }
|
||||
inline bool isRWExt() const { return util::holds_alternative<rw_ext_t>(m_ref); }
|
||||
inline bool isRWOwn() const { return util::holds_alternative<rw_own_t>(m_ref); }
|
||||
|
||||
void init(const T* obj = nullptr)
|
||||
{
|
||||
if (obj) m_desc = cv::descr_of(*obj);
|
||||
}
|
||||
|
||||
public:
|
||||
OpaqueRefT() { init(); }
|
||||
virtual ~OpaqueRefT() {}
|
||||
|
||||
explicit OpaqueRefT(const T& obj) : m_ref(&obj) { init(&obj); }
|
||||
explicit OpaqueRefT( T& obj) : m_ref(&obj) { init(&obj); }
|
||||
explicit OpaqueRefT( T&& obj) : m_ref(std::move(obj)) { init(&obj); }
|
||||
|
||||
// Reset a OpaqueRefT. Called only for objects instantiated
|
||||
// internally in G-API (e.g. temporary GOpaque<T>'s within a
|
||||
// computation). Reset here means both initialization
|
||||
// (creating an object) and reset (discarding its existing
|
||||
// content before the next execution). Must never be called
|
||||
// for external OpaqueRefTs.
|
||||
void reset()
|
||||
{
|
||||
if (isEmpty())
|
||||
{
|
||||
T empty_obj{};
|
||||
m_desc = cv::descr_of(empty_obj);
|
||||
m_ref = std::move(empty_obj);
|
||||
GAPI_Assert(isRWOwn());
|
||||
}
|
||||
else if (isRWOwn())
|
||||
{
|
||||
util::get<rw_own_t>(m_ref) = {};
|
||||
}
|
||||
else GAPI_Assert(false); // shouldn't be called in *EXT modes
|
||||
}
|
||||
|
||||
// Obtain a WRITE reference to underlying object
|
||||
// Used by CPU kernel API wrappers when a kernel execution frame
|
||||
// is created
|
||||
T& wref()
|
||||
{
|
||||
GAPI_Assert(isRWExt() || isRWOwn());
|
||||
if (isRWExt()) return *util::get<rw_ext_t>(m_ref);
|
||||
if (isRWOwn()) return util::get<rw_own_t>(m_ref);
|
||||
util::throw_error(std::logic_error("Impossible happened"));
|
||||
}
|
||||
|
||||
// Obtain a READ reference to underlying object
|
||||
// Used by CPU kernel API wrappers when a kernel execution frame
|
||||
// is created
|
||||
const T& rref() const
|
||||
{
|
||||
// ANY object can be accessed for reading, even if it declared for
|
||||
// output. Example -- a GComputation from [in] to [out1,out2]
|
||||
// where [out2] is a result of operation applied to [out1]:
|
||||
//
|
||||
// GComputation boundary
|
||||
// . . . . . . .
|
||||
// . .
|
||||
// [in] ----> foo() ----> [out1]
|
||||
// . . :
|
||||
// . . . .:. . .
|
||||
// . V .
|
||||
// . bar() ---> [out2]
|
||||
// . . . . . . . . . . . .
|
||||
//
|
||||
if (isROExt()) return *util::get<ro_ext_t>(m_ref);
|
||||
if (isRWExt()) return *util::get<rw_ext_t>(m_ref);
|
||||
if (isRWOwn()) return util::get<rw_own_t>(m_ref);
|
||||
util::throw_error(std::logic_error("Impossible happened"));
|
||||
}
|
||||
|
||||
virtual void mov(BasicOpaqueRef &v) override {
|
||||
OpaqueRefT<T> *tv = dynamic_cast<OpaqueRefT<T>*>(&v);
|
||||
GAPI_Assert(tv != nullptr);
|
||||
wref() = std::move(tv->wref());
|
||||
}
|
||||
};
|
||||
|
||||
// This class strips type information from OpaqueRefT<> and makes it usable
|
||||
// in the G-API executables (carrying run-time data/information to kernels).
|
||||
// Part of GRunArg.
|
||||
// Its methods are typed proxies to OpaqueRefT<T>.
|
||||
// OpaqueRef maintains "reference" semantics so two copies of OpaqueRef refer
|
||||
// to the same underlying object.
|
||||
class OpaqueRef
|
||||
{
|
||||
std::shared_ptr<BasicOpaqueRef> m_ref;
|
||||
|
||||
template<typename T> inline void check() const
|
||||
{
|
||||
GAPI_DbgAssert(dynamic_cast<OpaqueRefT<T>*>(m_ref.get()) != nullptr);
|
||||
}
|
||||
|
||||
public:
|
||||
OpaqueRef() = default;
|
||||
|
||||
template<typename T> explicit OpaqueRef(T&& obj) :
|
||||
m_ref(new OpaqueRefT<typename std::decay<T>::type>(std::forward<T>(obj))) {}
|
||||
|
||||
template<typename T> void reset()
|
||||
{
|
||||
if (!m_ref) m_ref.reset(new OpaqueRefT<T>());
|
||||
|
||||
check<T>();
|
||||
static_cast<OpaqueRefT<T>&>(*m_ref).reset();
|
||||
}
|
||||
|
||||
template<typename T> T& wref()
|
||||
{
|
||||
check<T>();
|
||||
return static_cast<OpaqueRefT<T>&>(*m_ref).wref();
|
||||
}
|
||||
|
||||
template<typename T> const T& rref() const
|
||||
{
|
||||
check<T>();
|
||||
return static_cast<OpaqueRefT<T>&>(*m_ref).rref();
|
||||
}
|
||||
|
||||
void mov(OpaqueRef &v)
|
||||
{
|
||||
m_ref->mov(*v.m_ref);
|
||||
}
|
||||
|
||||
cv::GOpaqueDesc descr_of() const
|
||||
{
|
||||
return m_ref->m_desc;
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
/** \addtogroup gapi_data_objects
|
||||
* @{
|
||||
*/
|
||||
|
||||
template<typename T> class GOpaque
|
||||
{
|
||||
public:
|
||||
GOpaque() { putDetails(); } // Empty constructor
|
||||
explicit GOpaque(detail::GOpaqueU &&ref) // GOpaqueU-based constructor
|
||||
: m_ref(ref) { putDetails(); } // (used by GCall, not for users)
|
||||
|
||||
detail::GOpaqueU strip() const { return m_ref; }
|
||||
|
||||
private:
|
||||
// Host type (or Flat type) - the type this GOpaque is actually
|
||||
// specified to.
|
||||
using HT = typename detail::flatten_g<typename std::decay<T>::type>::type;
|
||||
|
||||
static void CTor(detail::OpaqueRef& ref) {
|
||||
ref.reset<HT>();
|
||||
}
|
||||
void putDetails() {
|
||||
m_ref.setConstructFcn(&CTor);
|
||||
m_ref.specifyType<HT>();
|
||||
}
|
||||
|
||||
detail::GOpaqueU m_ref;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GOPAQUE_HPP
|
@ -17,6 +17,7 @@
|
||||
#include <opencv2/gapi/gmat.hpp>
|
||||
#include <opencv2/gapi/gscalar.hpp>
|
||||
#include <opencv2/gapi/garray.hpp>
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
#include <opencv2/gapi/garg.hpp>
|
||||
#include <opencv2/gapi/gmetaarg.hpp>
|
||||
|
||||
@ -36,7 +37,8 @@ using GProtoArg = util::variant
|
||||
< GMat
|
||||
, GMatP
|
||||
, GScalar
|
||||
, detail::GArrayU // instead of GArray<T>
|
||||
, detail::GArrayU // instead of GArray<T>
|
||||
, detail::GOpaqueU // instead of GOpaque<T>
|
||||
>;
|
||||
|
||||
using GProtoArgs = std::vector<GProtoArg>;
|
||||
@ -124,6 +126,10 @@ bool GAPI_EXPORTS can_describe(const GMetaArgs& metas, const GRunArgs& args);
|
||||
// coincides with output arguments passed to computation in cpu and ocl backends
|
||||
bool GAPI_EXPORTS can_describe(const GMetaArg& meta, const GRunArgP& argp);
|
||||
|
||||
// Validates input arguments
|
||||
void GAPI_EXPORTS validate_input_arg(const GRunArg& arg);
|
||||
void GAPI_EXPORTS validate_input_args(const GRunArgs& args);
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GPROTO_HPP
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/gcommon.hpp> // GShape
|
||||
#include <opencv2/gapi/util/optional.hpp>
|
||||
#include <opencv2/gapi/own/scalar.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@ -31,11 +30,9 @@ class GAPI_EXPORTS GScalar
|
||||
{
|
||||
public:
|
||||
GScalar(); // Empty constructor
|
||||
explicit GScalar(const cv::gapi::own::Scalar& s); // Constant value constructor from cv::gapi::own::Scalar
|
||||
explicit GScalar(cv::gapi::own::Scalar&& s); // Constant value move-constructor from cv::gapi::own::Scalar
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
explicit GScalar(const cv::Scalar& s); // Constant value constructor from cv::Scalar
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
explicit GScalar(const cv::Scalar& s); // Constant value constructor from cv::Scalar
|
||||
explicit GScalar(cv::Scalar&& s); // Constant value move-constructor from cv::Scalar
|
||||
|
||||
GScalar(double v0); // Constant value constructor from double
|
||||
GScalar(const GNode &n, std::size_t out); // Operation result constructor
|
||||
|
||||
@ -69,12 +66,7 @@ struct GScalarDesc
|
||||
|
||||
static inline GScalarDesc empty_scalar_desc() { return GScalarDesc(); }
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
GAPI_EXPORTS GScalarDesc descr_of(const cv::Scalar &scalar);
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
/** @} */
|
||||
|
||||
GAPI_EXPORTS GScalarDesc descr_of(const cv::gapi::own::Scalar &scalar);
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GScalarDesc &desc);
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <opencv2/gapi/gmat.hpp>
|
||||
#include <opencv2/gapi/gscalar.hpp>
|
||||
#include <opencv2/gapi/garray.hpp>
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
#include <opencv2/gapi/streaming/source.hpp>
|
||||
#include <opencv2/gapi/gcommon.hpp>
|
||||
#include <opencv2/gapi/own/convert.hpp>
|
||||
@ -36,7 +37,8 @@ namespace detail
|
||||
GMAT, // a cv::GMat
|
||||
GMATP, // a cv::GMatP
|
||||
GSCALAR, // a cv::GScalar
|
||||
GARRAY, // a cv::GArrayU (note - exactly GArrayU, not GArray<T>!)
|
||||
GARRAY, // a cv::GArrayU (note - exactly GArrayU, not GArray<T>!)
|
||||
GOPAQUE, // a cv::GOpaqueU (note - exactly GOpaqueU, not GOpaque<T>!)
|
||||
};
|
||||
|
||||
// Describe G-API types (G-types) with traits. Mostly used by
|
||||
@ -73,6 +75,16 @@ namespace detail
|
||||
static cv::detail::VectorRef wrap_in (const std::vector<T> &t) { return detail::VectorRef(t); }
|
||||
static cv::detail::VectorRef wrap_out ( std::vector<T> &t) { return detail::VectorRef(t); }
|
||||
};
|
||||
template<class T> struct GTypeTraits<cv::GOpaque<T> >
|
||||
{
|
||||
static constexpr const ArgKind kind = ArgKind::GOPAQUE;
|
||||
static constexpr const GShape shape = GShape::GOPAQUE;
|
||||
using host_type = T;
|
||||
using strip_type = cv::detail::OpaqueRef;
|
||||
static cv::detail::GOpaqueU wrap_value(const cv::GOpaque<T> &t) { return t.strip();}
|
||||
static cv::detail::OpaqueRef wrap_in (const T &t) { return detail::OpaqueRef(t); }
|
||||
static cv::detail::OpaqueRef wrap_out ( T &t) { return detail::OpaqueRef(t); }
|
||||
};
|
||||
|
||||
// Tests if Trait for type T requires extra marshalling ("custom wrap") or not.
|
||||
// If Traits<T> has wrap_value() defined, it does.
|
||||
@ -95,11 +107,11 @@ namespace detail
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
template<> struct GTypeOf<cv::Mat> { using type = cv::GMat; };
|
||||
template<> struct GTypeOf<cv::UMat> { using type = cv::GMat; };
|
||||
template<> struct GTypeOf<cv::Scalar> { using type = cv::GScalar; };
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
template<> struct GTypeOf<cv::gapi::own::Mat> { using type = cv::GMat; };
|
||||
template<> struct GTypeOf<cv::gapi::own::Scalar> { using type = cv::GScalar; };
|
||||
template<> struct GTypeOf<cv::Scalar> { using type = cv::GScalar; };
|
||||
template<typename U> struct GTypeOf<std::vector<U> > { using type = cv::GArray<U>; };
|
||||
template<typename U> struct GTypeOf { using type = cv::GOpaque<U>;};
|
||||
// FIXME: This is not quite correct since IStreamSource may produce not only Mat but also Scalar
|
||||
// and vector data. TODO: Extend the type dispatching on these types too.
|
||||
template<> struct GTypeOf<cv::gapi::wip::IStreamSource::Ptr> { using type = cv::GMat;};
|
||||
@ -164,7 +176,6 @@ namespace detail
|
||||
|
||||
template<typename T> using wrap_gapi_helper = WrapValue<typename std::decay<T>::type>;
|
||||
template<typename T> using wrap_host_helper = WrapValue<typename std::decay<g_type_of_t<T> >::type>;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@ -25,13 +25,15 @@ namespace detail
|
||||
template<typename T> struct ProtoToParam;
|
||||
template<> struct ProtoToParam<cv::GMat> { using type = cv::Mat; };
|
||||
template<> struct ProtoToParam<cv::GScalar> { using type = cv::Scalar; };
|
||||
template<typename U> struct ProtoToParam<cv::GArray<U> > { using type = std::vector<U>; };
|
||||
template<typename U> struct ProtoToParam<cv::GArray<U> > { using type = std::vector<U>; };
|
||||
template<typename U> struct ProtoToParam<cv::GOpaque<U> > { using type = U; };
|
||||
template<typename T> using ProtoToParamT = typename ProtoToParam<T>::type;
|
||||
|
||||
template<typename T> struct ProtoToMeta;
|
||||
template<> struct ProtoToMeta<cv::GMat> { using type = cv::GMatDesc; };
|
||||
template<> struct ProtoToMeta<cv::GScalar> { using type = cv::GScalarDesc; };
|
||||
template<typename U> struct ProtoToMeta<cv::GArray<U> > { using type = cv::GArrayDesc; };
|
||||
template<typename U> struct ProtoToMeta<cv::GArray<U> > { using type = cv::GArrayDesc; };
|
||||
template<typename U> struct ProtoToMeta<cv::GOpaque<U> > { using type = cv::GOpaqueDesc; };
|
||||
template<typename T> using ProtoToMetaT = typename ProtoToMeta<T>::type;
|
||||
|
||||
//workaround for MSVC 19.0 bug
|
||||
|
@ -222,6 +222,21 @@ namespace imgproc {
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GNV12toGray, <GMat(GMat,GMat)>, "org.opencv.colorconvert.imgproc.nv12togray") {
|
||||
static GMatDesc outMeta(GMatDesc inY, GMatDesc inUV) {
|
||||
GAPI_Assert(inY.depth == CV_8U);
|
||||
GAPI_Assert(inUV.depth == CV_8U);
|
||||
GAPI_Assert(inY.chan == 1);
|
||||
GAPI_Assert(inY.planar == false);
|
||||
GAPI_Assert(inUV.chan == 2);
|
||||
GAPI_Assert(inUV.planar == false);
|
||||
|
||||
GAPI_Assert(inY.size.width == 2 * inUV.size.width);
|
||||
GAPI_Assert(inY.size.height == 2 * inUV.size.height);
|
||||
return inY.withType(CV_8U, 1);
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GNV12toBGRp, <GMatP(GMat,GMat)>, "org.opencv.colorconvert.imgproc.nv12tobgrp") {
|
||||
static GMatDesc outMeta(GMatDesc inY, GMatDesc inUV) {
|
||||
GAPI_Assert(inY.depth == CV_8U);
|
||||
@ -819,6 +834,21 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
*/
|
||||
GAPI_EXPORTS GMat NV12toRGB(const GMat& src_y, const GMat& src_uv);
|
||||
|
||||
/** @brief Converts an image from NV12 (YUV420p) color space to gray-scaled.
|
||||
The function converts an input image from NV12 color space to gray-scaled.
|
||||
The conventional ranges for Y, U, and V channel values are 0 to 255.
|
||||
|
||||
Output image must be 8-bit unsigned 1-channel image @ref CV_8UC1.
|
||||
|
||||
@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12togray"
|
||||
|
||||
@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1.
|
||||
@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2.
|
||||
|
||||
@sa YUV2RGB, NV12toBGR
|
||||
*/
|
||||
GAPI_EXPORTS GMat NV12toGray(const GMat& src_y, const GMat& src_uv);
|
||||
|
||||
/** @brief Converts an image from NV12 (YUV420p) color space to BGR.
|
||||
The function converts an input image from NV12 color space to RGB.
|
||||
The conventional ranges for Y, U, and V channel values are 0 to 255.
|
||||
|
@ -23,23 +23,6 @@
|
||||
|
||||
namespace cv {
|
||||
|
||||
namespace detail {
|
||||
// This tiny class eliminates the semantic difference between
|
||||
// GKernelType and GKernelTypeM.
|
||||
// FIXME: Something similar can be reused for regular kernels
|
||||
template<typename, typename>
|
||||
struct KernelTypeMedium;
|
||||
|
||||
template<class K, typename... R, typename... Args>
|
||||
struct KernelTypeMedium<K, std::function<std::tuple<R...>(Args...)> >:
|
||||
public GKernelTypeM<K, std::function<std::tuple<R...>(Args...)> > {};
|
||||
|
||||
template<class K, typename R, typename... Args>
|
||||
struct KernelTypeMedium<K, std::function<R(Args...)> >:
|
||||
public GKernelType<K, std::function<R(Args...)> > {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<typename, typename> class GNetworkType;
|
||||
|
||||
// TODO: maybe tuple_wrap_helper from util.hpp may help with this.
|
||||
|
@ -62,15 +62,20 @@ public:
|
||||
const cv::UMat& inMat(int input);
|
||||
cv::UMat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR()
|
||||
|
||||
const cv::gapi::own::Scalar& inVal(int input);
|
||||
cv::gapi::own::Scalar& outValR(int output); // FIXME: Avoid cv::gapi::own::Scalar s = ctx.outValR()
|
||||
const cv::Scalar& inVal(int input);
|
||||
cv::Scalar& outValR(int output); // FIXME: Avoid cv::Scalar s = ctx.outValR()
|
||||
template<typename T> std::vector<T>& outVecR(int output) // FIXME: the same issue
|
||||
{
|
||||
return outVecRef(output).wref<T>();
|
||||
}
|
||||
template<typename T> T& outOpaqueR(int output) // FIXME: the same issue
|
||||
{
|
||||
return outOpaqueRef(output).wref<T>();
|
||||
}
|
||||
|
||||
protected:
|
||||
detail::VectorRef& outVecRef(int output);
|
||||
detail::VectorRef& outOpaqueRef(int output);
|
||||
|
||||
std::vector<GArg> m_args;
|
||||
std::unordered_map<std::size_t, GRunArgP> m_results;
|
||||
@ -105,12 +110,16 @@ template<> struct ocl_get_in<cv::GMat>
|
||||
};
|
||||
template<> struct ocl_get_in<cv::GScalar>
|
||||
{
|
||||
static cv::Scalar get(GOCLContext &ctx, int idx) { return to_ocv(ctx.inVal(idx)); }
|
||||
static cv::Scalar get(GOCLContext &ctx, int idx) { return ctx.inVal(idx); }
|
||||
};
|
||||
template<typename U> struct ocl_get_in<cv::GArray<U> >
|
||||
{
|
||||
static const std::vector<U>& get(GOCLContext &ctx, int idx) { return ctx.inArg<VectorRef>(idx).rref<U>(); }
|
||||
};
|
||||
template<typename U> struct ocl_get_in<cv::GOpaque<U> >
|
||||
{
|
||||
static const U& get(GOCLContext &ctx, int idx) { return ctx.inArg<OpaqueRef>(idx).rref<U>(); }
|
||||
};
|
||||
template<class T> struct ocl_get_in
|
||||
{
|
||||
static T get(GOCLContext &ctx, int idx) { return ctx.inArg<T>(idx); }
|
||||
@ -137,24 +146,12 @@ struct tracked_cv_umat{
|
||||
}
|
||||
};
|
||||
|
||||
struct scalar_wrapper_ocl
|
||||
{
|
||||
//FIXME reuse CPU (OpenCV) plugin code
|
||||
scalar_wrapper_ocl(cv::gapi::own::Scalar& s) : m_s{cv::gapi::own::to_ocv(s)}, m_org_s(s) {};
|
||||
operator cv::Scalar& () { return m_s; }
|
||||
void writeBack() const { m_org_s = to_own(m_s); }
|
||||
|
||||
cv::Scalar m_s;
|
||||
cv::gapi::own::Scalar& m_org_s;
|
||||
};
|
||||
|
||||
template<typename... Outputs>
|
||||
void postprocess_ocl(Outputs&... outs)
|
||||
{
|
||||
struct
|
||||
{
|
||||
void operator()(tracked_cv_umat* bm) { bm->validate(); }
|
||||
void operator()(scalar_wrapper_ocl* sw) { sw->writeBack(); }
|
||||
void operator()(...) { }
|
||||
|
||||
} validate;
|
||||
@ -174,16 +171,19 @@ template<> struct ocl_get_out<cv::GMat>
|
||||
};
|
||||
template<> struct ocl_get_out<cv::GScalar>
|
||||
{
|
||||
static scalar_wrapper_ocl get(GOCLContext &ctx, int idx)
|
||||
static cv::Scalar& get(GOCLContext &ctx, int idx)
|
||||
{
|
||||
auto& s = ctx.outValR(idx);
|
||||
return{ s };
|
||||
return ctx.outValR(idx);
|
||||
}
|
||||
};
|
||||
template<typename U> struct ocl_get_out<cv::GArray<U> >
|
||||
{
|
||||
static std::vector<U>& get(GOCLContext &ctx, int idx) { return ctx.outVecR<U>(idx); }
|
||||
};
|
||||
template<typename U> struct ocl_get_out<cv::GOpaque<U> >
|
||||
{
|
||||
static U& get(GOCLContext &ctx, int idx) { return ctx.outOpaqueR<U>(idx); }
|
||||
};
|
||||
|
||||
template<typename, typename, typename>
|
||||
struct OCLCallHelper;
|
||||
|
@ -11,9 +11,7 @@
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp>
|
||||
#include <opencv2/gapi/own/scalar.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@ -34,15 +32,6 @@ namespace cv
|
||||
? cv::gapi::own::Mat{m.rows, m.cols, m.type(), m.data, m.step}
|
||||
: cv::gapi::own::Mat{to_own<int>(m.size), m.type(), m.data};
|
||||
};
|
||||
|
||||
|
||||
inline cv::gapi::own::Scalar to_own(const cv::Scalar& s) { return {s[0], s[1], s[2], s[3]}; };
|
||||
|
||||
inline cv::gapi::own::Size to_own (const Size& s) { return {s.width, s.height}; };
|
||||
|
||||
inline cv::gapi::own::Rect to_own (const Rect& r) { return {r.x, r.y, r.width, r.height}; };
|
||||
|
||||
|
||||
namespace gapi
|
||||
{
|
||||
namespace own
|
||||
@ -53,13 +42,6 @@ namespace own
|
||||
: cv::Mat{m.dims, m.type(), m.data};
|
||||
}
|
||||
cv::Mat to_ocv(Mat&&) = delete;
|
||||
|
||||
inline cv::Scalar to_ocv(const Scalar& s) { return {s[0], s[1], s[2], s[3]}; };
|
||||
|
||||
inline cv::Size to_ocv (const Size& s) { return cv::Size(s.width, s.height); };
|
||||
|
||||
inline cv::Rect to_ocv (const Rect& r) { return cv::Rect(r.x, r.y, r.width, r.height); };
|
||||
|
||||
} // namespace own
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
@ -9,6 +9,8 @@
|
||||
#define OPENCV_GAPI_CV_DEFS_HPP
|
||||
|
||||
#if defined(GAPI_STANDALONE)
|
||||
#include <opencv2/gapi/own/types.hpp> // cv::gapi::own::Rect/Size/Point
|
||||
#include <opencv2/gapi/own/scalar.hpp> // cv::gapi::own::Scalar
|
||||
|
||||
// Simulate OpenCV definitions taken from various
|
||||
// OpenCV interface headers if G-API is built in a
|
||||
@ -137,6 +139,11 @@ enum InterpolationFlags{
|
||||
INTER_LINEAR_EXACT = 5,
|
||||
INTER_MAX = 7,
|
||||
};
|
||||
// replacement of cv's structures:
|
||||
using Rect = gapi::own::Rect;
|
||||
using Size = gapi::own::Size;
|
||||
using Point = gapi::own::Point;
|
||||
using Scalar = gapi::own::Scalar;
|
||||
} // namespace cv
|
||||
|
||||
static inline int cvFloor( double value )
|
||||
|
@ -230,6 +230,7 @@ namespace cv { namespace gapi { namespace own {
|
||||
*/
|
||||
void create(Size _size, int _type)
|
||||
{
|
||||
GAPI_Assert(_size.height >= 0 && _size.width >= 0);
|
||||
if (_size != Size{cols, rows} )
|
||||
{
|
||||
Mat tmp{_size.height, _size.width, _type, nullptr};
|
||||
@ -296,10 +297,9 @@ namespace cv { namespace gapi { namespace own {
|
||||
*/
|
||||
size_t total() const
|
||||
{
|
||||
return static_cast<std::size_t>
|
||||
(dims.empty()
|
||||
? (rows * cols)
|
||||
: std::accumulate(dims.begin(), dims.end(), 1, std::multiplies<int>()));
|
||||
return dims.empty()
|
||||
? (static_cast<std::size_t>(rows) * cols)
|
||||
: std::accumulate(dims.begin(), dims.end(), static_cast<std::size_t>(1), std::multiplies<size_t>());
|
||||
}
|
||||
|
||||
/** @overload
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/util/variant.hpp>
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
#include <opencv2/gapi/own/scalar.hpp>
|
||||
|
||||
|
||||
/** \defgroup gapi_draw G-API Drawing and composition functionality
|
||||
|
@ -281,13 +281,14 @@ namespace util
|
||||
template<class T> typename detail::are_different<variant<Ts...>, T, variant<Ts...>&>
|
||||
::type variant<Ts...>::operator=(T&& t) noexcept
|
||||
{
|
||||
using decayed_t = typename std::decay<T>::type;
|
||||
// FIXME: No version with implicit type conversion available!
|
||||
static const constexpr std::size_t t_index =
|
||||
util::type_list_index<T, Ts...>::value;
|
||||
util::type_list_index<decayed_t, Ts...>::value;
|
||||
|
||||
if (t_index == m_index)
|
||||
{
|
||||
util::get<T>(*this) = std::move(t);
|
||||
util::get<decayed_t>(*this) = std::move(t);
|
||||
return *this;
|
||||
}
|
||||
else return (*this = variant(std::move(t)));
|
||||
|
@ -620,7 +620,7 @@ PERF_TEST_P_(CmpPerfTest, TestPerformance)
|
||||
}
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
@ -666,7 +666,7 @@ PERF_TEST_P_(CmpWithScalarPerfTest, TestPerformance)
|
||||
}
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
|
216
inference-engine/thirdparty/fluid/modules/gapi/samples/privacy_masking_camera.cpp
vendored
Normal file
216
inference-engine/thirdparty/fluid/modules/gapi/samples/privacy_masking_camera.cpp
vendored
Normal file
@ -0,0 +1,216 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <cctype>
|
||||
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#include <opencv2/gapi.hpp>
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
#include <opencv2/gapi/imgproc.hpp>
|
||||
#include <opencv2/gapi/infer.hpp>
|
||||
#include <opencv2/gapi/render.hpp>
|
||||
#include <opencv2/gapi/infer/ie.hpp>
|
||||
#include <opencv2/gapi/cpu/gcpukernel.hpp>
|
||||
#include <opencv2/gapi/streaming/cap.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
const std::string about =
|
||||
"This is an OpenCV-based version of Privacy Masking Camera example";
|
||||
const std::string keys =
|
||||
"{ h help | | Print this help message }"
|
||||
"{ input | | Path to the input video file }"
|
||||
"{ platm | vehicle-license-plate-detection-barrier-0106.xml | Path to OpenVINO IE vehicle/plate detection model (.xml) }"
|
||||
"{ platd | CPU | Target device for vehicle/plate detection model (e.g. CPU, GPU, VPU, ...) }"
|
||||
"{ facem | face-detection-adas-0001.xml | Path to OpenVINO IE face detection model (.xml) }"
|
||||
"{ faced | CPU | Target device for face detection model (e.g. CPU, GPU, VPU, ...) }"
|
||||
"{ trad | false | Run processing in a traditional (non-pipelined) way }"
|
||||
"{ noshow | false | Don't display UI (improves performance) }";
|
||||
|
||||
namespace {
|
||||
|
||||
std::string weights_path(const std::string &model_path) {
|
||||
const auto EXT_LEN = 4u;
|
||||
const auto sz = model_path.size();
|
||||
CV_Assert(sz > EXT_LEN);
|
||||
|
||||
auto ext = model_path.substr(sz - EXT_LEN);
|
||||
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c){ return static_cast<unsigned char>(std::tolower(c)); });
|
||||
CV_Assert(ext == ".xml");
|
||||
|
||||
return model_path.substr(0u, sz - EXT_LEN) + ".bin";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace custom {
|
||||
|
||||
G_API_NET(VehLicDetector, <cv::GMat(cv::GMat)>, "vehicle-license-plate-detector");
|
||||
G_API_NET(FaceDetector, <cv::GMat(cv::GMat)>, "face-detector");
|
||||
|
||||
using GDetections = cv::GArray<cv::Rect>;
|
||||
|
||||
G_API_OP(ParseSSD, <GDetections(cv::GMat, cv::GMat, int)>, "custom.privacy_masking.postproc") {
|
||||
static cv::GArrayDesc outMeta(const cv::GMatDesc &, const cv::GMatDesc &, int) {
|
||||
return cv::empty_array_desc();
|
||||
}
|
||||
};
|
||||
|
||||
using GPrims = cv::GArray<cv::gapi::wip::draw::Prim>;
|
||||
|
||||
G_API_OP(ToMosaic, <GPrims(GDetections, GDetections)>, "custom.privacy_masking.to_mosaic") {
|
||||
static cv::GArrayDesc outMeta(const cv::GArrayDesc &, const cv::GArrayDesc &) {
|
||||
return cv::empty_array_desc();
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(OCVParseSSD, ParseSSD) {
|
||||
static void run(const cv::Mat &in_ssd_result,
|
||||
const cv::Mat &in_frame,
|
||||
const int filter_label,
|
||||
std::vector<cv::Rect> &out_objects) {
|
||||
const auto &in_ssd_dims = in_ssd_result.size;
|
||||
CV_Assert(in_ssd_dims.dims() == 4u);
|
||||
|
||||
const int MAX_PROPOSALS = in_ssd_dims[2];
|
||||
const int OBJECT_SIZE = in_ssd_dims[3];
|
||||
CV_Assert(OBJECT_SIZE == 7); // fixed SSD object size
|
||||
|
||||
const cv::Size upscale = in_frame.size();
|
||||
const cv::Rect surface({0,0}, upscale);
|
||||
|
||||
out_objects.clear();
|
||||
|
||||
const float *data = in_ssd_result.ptr<float>();
|
||||
for (int i = 0; i < MAX_PROPOSALS; i++) {
|
||||
const float image_id = data[i * OBJECT_SIZE + 0];
|
||||
const float label = data[i * OBJECT_SIZE + 1];
|
||||
const float confidence = data[i * OBJECT_SIZE + 2];
|
||||
const float rc_left = data[i * OBJECT_SIZE + 3];
|
||||
const float rc_top = data[i * OBJECT_SIZE + 4];
|
||||
const float rc_right = data[i * OBJECT_SIZE + 5];
|
||||
const float rc_bottom = data[i * OBJECT_SIZE + 6];
|
||||
|
||||
if (image_id < 0.f) {
|
||||
break; // marks end-of-detections
|
||||
}
|
||||
if (confidence < 0.5f) {
|
||||
continue; // skip objects with low confidence
|
||||
}
|
||||
if (filter_label != -1 && static_cast<int>(label) != filter_label) {
|
||||
continue; // filter out object classes if filter is specified
|
||||
}
|
||||
|
||||
cv::Rect rc; // map relative coordinates to the original image scale
|
||||
rc.x = static_cast<int>(rc_left * upscale.width);
|
||||
rc.y = static_cast<int>(rc_top * upscale.height);
|
||||
rc.width = static_cast<int>(rc_right * upscale.width) - rc.x;
|
||||
rc.height = static_cast<int>(rc_bottom * upscale.height) - rc.y;
|
||||
out_objects.emplace_back(rc & surface);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(OCVToMosaic, ToMosaic) {
|
||||
static void run(const std::vector<cv::Rect> &in_plate_rcs,
|
||||
const std::vector<cv::Rect> &in_face_rcs,
|
||||
std::vector<cv::gapi::wip::draw::Prim> &out_prims) {
|
||||
out_prims.clear();
|
||||
const auto cvt = [](cv::Rect rc) {
|
||||
// Align the mosaic region to mosaic block size
|
||||
const int BLOCK_SIZE = 24;
|
||||
const int dw = BLOCK_SIZE - (rc.width % BLOCK_SIZE);
|
||||
const int dh = BLOCK_SIZE - (rc.height % BLOCK_SIZE);
|
||||
rc.width += dw;
|
||||
rc.height += dh;
|
||||
rc.x -= dw / 2;
|
||||
rc.y -= dh / 2;
|
||||
return cv::gapi::wip::draw::Mosaic{rc, BLOCK_SIZE, 0};
|
||||
};
|
||||
for (auto &&rc : in_plate_rcs) { out_prims.emplace_back(cvt(rc)); }
|
||||
for (auto &&rc : in_face_rcs) { out_prims.emplace_back(cvt(rc)); }
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace custom
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
cv::CommandLineParser cmd(argc, argv, keys);
|
||||
cmd.about(about);
|
||||
if (cmd.has("help")) {
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
const std::string input = cmd.get<std::string>("input");
|
||||
const bool no_show = cmd.get<bool>("noshow");
|
||||
const bool run_trad = cmd.get<bool>("trad");
|
||||
|
||||
cv::GMat in;
|
||||
cv::GMat blob_plates = cv::gapi::infer<custom::VehLicDetector>(in);
|
||||
cv::GMat blob_faces = cv::gapi::infer<custom::FaceDetector>(in);
|
||||
// VehLicDetector from Open Model Zoo marks vehicles with label "1" and
|
||||
// license plates with label "2", filter out license plates only.
|
||||
cv::GArray<cv::Rect> rc_plates = custom::ParseSSD::on(blob_plates, in, 2);
|
||||
// Face detector produces faces only so there's no need to filter by label,
|
||||
// pass "-1".
|
||||
cv::GArray<cv::Rect> rc_faces = custom::ParseSSD::on(blob_faces, in, -1);
|
||||
cv::GMat out = cv::gapi::wip::draw::render3ch(in, custom::ToMosaic::on(rc_plates, rc_faces));
|
||||
cv::GComputation graph(in, out);
|
||||
|
||||
const auto plate_model_path = cmd.get<std::string>("platm");
|
||||
auto plate_net = cv::gapi::ie::Params<custom::VehLicDetector> {
|
||||
plate_model_path, // path to topology IR
|
||||
weights_path(plate_model_path), // path to weights
|
||||
cmd.get<std::string>("platd"), // device specifier
|
||||
};
|
||||
const auto face_model_path = cmd.get<std::string>("facem");
|
||||
auto face_net = cv::gapi::ie::Params<custom::FaceDetector> {
|
||||
face_model_path, // path to topology IR
|
||||
weights_path(face_model_path), // path to weights
|
||||
cmd.get<std::string>("faced"), // device specifier
|
||||
};
|
||||
auto kernels = cv::gapi::kernels<custom::OCVParseSSD, custom::OCVToMosaic>();
|
||||
auto networks = cv::gapi::networks(plate_net, face_net);
|
||||
|
||||
cv::TickMeter tm;
|
||||
cv::Mat out_frame;
|
||||
std::size_t frames = 0u;
|
||||
std::cout << "Reading " << input << std::endl;
|
||||
|
||||
if (run_trad) {
|
||||
cv::Mat in_frame;
|
||||
cv::VideoCapture cap(input);
|
||||
cap >> in_frame;
|
||||
|
||||
auto exec = graph.compile(cv::descr_of(in_frame), cv::compile_args(kernels, networks));
|
||||
tm.start();
|
||||
do {
|
||||
exec(in_frame, out_frame);
|
||||
if (!no_show) {
|
||||
cv::imshow("Out", out_frame);
|
||||
cv::waitKey(1);
|
||||
}
|
||||
frames++;
|
||||
} while (cap.read(in_frame));
|
||||
tm.stop();
|
||||
} else {
|
||||
auto pipeline = graph.compileStreaming(cv::compile_args(kernels, networks));
|
||||
pipeline.setSource(cv::gapi::wip::make_src<cv::gapi::wip::GCaptureSource>(input));
|
||||
pipeline.start();
|
||||
tm.start();
|
||||
|
||||
while (pipeline.pull(cv::gout(out_frame))) {
|
||||
frames++;
|
||||
if (!no_show) {
|
||||
cv::imshow("Out", out_frame);
|
||||
cv::waitKey(1);
|
||||
}
|
||||
}
|
||||
|
||||
tm.stop();
|
||||
}
|
||||
|
||||
std::cout << "Processed " << frames << " frames"
|
||||
<< " (" << frames / tm.getTimeSec() << " FPS)" << std::endl;
|
||||
return 0;
|
||||
}
|
@ -152,14 +152,11 @@ void bindInArg(Mag& mag, const RcDesc &rc, const GRunArg &arg, bool is_umat)
|
||||
|
||||
case GShape::GSCALAR:
|
||||
{
|
||||
auto& mag_scalar = mag.template slot<cv::gapi::own::Scalar>()[rc.id];
|
||||
auto& mag_scalar = mag.template slot<cv::Scalar>()[rc.id];
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArg::index_of<cv::gapi::own::Scalar>() : mag_scalar = util::get<cv::gapi::own::Scalar>(arg); break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Scalar>() : mag_scalar = to_own(util::get<cv::Scalar>(arg)); break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
case GRunArg::index_of<cv::Scalar>() : mag_scalar = util::get<cv::Scalar>(arg); break;
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -168,6 +165,10 @@ void bindInArg(Mag& mag, const RcDesc &rc, const GRunArg &arg, bool is_umat)
|
||||
mag.template slot<cv::detail::VectorRef>()[rc.id] = util::get<cv::detail::VectorRef>(arg);
|
||||
break;
|
||||
|
||||
case GShape::GOPAQUE:
|
||||
mag.template slot<cv::detail::OpaqueRef>()[rc.id] = util::get<cv::detail::OpaqueRef>(arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
}
|
||||
@ -218,14 +219,11 @@ void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg, bool is_umat)
|
||||
|
||||
case GShape::GSCALAR:
|
||||
{
|
||||
auto& mag_scalar = mag.template slot<cv::gapi::own::Scalar>()[rc.id];
|
||||
auto& mag_scalar = mag.template slot<cv::Scalar>()[rc.id];
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Scalar*>() : mag_scalar = *util::get<cv::gapi::own::Scalar*>(arg); break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Scalar*>() : mag_scalar = to_own(*util::get<cv::Scalar*>(arg)); break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
case GRunArgP::index_of<cv::Scalar*>() : mag_scalar = *util::get<cv::Scalar*>(arg); break;
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -233,6 +231,10 @@ void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg, bool is_umat)
|
||||
mag.template slot<cv::detail::VectorRef>()[rc.id] = util::get<cv::detail::VectorRef>(arg);
|
||||
break;
|
||||
|
||||
case GShape::GOPAQUE:
|
||||
mag.template slot<cv::detail::OpaqueRef>()[rc.id] = util::get<cv::detail::OpaqueRef>(arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
break;
|
||||
@ -251,8 +253,13 @@ void resetInternalData(Mag& mag, const Data &d)
|
||||
(mag.template slot<cv::detail::VectorRef>()[d.rc]);
|
||||
break;
|
||||
|
||||
case GShape::GOPAQUE:
|
||||
util::get<cv::detail::ConstructOpaque>(d.ctor)
|
||||
(mag.template slot<cv::detail::OpaqueRef>()[d.rc]);
|
||||
break;
|
||||
|
||||
case GShape::GSCALAR:
|
||||
mag.template slot<cv::gapi::own::Scalar>()[d.rc] = cv::gapi::own::Scalar();
|
||||
mag.template slot<cv::Scalar>()[d.rc] = cv::Scalar();
|
||||
break;
|
||||
|
||||
case GShape::GMAT:
|
||||
@ -271,10 +278,11 @@ cv::GRunArg getArg(const Mag& mag, const RcDesc &ref)
|
||||
switch (ref.shape)
|
||||
{
|
||||
case GShape::GMAT: return GRunArg(mag.template slot<cv::gapi::own::Mat>().at(ref.id));
|
||||
case GShape::GSCALAR: return GRunArg(mag.template slot<cv::gapi::own::Scalar>().at(ref.id));
|
||||
// Note: .at() is intentional for GArray as object MUST be already there
|
||||
case GShape::GSCALAR: return GRunArg(mag.template slot<cv::Scalar>().at(ref.id));
|
||||
// Note: .at() is intentional for GArray and GOpaque as objects MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
case GShape::GARRAY: return GRunArg(mag.template slot<cv::detail::VectorRef>().at(ref.id));
|
||||
case GShape::GOPAQUE: return GRunArg(mag.template slot<cv::detail::OpaqueRef>().at(ref.id));
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
break;
|
||||
@ -296,8 +304,8 @@ cv::GRunArgP getObjPtr(Mag& mag, const RcDesc &rc, bool is_umat)
|
||||
}
|
||||
else
|
||||
return GRunArgP(&mag.template slot<cv::gapi::own::Mat>()[rc.id]);
|
||||
case GShape::GSCALAR: return GRunArgP(&mag.template slot<cv::gapi::own::Scalar>()[rc.id]);
|
||||
// Note: .at() is intentional for GArray as object MUST be already there
|
||||
case GShape::GSCALAR: return GRunArgP(&mag.template slot<cv::Scalar>()[rc.id]);
|
||||
// Note: .at() is intentional for GArray and GOpaque as objects MUST be already there
|
||||
// (and constructor by either bindIn/Out or resetInternal)
|
||||
case GShape::GARRAY:
|
||||
// FIXME(DM): For some absolutely unknown to me reason, move
|
||||
@ -307,6 +315,14 @@ cv::GRunArgP getObjPtr(Mag& mag, const RcDesc &rc, bool is_umat)
|
||||
// debugging this!!!1
|
||||
return GRunArgP(const_cast<const Mag&>(mag)
|
||||
.template slot<cv::detail::VectorRef>().at(rc.id));
|
||||
case GShape::GOPAQUE:
|
||||
// FIXME(DM): For some absolutely unknown to me reason, move
|
||||
// semantics is involved here without const_cast to const (and
|
||||
// value from map is moved into return value GRunArgP, leaving
|
||||
// map with broken value I've spent few late Friday hours
|
||||
// debugging this!!!1
|
||||
return GRunArgP(const_cast<const Mag&>(mag)
|
||||
.template slot<cv::detail::OpaqueRef>().at(rc.id));
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
break;
|
||||
@ -320,6 +336,9 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg, bool is_umat)
|
||||
case GShape::GARRAY:
|
||||
// Do nothing - should we really do anything here?
|
||||
break;
|
||||
case GShape::GOPAQUE:
|
||||
// Do nothing - should we really do anything here?
|
||||
break;
|
||||
|
||||
case GShape::GMAT:
|
||||
{
|
||||
@ -356,11 +375,8 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg, bool is_umat)
|
||||
{
|
||||
switch (g_arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Scalar*>() : *util::get<cv::gapi::own::Scalar*>(g_arg) = mag.template slot<cv::gapi::own::Scalar>().at(rc.id); break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Scalar*>() : *util::get<cv::Scalar*>(g_arg) = cv::gapi::own::to_ocv(mag.template slot<cv::gapi::own::Scalar>().at(rc.id)); break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
case GRunArgP::index_of<cv::Scalar*>() : *util::get<cv::Scalar*>(g_arg) = mag.template slot<cv::Scalar>().at(rc.id); break;
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -379,7 +395,7 @@ void createMat(const cv::GMatDesc &desc, cv::gapi::own::Mat& mat)
|
||||
if (desc.dims.empty())
|
||||
{
|
||||
const auto type = desc.planar ? desc.depth : CV_MAKETYPE(desc.depth, desc.chan);
|
||||
const auto size = desc.planar ? cv::gapi::own::Size{desc.size.width, desc.size.height*desc.chan}
|
||||
const auto size = desc.planar ? cv::Size{desc.size.width, desc.size.height*desc.chan}
|
||||
: desc.size;
|
||||
mat.create(size, type);
|
||||
}
|
||||
@ -398,7 +414,7 @@ void createMat(const cv::GMatDesc &desc, cv::Mat& mat)
|
||||
{
|
||||
const auto type = desc.planar ? desc.depth : CV_MAKETYPE(desc.depth, desc.chan);
|
||||
const auto size = desc.planar ? cv::Size{desc.size.width, desc.size.height*desc.chan}
|
||||
: cv::gapi::own::to_ocv(desc.size);
|
||||
: desc.size;
|
||||
mat.create(size, type);
|
||||
}
|
||||
else
|
||||
|
@ -64,6 +64,11 @@ cv::detail::GArrayU cv::GCall::yieldArray(int output)
|
||||
return cv::detail::GArrayU(m_priv->m_node, output);
|
||||
}
|
||||
|
||||
cv::detail::GOpaqueU cv::GCall::yieldOpaque(int output)
|
||||
{
|
||||
return cv::detail::GOpaqueU(m_priv->m_node, output);
|
||||
}
|
||||
|
||||
cv::GCall::Priv& cv::GCall::priv()
|
||||
{
|
||||
return *m_priv;
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <ade/util/iota_range.hpp>
|
||||
#include <ade/util/algorithm.hpp>
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp> //gapi::own::Mat
|
||||
#include <opencv2/gapi/gmat.hpp>
|
||||
|
||||
|
45
inference-engine/thirdparty/fluid/modules/gapi/src/api/gopaque.cpp
vendored
Normal file
45
inference-engine/thirdparty/fluid/modules/gapi/src/api/gopaque.cpp
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
#include "api/gorigin.hpp"
|
||||
|
||||
// cv::detail::GOpaqueU public implementation ///////////////////////////////////
|
||||
cv::detail::GOpaqueU::GOpaqueU()
|
||||
: m_priv(new GOrigin(GShape::GOPAQUE, cv::GNode::Param()))
|
||||
{
|
||||
}
|
||||
|
||||
cv::detail::GOpaqueU::GOpaqueU(const GNode &n, std::size_t out)
|
||||
: m_priv(new GOrigin(GShape::GOPAQUE, n, out))
|
||||
{
|
||||
}
|
||||
|
||||
cv::GOrigin& cv::detail::GOpaqueU::priv()
|
||||
{
|
||||
return *m_priv;
|
||||
}
|
||||
|
||||
const cv::GOrigin& cv::detail::GOpaqueU::priv() const
|
||||
{
|
||||
return *m_priv;
|
||||
}
|
||||
|
||||
void cv::detail::GOpaqueU::setConstructFcn(ConstructOpaque &&co)
|
||||
{
|
||||
m_priv->ctor = std::move(co);
|
||||
}
|
||||
|
||||
namespace cv {
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GOpaqueDesc &)
|
||||
{
|
||||
// FIXME: add type information here
|
||||
os << "(Opaque)";
|
||||
return os;
|
||||
}
|
||||
}
|
@ -34,6 +34,9 @@ const cv::GOrigin& cv::gimpl::proto::origin_of(const cv::GProtoArg &arg)
|
||||
case cv::GProtoArg::index_of<cv::detail::GArrayU>():
|
||||
return util::get<cv::detail::GArrayU>(arg).priv();
|
||||
|
||||
case cv::GProtoArg::index_of<cv::detail::GOpaqueU>():
|
||||
return util::get<cv::detail::GOpaqueU>(arg).priv();
|
||||
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GProtoArg type"));
|
||||
}
|
||||
@ -59,6 +62,7 @@ bool cv::gimpl::proto::is_dynamic(const cv::GArg& arg)
|
||||
case detail::ArgKind::GMATP:
|
||||
case detail::ArgKind::GSCALAR:
|
||||
case detail::ArgKind::GARRAY:
|
||||
case detail::ArgKind::GOPAQUE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
@ -70,7 +74,7 @@ cv::GRunArg cv::value_of(const cv::GOrigin &origin)
|
||||
{
|
||||
switch (origin.shape)
|
||||
{
|
||||
case GShape::GSCALAR: return GRunArg(util::get<cv::gapi::own::Scalar>(origin.value));
|
||||
case GShape::GSCALAR: return GRunArg(util::get<cv::Scalar>(origin.value));
|
||||
default: util::throw_error(std::logic_error("Unsupported shape for constant"));
|
||||
}
|
||||
}
|
||||
@ -85,6 +89,7 @@ cv::GProtoArg cv::gimpl::proto::rewrap(const cv::GArg &arg)
|
||||
case detail::ArgKind::GMATP: return GProtoArg(arg.get<cv::GMatP>());
|
||||
case detail::ArgKind::GSCALAR: return GProtoArg(arg.get<cv::GScalar>());
|
||||
case detail::ArgKind::GARRAY: return GProtoArg(arg.get<cv::detail::GArrayU>());
|
||||
case detail::ArgKind::GOPAQUE: return GProtoArg(arg.get<cv::detail::GOpaqueU>());
|
||||
default: util::throw_error(std::logic_error("Unsupported GArg type"));
|
||||
}
|
||||
}
|
||||
@ -97,19 +102,20 @@ cv::GMetaArg cv::descr_of(const cv::GRunArg &arg)
|
||||
case GRunArg::index_of<cv::Mat>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::Mat>(arg)));
|
||||
|
||||
case GRunArg::index_of<cv::Scalar>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::Scalar>(arg)));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::gapi::own::Mat>(arg)));
|
||||
|
||||
case GRunArg::index_of<cv::gapi::own::Scalar>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::gapi::own::Scalar>(arg)));
|
||||
case GRunArg::index_of<cv::Scalar>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::Scalar>(arg)));
|
||||
|
||||
case GRunArg::index_of<cv::detail::VectorRef>():
|
||||
return cv::GMetaArg(util::get<cv::detail::VectorRef>(arg).descr_of());
|
||||
|
||||
case GRunArg::index_of<cv::detail::OpaqueRef>():
|
||||
return cv::GMetaArg(util::get<cv::detail::OpaqueRef>(arg).descr_of());
|
||||
|
||||
case GRunArg::index_of<cv::gapi::wip::IStreamSource::Ptr>():
|
||||
return cv::util::get<cv::gapi::wip::IStreamSource::Ptr>(arg)->descr_of();
|
||||
|
||||
@ -131,11 +137,11 @@ cv::GMetaArg cv::descr_of(const cv::GRunArgP &argp)
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>(): return GMetaArg(descr_of(*util::get<cv::Mat*>(argp)));
|
||||
case GRunArgP::index_of<cv::UMat*>(): return GMetaArg(descr_of(*util::get<cv::UMat*>(argp)));
|
||||
case GRunArgP::index_of<cv::Scalar*>(): return GMetaArg(descr_of(*util::get<cv::Scalar*>(argp)));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>(): return GMetaArg(descr_of(*util::get<cv::gapi::own::Mat*>(argp)));
|
||||
case GRunArgP::index_of<cv::gapi::own::Scalar*>(): return GMetaArg(descr_of(*util::get<cv::gapi::own::Scalar*>(argp)));
|
||||
case GRunArgP::index_of<cv::detail::VectorRef>(): return GMetaArg(util::get<cv::detail::VectorRef>(argp).descr_of());
|
||||
case GRunArgP::index_of<cv::Scalar*>(): return GMetaArg(descr_of(*util::get<cv::Scalar*>(argp)));
|
||||
case GRunArgP::index_of<cv::detail::VectorRef>(): return GMetaArg(util::get<cv::detail::VectorRef>(argp).descr_of());
|
||||
case GRunArgP::index_of<cv::detail::OpaqueRef>(): return GMetaArg(util::get<cv::detail::OpaqueRef>(argp).descr_of());
|
||||
default: util::throw_error(std::logic_error("Unsupported GRunArgP type"));
|
||||
}
|
||||
}
|
||||
@ -148,12 +154,12 @@ bool cv::can_describe(const GMetaArg& meta, const GRunArgP& argp)
|
||||
case GRunArgP::index_of<cv::Mat*>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(*util::get<cv::Mat*>(argp));
|
||||
case GRunArgP::index_of<cv::UMat*>(): return meta == GMetaArg(descr_of(*util::get<cv::UMat*>(argp)));
|
||||
case GRunArgP::index_of<cv::Scalar*>(): return meta == GMetaArg(descr_of(*util::get<cv::Scalar*>(argp)));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(*util::get<cv::gapi::own::Mat*>(argp));
|
||||
case GRunArgP::index_of<cv::gapi::own::Scalar*>(): return meta == GMetaArg(descr_of(*util::get<cv::gapi::own::Scalar*>(argp)));
|
||||
case GRunArgP::index_of<cv::Scalar*>(): return meta == GMetaArg(descr_of(*util::get<cv::Scalar*>(argp)));
|
||||
case GRunArgP::index_of<cv::detail::VectorRef>(): return meta == GMetaArg(util::get<cv::detail::VectorRef>(argp).descr_of());
|
||||
case GRunArgP::index_of<cv::detail::OpaqueRef>(): return meta == GMetaArg(util::get<cv::detail::OpaqueRef>(argp).descr_of());
|
||||
default: util::throw_error(std::logic_error("Unsupported GRunArgP type"));
|
||||
}
|
||||
}
|
||||
@ -166,12 +172,12 @@ bool cv::can_describe(const GMetaArg& meta, const GRunArg& arg)
|
||||
case GRunArg::index_of<cv::Mat>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(util::get<cv::Mat>(arg));
|
||||
case GRunArg::index_of<cv::UMat>(): return meta == cv::GMetaArg(descr_of(util::get<cv::UMat>(arg)));
|
||||
case GRunArg::index_of<cv::Scalar>(): return meta == cv::GMetaArg(descr_of(util::get<cv::Scalar>(arg)));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(util::get<cv::gapi::own::Mat>(arg));
|
||||
case GRunArg::index_of<cv::gapi::own::Scalar>(): return meta == cv::GMetaArg(descr_of(util::get<cv::gapi::own::Scalar>(arg)));
|
||||
case GRunArg::index_of<cv::Scalar>(): return meta == cv::GMetaArg(descr_of(util::get<cv::Scalar>(arg)));
|
||||
case GRunArg::index_of<cv::detail::VectorRef>(): return meta == cv::GMetaArg(util::get<cv::detail::VectorRef>(arg).descr_of());
|
||||
case GRunArg::index_of<cv::detail::OpaqueRef>(): return meta == cv::GMetaArg(util::get<cv::detail::OpaqueRef>(arg).descr_of());
|
||||
case GRunArg::index_of<cv::gapi::wip::IStreamSource::Ptr>(): return util::holds_alternative<GMatDesc>(meta); // FIXME(?) may be not the best option
|
||||
default: util::throw_error(std::logic_error("Unsupported GRunArg type"));
|
||||
}
|
||||
@ -186,6 +192,42 @@ bool cv::can_describe(const GMetaArgs &metas, const GRunArgs &args)
|
||||
});
|
||||
}
|
||||
|
||||
void cv::validate_input_arg(const GRunArg& arg)
|
||||
{
|
||||
// FIXME: It checks only Mat argument
|
||||
switch (arg.index())
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>():
|
||||
{
|
||||
const auto desc = descr_of(util::get<cv::Mat>(arg));
|
||||
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of cv::Mat!"); break;
|
||||
}
|
||||
case GRunArg::index_of<cv::UMat>():
|
||||
{
|
||||
const auto desc = descr_of(util::get<cv::UMat>(arg));
|
||||
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of cv::UMat!"); break;
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>():
|
||||
{
|
||||
const auto desc = descr_of(util::get<cv::gapi::own::Mat>(arg));
|
||||
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of own::Mat!"); break;
|
||||
}
|
||||
default:
|
||||
// No extra handling
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void cv::validate_input_args(const GRunArgs& args)
|
||||
{
|
||||
for (const auto& arg : args)
|
||||
{
|
||||
validate_input_arg(arg);
|
||||
}
|
||||
}
|
||||
|
||||
namespace cv {
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GMetaArg &arg)
|
||||
{
|
||||
@ -207,6 +249,10 @@ std::ostream& operator<<(std::ostream& os, const cv::GMetaArg &arg)
|
||||
case cv::GMetaArg::index_of<cv::GArrayDesc>():
|
||||
os << util::get<cv::GArrayDesc>(arg);
|
||||
break;
|
||||
|
||||
case cv::GMetaArg::index_of<cv::GOpaqueDesc>():
|
||||
os << util::get<cv::GOpaqueDesc>(arg);
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
}
|
||||
|
@ -22,18 +22,18 @@ cv::GScalar::GScalar(const GNode &n, std::size_t out)
|
||||
{
|
||||
}
|
||||
|
||||
cv::GScalar::GScalar(const cv::gapi::own::Scalar& s)
|
||||
cv::GScalar::GScalar(const cv::Scalar& s)
|
||||
: m_priv(new GOrigin(GShape::GSCALAR, cv::gimpl::ConstVal(s)))
|
||||
{
|
||||
}
|
||||
|
||||
cv::GScalar::GScalar(cv::gapi::own::Scalar&& s)
|
||||
cv::GScalar::GScalar(cv::Scalar&& s)
|
||||
: m_priv(new GOrigin(GShape::GSCALAR, cv::gimpl::ConstVal(std::move(s))))
|
||||
{
|
||||
}
|
||||
|
||||
cv::GScalar::GScalar(double v0)
|
||||
: m_priv(new GOrigin(GShape::GSCALAR, cv::gimpl::ConstVal(cv::gapi::own::Scalar(v0))))
|
||||
: m_priv(new GOrigin(GShape::GSCALAR, cv::gimpl::ConstVal(cv::Scalar(v0))))
|
||||
{
|
||||
}
|
||||
|
||||
@ -47,23 +47,11 @@ const cv::GOrigin& cv::GScalar::priv() const
|
||||
return *m_priv;
|
||||
}
|
||||
|
||||
cv::GScalarDesc cv::descr_of(const cv::gapi::own::Scalar &)
|
||||
cv::GScalarDesc cv::descr_of(const cv::Scalar &)
|
||||
{
|
||||
return empty_scalar_desc();
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::GScalar::GScalar(const cv::Scalar& s)
|
||||
: m_priv(new GOrigin(GShape::GSCALAR, cv::gimpl::ConstVal(to_own(s))))
|
||||
{
|
||||
}
|
||||
|
||||
cv::GScalarDesc cv::descr_of(const cv::Scalar& s)
|
||||
{
|
||||
return cv::descr_of(to_own(s));
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
namespace cv {
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GScalarDesc &)
|
||||
{
|
||||
|
@ -371,5 +371,17 @@ GMat normalize(const GMat& _src, double a, double b,
|
||||
return core::GNormalize::on(_src, a, b, norm_type, ddepth);
|
||||
}
|
||||
|
||||
GMat warpPerspective(const GMat& src, const Mat& M, const Size& dsize, int flags,
|
||||
int borderMode, const Scalar& borderValue)
|
||||
{
|
||||
return core::GWarpPerspective::on(src, M, dsize, flags, borderMode, borderValue);
|
||||
}
|
||||
|
||||
GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, int flags,
|
||||
int borderMode, const Scalar& borderValue)
|
||||
{
|
||||
return core::GWarpAffine::on(src, M, dsize, flags, borderMode, borderValue);
|
||||
}
|
||||
|
||||
} //namespace gapi
|
||||
} //namespace cv
|
||||
|
@ -157,18 +157,26 @@ GMat RGB2Lab(const GMat& src)
|
||||
return imgproc::GRGB2Lab::on(src);
|
||||
}
|
||||
|
||||
GMat BayerGR2RGB(const GMat& src_gr) {
|
||||
GMat BayerGR2RGB(const GMat& src_gr)
|
||||
{
|
||||
return imgproc::GBayerGR2RGB::on(src_gr);
|
||||
}
|
||||
|
||||
GMat RGB2HSV(const GMat& src) {
|
||||
GMat RGB2HSV(const GMat& src)
|
||||
{
|
||||
return imgproc::GRGB2HSV::on(src);
|
||||
}
|
||||
|
||||
GMat RGB2YUV422(const GMat& src) {
|
||||
GMat RGB2YUV422(const GMat& src)
|
||||
{
|
||||
return imgproc::GRGB2YUV422::on(src);
|
||||
}
|
||||
|
||||
GMat NV12toGray(const GMat &y, const GMat &uv)
|
||||
{
|
||||
return imgproc::GNV12toGray::on(y, uv);
|
||||
}
|
||||
|
||||
GMatP NV12toRGBp(const GMat &y, const GMat &uv)
|
||||
{
|
||||
return imgproc::GNV12toRGBp::on(y, uv);
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <opencv2/gapi/render/render.hpp>
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
|
||||
|
@ -167,27 +167,11 @@ void drawPrimitivesOCV(cv::Mat& in,
|
||||
break;
|
||||
}
|
||||
|
||||
// FIXME avoid code duplicate for Text and FText
|
||||
case Prim::index_of<Text>():
|
||||
{
|
||||
auto tp = cv::util::get<Text>(p);
|
||||
tp.color = converter.cvtColor(tp.color);
|
||||
|
||||
int baseline = 0;
|
||||
auto size = cv::getTextSize(tp.text, tp.ff, tp.fs, tp.thick, &baseline);
|
||||
baseline += tp.thick;
|
||||
size.height += baseline;
|
||||
|
||||
// Allocate mask outside
|
||||
cv::Mat mask(size, CV_8UC1, cv::Scalar::all(0));
|
||||
// Org it's bottom left position for baseline
|
||||
cv::Point org(0, mask.rows - baseline);
|
||||
cv::putText(mask, tp.text, org, tp.ff, tp.fs, 255, tp.thick);
|
||||
|
||||
// Org is bottom left point, transform it to top left point for blendImage
|
||||
cv::Point tl(tp.org.x, tp.org.y - mask.size().height + baseline);
|
||||
|
||||
blendTextMask(in, mask, tl, tp.color);
|
||||
cv::putText(in, tp.text, tp.org, tp.ff, tp.fs, tp.color, tp.thick, tp.lt, tp.bottom_left_origin);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "opencv2/gapi/own/mat.hpp"
|
||||
|
||||
#include "opencv2/gapi/util/optional.hpp"
|
||||
#include "opencv2/gapi/own/scalar.hpp"
|
||||
|
||||
#include "compiler/gmodel.hpp"
|
||||
|
||||
@ -46,9 +45,9 @@ namespace magazine {
|
||||
|
||||
} // namespace magazine
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
using Mag = magazine::Class<cv::gapi::own::Mat, cv::UMat, cv::gapi::own::Scalar, cv::detail::VectorRef>;
|
||||
using Mag = magazine::Class<cv::gapi::own::Mat, cv::UMat, cv::Scalar, cv::detail::VectorRef, cv::detail::OpaqueRef>;
|
||||
#else
|
||||
using Mag = magazine::Class<cv::gapi::own::Mat, cv::gapi::own::Scalar, cv::detail::VectorRef>;
|
||||
using Mag = magazine::Class<cv::gapi::own::Mat, cv::Scalar, cv::detail::VectorRef, cv::detail::OpaqueRef>;
|
||||
#endif
|
||||
|
||||
namespace magazine
|
||||
|
@ -113,7 +113,8 @@ cv::GArg cv::gimpl::GCPUExecutable::packArg(const GArg &arg)
|
||||
// FIXME: this check has to be done somewhere in compilation stage.
|
||||
GAPI_Assert( arg.kind != cv::detail::ArgKind::GMAT
|
||||
&& arg.kind != cv::detail::ArgKind::GSCALAR
|
||||
&& arg.kind != cv::detail::ArgKind::GARRAY);
|
||||
&& arg.kind != cv::detail::ArgKind::GARRAY
|
||||
&& arg.kind != cv::detail::ArgKind::GOPAQUE);
|
||||
|
||||
if (arg.kind != cv::detail::ArgKind::GOBJREF)
|
||||
{
|
||||
@ -128,10 +129,11 @@ cv::GArg cv::gimpl::GCPUExecutable::packArg(const GArg &arg)
|
||||
switch (ref.shape)
|
||||
{
|
||||
case GShape::GMAT: return GArg(m_res.slot<cv::gapi::own::Mat>() [ref.id]);
|
||||
case GShape::GSCALAR: return GArg(m_res.slot<cv::gapi::own::Scalar>()[ref.id]);
|
||||
// Note: .at() is intentional for GArray as object MUST be already there
|
||||
case GShape::GSCALAR: return GArg(m_res.slot<cv::Scalar>()[ref.id]);
|
||||
// Note: .at() is intentional for GArray and GOpaque as objects MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
case GShape::GARRAY: return GArg(m_res.slot<cv::detail::VectorRef>().at(ref.id));
|
||||
case GShape::GOPAQUE: return GArg(m_res.slot<cv::detail::OpaqueRef>().at(ref.id));
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
break;
|
||||
|
@ -558,6 +558,25 @@ GAPI_OCV_KERNEL(GCPUNormalize, cv::gapi::core::GNormalize)
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUWarpPerspective, cv::gapi::core::GWarpPerspective)
|
||||
{
|
||||
static void run(const cv::Mat& src, const cv::Mat& M, const cv::Size& dsize,
|
||||
int flags, int borderMode, const cv::Scalar& borderValue, cv::Mat& out)
|
||||
{
|
||||
cv::warpPerspective(src, out, M, dsize, flags, borderMode, borderValue);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUWarpAffine, cv::gapi::core::GWarpAffine)
|
||||
{
|
||||
static void run(const cv::Mat& src, const cv::Mat& M, const cv::Size& dsize,
|
||||
int flags, int borderMode, const cv::Scalar& borderValue, cv::Mat& out)
|
||||
{
|
||||
cv::warpAffine(src, out, M, dsize, flags, borderMode, borderValue);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
cv::gapi::GKernelPackage cv::gapi::core::cpu::kernels()
|
||||
{
|
||||
static auto pkg = cv::gapi::kernels
|
||||
@ -626,6 +645,8 @@ cv::gapi::GKernelPackage cv::gapi::core::cpu::kernels()
|
||||
, GCPUConvertTo
|
||||
, GCPUSqrt
|
||||
, GCPUNormalize
|
||||
, GCPUWarpPerspective
|
||||
, GCPUWarpAffine
|
||||
>();
|
||||
return pkg;
|
||||
}
|
||||
|
@ -10,9 +10,11 @@
|
||||
#include <opencv2/gapi/imgproc.hpp>
|
||||
#include <opencv2/gapi/cpu/imgproc.hpp>
|
||||
#include <opencv2/gapi/cpu/gcpukernel.hpp>
|
||||
#include <opencv2/gapi/gcompoundkernel.hpp>
|
||||
|
||||
#include "backends/fluid/gfluidimgproc_func.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
cv::Mat add_border(const cv::Mat& in, const int ksize, const int borderType, const cv::Scalar& bordVal){
|
||||
if( borderType == cv::BORDER_CONSTANT )
|
||||
@ -335,6 +337,57 @@ GAPI_OCV_KERNEL(GCPUNV12toRGBp, cv::gapi::imgproc::GNV12toRGBp)
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GYUV2Gray, <cv::GMat(cv::GMat)>, "yuvtogray") {
|
||||
static cv::GMatDesc outMeta(cv::GMatDesc in) {
|
||||
GAPI_Assert(in.depth == CV_8U);
|
||||
GAPI_Assert(in.planar == false);
|
||||
GAPI_Assert(in.size.width % 2 == 0);
|
||||
GAPI_Assert(in.size.height % 3 == 0);
|
||||
|
||||
/* YUV format for this kernel:
|
||||
* Y Y Y Y Y Y Y Y
|
||||
* Y Y Y Y Y Y Y Y
|
||||
* Y Y Y Y Y Y Y Y
|
||||
* Y Y Y Y Y Y Y Y
|
||||
* U V U V U V U V
|
||||
* U V U V U V U V
|
||||
*/
|
||||
|
||||
return {CV_8U, 1, cv::Size{in.size.width, in.size.height - (in.size.height / 3)}, false};
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUYUV2Gray, GYUV2Gray)
|
||||
{
|
||||
static void run(const cv::Mat& in, cv::Mat& out)
|
||||
{
|
||||
cv::cvtColor(in, out, cv::COLOR_YUV2GRAY_NV12);
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GConcatYUVPlanes, <cv::GMat(cv::GMat, cv::GMat)>, "concatyuvplanes") {
|
||||
static cv::GMatDesc outMeta(cv::GMatDesc y, cv::GMatDesc uv) {
|
||||
return {CV_8U, 1, cv::Size{y.size.width, y.size.height + uv.size.height}, false};
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUConcatYUVPlanes, GConcatYUVPlanes)
|
||||
{
|
||||
static void run(const cv::Mat& in_y, const cv::Mat& in_uv, cv::Mat& out)
|
||||
{
|
||||
cv::Mat uv_planar(in_uv.rows, in_uv.cols * 2, CV_8UC1, in_uv.data);
|
||||
cv::vconcat(in_y, uv_planar, out);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_COMPOUND_KERNEL(GCPUNV12toGray, cv::gapi::imgproc::GNV12toGray)
|
||||
{
|
||||
static cv::GMat expand(cv::GMat y, cv::GMat uv)
|
||||
{
|
||||
return GYUV2Gray::on(GConcatYUVPlanes::on(y, uv));
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUNV12toBGRp, cv::gapi::imgproc::GNV12toBGRp)
|
||||
{
|
||||
static void run(const cv::Mat& inY, const cv::Mat& inUV, cv::Mat& out)
|
||||
@ -345,7 +398,6 @@ GAPI_OCV_KERNEL(GCPUNV12toBGRp, cv::gapi::imgproc::GNV12toBGRp)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
cv::gapi::GKernelPackage cv::gapi::imgproc::cpu::kernels()
|
||||
{
|
||||
static auto pkg = cv::gapi::kernels
|
||||
@ -376,8 +428,11 @@ cv::gapi::GKernelPackage cv::gapi::imgproc::cpu::kernels()
|
||||
, GCPUBayerGR2RGB
|
||||
, GCPURGB2HSV
|
||||
, GCPURGB2YUV422
|
||||
, GCPUYUV2Gray
|
||||
, GCPUNV12toRGBp
|
||||
, GCPUNV12toBGRp
|
||||
, GCPUNV12toGray
|
||||
, GCPUConcatYUVPlanes
|
||||
>();
|
||||
return pkg;
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ cv::gapi::own::Mat& cv::GCPUContext::outMatR(int output)
|
||||
return *util::get<cv::gapi::own::Mat*>(m_results.at(output));
|
||||
}
|
||||
|
||||
const cv::gapi::own::Scalar& cv::GCPUContext::inVal(int input)
|
||||
const cv::Scalar& cv::GCPUContext::inVal(int input)
|
||||
{
|
||||
return inArg<cv::gapi::own::Scalar>(input);
|
||||
return inArg<cv::Scalar>(input);
|
||||
}
|
||||
|
||||
cv::gapi::own::Scalar& cv::GCPUContext::outValR(int output)
|
||||
cv::Scalar& cv::GCPUContext::outValR(int output)
|
||||
{
|
||||
return *util::get<cv::gapi::own::Scalar*>(m_results.at(output));
|
||||
return *util::get<cv::Scalar*>(m_results.at(output));
|
||||
}
|
||||
|
||||
cv::detail::VectorRef& cv::GCPUContext::outVecRef(int output)
|
||||
@ -36,6 +36,11 @@ cv::detail::VectorRef& cv::GCPUContext::outVecRef(int output)
|
||||
return util::get<cv::detail::VectorRef>(m_results.at(output));
|
||||
}
|
||||
|
||||
cv::detail::OpaqueRef& cv::GCPUContext::outOpaqueRef(int output)
|
||||
{
|
||||
return util::get<cv::detail::OpaqueRef>(m_results.at(output));
|
||||
}
|
||||
|
||||
cv::GCPUKernel::GCPUKernel()
|
||||
{
|
||||
}
|
||||
|
@ -14,10 +14,6 @@
|
||||
#include <unordered_set>
|
||||
#include <stack>
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ <= 5)
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include <ade/util/algorithm.hpp>
|
||||
#include <ade/util/chain_range.hpp>
|
||||
#include <ade/util/iota_range.hpp>
|
||||
@ -558,8 +554,8 @@ void cv::gimpl::FluidAgent::debug(std::ostream &os)
|
||||
// GCPUExcecutable implementation //////////////////////////////////////////////
|
||||
|
||||
void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
std::vector<cv::gapi::own::Rect>& rois,
|
||||
const std::vector<cv::gapi::own::Rect>& out_rois)
|
||||
std::vector<cv::Rect>& rois,
|
||||
const std::vector<cv::Rect>& out_rois)
|
||||
{
|
||||
GConstFluidModel fg(m_g);
|
||||
auto proto = m_gm.metadata().get<Protocol>();
|
||||
@ -596,9 +592,9 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
readStarts[id] = 0;
|
||||
|
||||
const auto& out_roi = out_rois[idx];
|
||||
if (out_roi == gapi::own::Rect{})
|
||||
if (out_roi == cv::Rect{})
|
||||
{
|
||||
rois[id] = gapi::own::Rect{ 0, 0, desc.size.width, desc.size.height };
|
||||
rois[id] = cv::Rect{ 0, 0, desc.size.width, desc.size.height };
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -643,14 +639,14 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
const auto& in_meta = util::get<GMatDesc>(in_data.meta);
|
||||
const auto& fd = fg.metadata(in_node).get<FluidData>();
|
||||
|
||||
auto adjFilterRoi = [](cv::gapi::own::Rect produced, int b, int max_height) {
|
||||
auto adjFilterRoi = [](cv::Rect produced, int b, int max_height) {
|
||||
// Extend with border roi which should be produced, crop to logical image size
|
||||
cv::gapi::own::Rect roi = {produced.x, produced.y - b, produced.width, produced.height + 2*b};
|
||||
cv::gapi::own::Rect fullImg{ 0, 0, produced.width, max_height };
|
||||
cv::Rect roi = {produced.x, produced.y - b, produced.width, produced.height + 2*b};
|
||||
cv::Rect fullImg{ 0, 0, produced.width, max_height };
|
||||
return roi & fullImg;
|
||||
};
|
||||
|
||||
auto adjResizeRoi = [](cv::gapi::own::Rect produced, cv::gapi::own::Size inSz, cv::gapi::own::Size outSz) {
|
||||
auto adjResizeRoi = [](cv::Rect produced, cv::Size inSz, cv::Size outSz) {
|
||||
auto map = [](int outCoord, int producedSz, int inSize, int outSize) {
|
||||
double ratio = (double)inSize / outSize;
|
||||
int w0 = 0, w1 = 0;
|
||||
@ -675,30 +671,30 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
auto x0 = mapX.first;
|
||||
auto x1 = mapX.second;
|
||||
|
||||
cv::gapi::own::Rect roi = {x0, y0, x1 - x0, y1 - y0};
|
||||
cv::Rect roi = {x0, y0, x1 - x0, y1 - y0};
|
||||
return roi;
|
||||
};
|
||||
|
||||
auto adj420Roi = [&](cv::gapi::own::Rect produced, std::size_t port) {
|
||||
auto adj420Roi = [&](cv::Rect produced, std::size_t port) {
|
||||
GAPI_Assert(produced.x % 2 == 0);
|
||||
GAPI_Assert(produced.y % 2 == 0);
|
||||
GAPI_Assert(produced.width % 2 == 0);
|
||||
GAPI_Assert(produced.height % 2 == 0);
|
||||
|
||||
cv::gapi::own::Rect roi;
|
||||
cv::Rect roi;
|
||||
switch (port) {
|
||||
case 0: roi = produced; break;
|
||||
case 1:
|
||||
case 2: roi = cv::gapi::own::Rect{ produced.x/2, produced.y/2, produced.width/2, produced.height/2 }; break;
|
||||
case 2: roi = cv::Rect{ produced.x/2, produced.y/2, produced.width/2, produced.height/2 }; break;
|
||||
default: GAPI_Assert(false);
|
||||
}
|
||||
return roi;
|
||||
};
|
||||
|
||||
cv::gapi::own::Rect produced = rois[m_id_map.at(data.rc)];
|
||||
cv::Rect produced = rois[m_id_map.at(data.rc)];
|
||||
|
||||
// Apply resize-specific roi transformations
|
||||
cv::gapi::own::Rect resized;
|
||||
cv::Rect resized;
|
||||
switch (fg.metadata(oh).get<FluidUnit>().k.m_kind)
|
||||
{
|
||||
case GFluidKernel::Kind::Filter: resized = produced; break;
|
||||
@ -731,7 +727,7 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
auto roi = adjFilterRoi(resized, fd.border_size, in_meta.size.height);
|
||||
|
||||
auto in_id = m_id_map.at(in_data.rc);
|
||||
if (rois[in_id] == cv::gapi::own::Rect{})
|
||||
if (rois[in_id] == cv::Rect{})
|
||||
{
|
||||
readStarts[in_id] = readStart;
|
||||
rois[in_id] = roi;
|
||||
@ -832,7 +828,7 @@ cv::gimpl::FluidGraphInputData cv::gimpl::fluidExtractInputDataFromGraph(const a
|
||||
|
||||
cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
|
||||
const cv::gimpl::FluidGraphInputData &traverse_res,
|
||||
const std::vector<cv::gapi::own::Rect> &outputRois)
|
||||
const std::vector<cv::Rect> &outputRois)
|
||||
: m_g(g), m_gm(m_g),
|
||||
m_num_int_buffers (traverse_res.m_mat_count),
|
||||
m_scratch_users (traverse_res.m_scratch_users),
|
||||
@ -1150,13 +1146,13 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void cv::gimpl::GFluidExecutable::makeReshape(const std::vector<gapi::own::Rect> &out_rois)
|
||||
void cv::gimpl::GFluidExecutable::makeReshape(const std::vector<cv::Rect> &out_rois)
|
||||
{
|
||||
GConstFluidModel fg(m_g);
|
||||
|
||||
// Calculate rois for each fluid buffer
|
||||
std::vector<int> readStarts(m_num_int_buffers);
|
||||
std::vector<cv::gapi::own::Rect> rois(m_num_int_buffers);
|
||||
std::vector<cv::Rect> rois(m_num_int_buffers);
|
||||
initBufferRois(readStarts, rois, out_rois);
|
||||
|
||||
// NB: Allocate ALL buffer object at once, and avoid any further reallocations
|
||||
@ -1252,8 +1248,9 @@ void cv::gimpl::GFluidExecutable::bindInArg(const cv::gimpl::RcDesc &rc, const G
|
||||
switch (rc.shape)
|
||||
{
|
||||
case GShape::GMAT: m_buffers[m_id_map.at(rc.id)].priv().bindTo(util::get<cv::gapi::own::Mat>(arg), true); break;
|
||||
case GShape::GSCALAR: m_res.slot<cv::gapi::own::Scalar>()[rc.id] = util::get<cv::gapi::own::Scalar>(arg); break;
|
||||
case GShape::GSCALAR: m_res.slot<cv::Scalar>()[rc.id] = util::get<cv::Scalar>(arg); break;
|
||||
case GShape::GARRAY: m_res.slot<cv::detail::VectorRef>()[rc.id] = util::get<cv::detail::VectorRef>(arg); break;
|
||||
case GShape::GOPAQUE: m_res.slot<cv::detail::OpaqueRef>()[rc.id] = util::get<cv::detail::OpaqueRef>(arg); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1296,19 +1293,24 @@ void cv::gimpl::GFluidExecutable::packArg(cv::GArg &in_arg, const cv::GArg &op_a
|
||||
{
|
||||
GAPI_Assert(op_arg.kind != cv::detail::ArgKind::GMAT
|
||||
&& op_arg.kind != cv::detail::ArgKind::GSCALAR
|
||||
&& op_arg.kind != cv::detail::ArgKind::GARRAY);
|
||||
&& op_arg.kind != cv::detail::ArgKind::GARRAY
|
||||
&& op_arg.kind != cv::detail::ArgKind::GOPAQUE);
|
||||
|
||||
if (op_arg.kind == cv::detail::ArgKind::GOBJREF)
|
||||
{
|
||||
const cv::gimpl::RcDesc &ref = op_arg.get<cv::gimpl::RcDesc>();
|
||||
if (ref.shape == GShape::GSCALAR)
|
||||
{
|
||||
in_arg = GArg(m_res.slot<cv::gapi::own::Scalar>()[ref.id]);
|
||||
in_arg = GArg(m_res.slot<cv::Scalar>()[ref.id]);
|
||||
}
|
||||
else if (ref.shape == GShape::GARRAY)
|
||||
{
|
||||
in_arg = GArg(m_res.slot<cv::detail::VectorRef>()[ref.id]);
|
||||
}
|
||||
else if (ref.shape == GShape::GOPAQUE)
|
||||
{
|
||||
in_arg = GArg(m_res.slot<cv::detail::OpaqueRef>()[ref.id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ class GFluidExecutable final: public GIslandExecutable
|
||||
|
||||
std::vector<FluidAgent*> m_script;
|
||||
|
||||
using Magazine = detail::magazine<cv::gapi::own::Scalar, cv::detail::VectorRef>;
|
||||
using Magazine = detail::magazine<cv::Scalar, cv::detail::VectorRef, cv::detail::OpaqueRef>;
|
||||
Magazine m_res;
|
||||
|
||||
std::size_t m_num_int_buffers; // internal buffers counter (m_buffers - num_scratch)
|
||||
@ -142,8 +142,8 @@ class GFluidExecutable final: public GIslandExecutable
|
||||
void bindOutArg(const RcDesc &rc, const GRunArgP &arg);
|
||||
void packArg (GArg &in_arg, const GArg &op_arg);
|
||||
|
||||
void initBufferRois(std::vector<int>& readStarts, std::vector<cv::gapi::own::Rect>& rois, const std::vector<gapi::own::Rect> &out_rois);
|
||||
void makeReshape(const std::vector<cv::gapi::own::Rect>& out_rois);
|
||||
void initBufferRois(std::vector<int>& readStarts, std::vector<cv::Rect>& rois, const std::vector<cv::Rect> &out_rois);
|
||||
void makeReshape(const std::vector<cv::Rect>& out_rois);
|
||||
std::size_t total_buffers_size() const;
|
||||
|
||||
public:
|
||||
@ -159,7 +159,7 @@ public:
|
||||
|
||||
GFluidExecutable(const ade::Graph &g,
|
||||
const FluidGraphInputData &graph_data,
|
||||
const std::vector<cv::gapi::own::Rect> &outputRois);
|
||||
const std::vector<cv::Rect> &outputRois);
|
||||
};
|
||||
|
||||
|
||||
|
@ -9,9 +9,6 @@
|
||||
|
||||
#include <iomanip> // hex, dec (debug)
|
||||
|
||||
#include <opencv2/gapi/own/convert.hpp>
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
|
||||
#include <opencv2/gapi/fluid/gfluidbuffer.hpp>
|
||||
#include "backends/fluid/gfluidbuffer_priv.hpp"
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
@ -64,7 +61,7 @@ void fillBorderReflectRow(uint8_t* row, int length, int chan, int borderSize)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void fillConstBorderRow(uint8_t* row, int length, int chan, int borderSize, cv::gapi::own::Scalar borderValue)
|
||||
void fillConstBorderRow(uint8_t* row, int length, int chan, int borderSize, cv::Scalar borderValue)
|
||||
{
|
||||
GAPI_DbgAssert(chan > 0 && chan <= 4);
|
||||
|
||||
@ -81,7 +78,7 @@ void fillConstBorderRow(uint8_t* row, int length, int chan, int borderSize, cv::
|
||||
}
|
||||
|
||||
// Fills const border pixels in the whole mat
|
||||
void fillBorderConstant(int borderSize, cv::gapi::own::Scalar borderValue, cv::gapi::own::Mat& mat)
|
||||
void fillBorderConstant(int borderSize, cv::Scalar borderValue, cv::gapi::own::Mat& mat)
|
||||
{
|
||||
// cv::Scalar can contain maximum 4 chan
|
||||
GAPI_Assert(mat.channels() > 0 && mat.channels() <= 4);
|
||||
@ -169,7 +166,7 @@ const uint8_t* fluid::BorderHandlerT<BorderType>::inLineB(int log_idx, const Buf
|
||||
return data.ptr(idx);
|
||||
}
|
||||
|
||||
fluid::BorderHandlerT<cv::BORDER_CONSTANT>::BorderHandlerT(int border_size, cv::gapi::own::Scalar border_value)
|
||||
fluid::BorderHandlerT<cv::BORDER_CONSTANT>::BorderHandlerT(int border_size, cv::Scalar border_value)
|
||||
: BorderHandler(border_size), m_border_value(border_value)
|
||||
{ /* nothing */ }
|
||||
|
||||
@ -181,7 +178,9 @@ const uint8_t* fluid::BorderHandlerT<cv::BORDER_CONSTANT>::inLineB(int /*log_idx
|
||||
void fluid::BorderHandlerT<cv::BORDER_CONSTANT>::fillCompileTimeBorder(BufferStorageWithBorder& data)
|
||||
{
|
||||
m_const_border.create(1, data.cols(), data.data().type());
|
||||
m_const_border = m_border_value;
|
||||
// FIXME: remove this crutch in deowned Mat
|
||||
m_const_border = {m_border_value[0], m_border_value[1],
|
||||
m_border_value[2], m_border_value[3]};
|
||||
|
||||
cv::gapi::fillBorderConstant(m_border_size, m_border_value, data.data());
|
||||
}
|
||||
@ -269,8 +268,8 @@ const uint8_t* fluid::BufferStorageWithBorder::inLineB(int log_idx, int desc_hei
|
||||
|
||||
static void copyWithoutBorder(const cv::gapi::own::Mat& src, int src_border_size, cv::gapi::own::Mat& dst, int dst_border_size, int startSrcLine, int startDstLine, int lpi)
|
||||
{
|
||||
auto subSrc = src(cv::gapi::own::Rect{src_border_size, startSrcLine, src.cols - 2*src_border_size, lpi});
|
||||
auto subDst = dst(cv::gapi::own::Rect{dst_border_size, startDstLine, dst.cols - 2*dst_border_size, lpi});
|
||||
auto subSrc = src(cv::Rect{src_border_size, startSrcLine, src.cols - 2*src_border_size, lpi});
|
||||
auto subDst = dst(cv::Rect{dst_border_size, startDstLine, dst.cols - 2*dst_border_size, lpi});
|
||||
|
||||
subSrc.copyTo(subDst);
|
||||
}
|
||||
@ -363,8 +362,8 @@ std::unique_ptr<fluid::BufferStorage> createStorage(int capacity, int desc_width
|
||||
#endif
|
||||
}
|
||||
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::gapi::own::Rect roi);
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::gapi::own::Rect roi)
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::Rect roi);
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::Rect roi)
|
||||
{
|
||||
std::unique_ptr<BufferStorageWithoutBorder> storage(new BufferStorageWithoutBorder);
|
||||
storage->attach(data, roi);
|
||||
@ -502,7 +501,7 @@ void fluid::View::Priv::initCache(int lineConsumption)
|
||||
|
||||
// Fluid Buffer implementation /////////////////////////////////////////////////
|
||||
|
||||
fluid::Buffer::Priv::Priv(int read_start, cv::gapi::own::Rect roi)
|
||||
fluid::Buffer::Priv::Priv(int read_start, cv::Rect roi)
|
||||
: m_readStart(read_start)
|
||||
, m_roi(roi)
|
||||
{}
|
||||
@ -510,12 +509,12 @@ fluid::Buffer::Priv::Priv(int read_start, cv::gapi::own::Rect roi)
|
||||
void fluid::Buffer::Priv::init(const cv::GMatDesc &desc,
|
||||
int writer_lpi,
|
||||
int readStartPos,
|
||||
cv::gapi::own::Rect roi)
|
||||
cv::Rect roi)
|
||||
{
|
||||
m_writer_lpi = writer_lpi;
|
||||
m_desc = desc;
|
||||
m_readStart = readStartPos;
|
||||
m_roi = roi == own::Rect{} ? own::Rect{ 0, 0, desc.size.width, desc.size.height }
|
||||
m_roi = roi == cv::Rect{} ? cv::Rect{ 0, 0, desc.size.width, desc.size.height }
|
||||
: roi;
|
||||
m_cache.m_linePtrs.resize(writer_lpi);
|
||||
m_cache.m_desc = desc;
|
||||
@ -650,7 +649,7 @@ fluid::Buffer::Buffer(const cv::GMatDesc &desc)
|
||||
{
|
||||
int lineConsumption = 1;
|
||||
int border = 0, skew = 0, wlpi = 1, readStart = 0;
|
||||
cv::gapi::own::Rect roi = {0, 0, desc.size.width, desc.size.height};
|
||||
cv::Rect roi = {0, 0, desc.size.width, desc.size.height};
|
||||
m_priv->init(desc, wlpi, readStart, roi);
|
||||
m_priv->allocate({}, border, lineConsumption, skew);
|
||||
}
|
||||
@ -665,7 +664,7 @@ fluid::Buffer::Buffer(const cv::GMatDesc &desc,
|
||||
, m_cache(&m_priv->cache())
|
||||
{
|
||||
int readStart = 0;
|
||||
cv::gapi::own::Rect roi = {0, 0, desc.size.width, desc.size.height};
|
||||
cv::Rect roi = {0, 0, desc.size.width, desc.size.height};
|
||||
m_priv->init(desc, wlpi, readStart, roi);
|
||||
m_priv->allocate(border, border_size, max_line_consumption, skew);
|
||||
}
|
||||
@ -675,7 +674,7 @@ fluid::Buffer::Buffer(const cv::gapi::own::Mat &data, bool is_input)
|
||||
, m_cache(&m_priv->cache())
|
||||
{
|
||||
int wlpi = 1, readStart = 0;
|
||||
cv::gapi::own::Rect roi{0, 0, data.cols, data.rows};
|
||||
cv::Rect roi{0, 0, data.cols, data.rows};
|
||||
m_priv->init(descr_of(data), wlpi, readStart, roi);
|
||||
m_priv->bindTo(data, is_input);
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ public:
|
||||
template<>
|
||||
class BorderHandlerT<cv::BORDER_CONSTANT> : public BorderHandler
|
||||
{
|
||||
cv::gapi::own::Scalar m_border_value;
|
||||
cv::Scalar m_border_value;
|
||||
cv::gapi::own::Mat m_const_border;
|
||||
|
||||
public:
|
||||
BorderHandlerT(int border_size, cv::gapi::own::Scalar border_value);
|
||||
BorderHandlerT(int border_size, cv::Scalar border_value);
|
||||
virtual const uint8_t* inLineB(int log_idx, const BufferStorageWithBorder &data, int desc_height) const override;
|
||||
virtual void fillCompileTimeBorder(BufferStorageWithBorder &) override;
|
||||
virtual std::size_t size() const override;
|
||||
@ -101,23 +101,23 @@ public:
|
||||
class BufferStorageWithoutBorder final : public BufferStorage
|
||||
{
|
||||
bool m_is_virtual = true;
|
||||
cv::gapi::own::Rect m_roi;
|
||||
cv::Rect m_roi;
|
||||
|
||||
public:
|
||||
virtual void copyTo(BufferStorageWithBorder &dst, int startLine, int nLines) const override;
|
||||
|
||||
inline virtual const uint8_t* ptr(int idx) const override
|
||||
{
|
||||
GAPI_DbgAssert((m_is_virtual && m_roi == cv::gapi::own::Rect{}) || (!m_is_virtual && m_roi != cv::gapi::own::Rect{}));
|
||||
GAPI_DbgAssert((m_is_virtual && m_roi == cv::Rect{}) || (!m_is_virtual && m_roi != cv::Rect{}));
|
||||
return m_data.ptr(physIdx(idx), 0);
|
||||
}
|
||||
inline virtual uint8_t* ptr(int idx) override
|
||||
{
|
||||
GAPI_DbgAssert((m_is_virtual && m_roi == cv::gapi::own::Rect{}) || (!m_is_virtual && m_roi != cv::gapi::own::Rect{}));
|
||||
GAPI_DbgAssert((m_is_virtual && m_roi == cv::Rect{}) || (!m_is_virtual && m_roi != cv::Rect{}));
|
||||
return m_data.ptr(physIdx(idx), 0);
|
||||
}
|
||||
|
||||
inline void attach(const cv::gapi::own::Mat& _data, cv::gapi::own::Rect _roi)
|
||||
inline void attach(const cv::gapi::own::Mat& _data, cv::Rect _roi)
|
||||
{
|
||||
m_data = _data(_roi);
|
||||
m_roi = _roi;
|
||||
@ -246,13 +246,13 @@ class GAPI_EXPORTS Buffer::Priv
|
||||
// Coordinate starting from which this buffer is assumed
|
||||
// to be read (with border not being taken into account)
|
||||
int m_readStart;
|
||||
cv::gapi::own::Rect m_roi;
|
||||
cv::Rect m_roi;
|
||||
|
||||
friend void debugBufferPriv(const Buffer& p, std::ostream &os);
|
||||
|
||||
public:
|
||||
Priv() = default;
|
||||
Priv(int read_start, cv::gapi::own::Rect roi);
|
||||
Priv(int read_start, cv::Rect roi);
|
||||
|
||||
inline const BufferStorage& storage() const { return *m_storage.get(); }
|
||||
|
||||
@ -260,7 +260,7 @@ public:
|
||||
void init(const cv::GMatDesc &desc,
|
||||
int writer_lpi,
|
||||
int readStart,
|
||||
cv::gapi::own::Rect roi);
|
||||
cv::Rect roi);
|
||||
|
||||
void allocate(BorderOpt border, int border_size, int line_consumption, int skew);
|
||||
void bindTo(const cv::gapi::own::Mat &data, bool is_input);
|
||||
|
@ -2040,7 +2040,7 @@ GAPI_FLUID_KERNEL(GFluidResize, cv::gapi::core::GResize, true)
|
||||
cv::GMatDesc desc;
|
||||
desc.chan = 1;
|
||||
desc.depth = CV_8UC1;
|
||||
desc.size = to_own(scratch_size);
|
||||
desc.size = scratch_size;
|
||||
|
||||
cv::gapi::fluid::Buffer buffer(desc);
|
||||
scratch = std::move(buffer);
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
#include <opencv2/gapi/imgproc.hpp>
|
||||
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
|
||||
#include <opencv2/gapi/fluid/gfluidbuffer.hpp>
|
||||
#include <opencv2/gapi/fluid/gfluidkernel.hpp>
|
||||
#include <opencv2/gapi/fluid/imgproc.hpp>
|
||||
@ -31,7 +29,7 @@
|
||||
#include <opencv2/core/hal/intrin.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
@ -451,7 +449,7 @@ GAPI_FLUID_KERNEL(GFluidBlur, cv::gapi::imgproc::GBlur, true)
|
||||
|
||||
int buflen = width * chan * Window; // work buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -526,7 +524,7 @@ GAPI_FLUID_KERNEL(GFluidBoxFilter, cv::gapi::imgproc::GBoxFilter, true)
|
||||
|
||||
int buflen = width * chan * Window; // work buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -748,7 +746,7 @@ GAPI_FLUID_KERNEL(GFluidSepFilter, cv::gapi::imgproc::GSepFilter, true)
|
||||
int buflen = kxLen + kyLen + // x, y kernels
|
||||
width * chan * Window; // work buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -851,7 +849,7 @@ GAPI_FLUID_KERNEL(GFluidGaussBlur, cv::gapi::imgproc::GGaussBlur, true)
|
||||
int buflen = kxsize + kysize + // x, y kernels
|
||||
width * chan * ksize.height; // work buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1016,7 +1014,7 @@ GAPI_FLUID_KERNEL(GFluidSobel, cv::gapi::imgproc::GSobel, true)
|
||||
int buflen = ksz + ksz // kernels: kx, ky
|
||||
+ ksz * width * chan; // working buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1171,7 +1169,7 @@ GAPI_FLUID_KERNEL(GFluidSobelXY, cv::gapi::imgproc::GSobelXY, true)
|
||||
int chan = in.chan;
|
||||
int buflen = BufHelper::length(ksz, width, chan);
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1319,7 +1317,7 @@ GAPI_FLUID_KERNEL(GFluidFilter2D, cv::gapi::imgproc::GFilter2D, true)
|
||||
|
||||
int buflen = krows * kcols; // kernel size
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1496,7 +1494,7 @@ GAPI_FLUID_KERNEL(GFluidErode, cv::gapi::imgproc::GErode, true)
|
||||
int k_cols = kernel.cols;
|
||||
int k_size = k_rows * k_cols;
|
||||
|
||||
cv::gapi::own::Size bufsize(k_size + 1, 1);
|
||||
cv::Size bufsize(k_size + 1, 1);
|
||||
GMatDesc bufdesc = {CV_8U, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1525,7 +1523,7 @@ GAPI_FLUID_KERNEL(GFluidErode, cv::gapi::imgproc::GErode, true)
|
||||
#if 1
|
||||
// TODO: saturate borderValue to image type in general case (not only maximal border)
|
||||
GAPI_Assert(borderType == cv::BORDER_CONSTANT && borderValue[0] == DBL_MAX);
|
||||
return { borderType, cv::gapi::own::Scalar::all(INT_MAX) };
|
||||
return { borderType, cv::Scalar::all(INT_MAX) };
|
||||
#else
|
||||
return { borderType, borderValue };
|
||||
#endif
|
||||
@ -1582,7 +1580,7 @@ GAPI_FLUID_KERNEL(GFluidDilate, cv::gapi::imgproc::GDilate, true)
|
||||
int k_cols = kernel.cols;
|
||||
int k_size = k_rows * k_cols;
|
||||
|
||||
cv::gapi::own::Size bufsize(k_size + 1, 1);
|
||||
cv::Size bufsize(k_size + 1, 1);
|
||||
GMatDesc bufdesc = {CV_8U, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1611,7 +1609,7 @@ GAPI_FLUID_KERNEL(GFluidDilate, cv::gapi::imgproc::GDilate, true)
|
||||
#if 1
|
||||
// TODO: fix borderValue for Dilate in general case (not only minimal border)
|
||||
GAPI_Assert(borderType == cv::BORDER_CONSTANT && borderValue[0] == DBL_MAX);
|
||||
return { borderType, cv::gapi::own::Scalar::all(INT_MIN) };
|
||||
return { borderType, cv::Scalar::all(INT_MIN) };
|
||||
#else
|
||||
return { borderType, borderValue };
|
||||
#endif
|
||||
@ -1749,7 +1747,7 @@ GAPI_FLUID_KERNEL(GFluidRGB2HSV, cv::gapi::imgproc::GRGB2HSV, true)
|
||||
cv::GMatDesc desc;
|
||||
desc.chan = 1;
|
||||
desc.depth = CV_32S;
|
||||
desc.size = cv::gapi::own::Size(512, 1);
|
||||
desc.size = cv::Size(512, 1);
|
||||
|
||||
cv::gapi::fluid::Buffer buffer(desc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1800,12 +1798,12 @@ GAPI_FLUID_KERNEL(GFluidBayerGR2RGB, cv::gapi::imgproc::GBayerGR2RGB, false)
|
||||
if (in.y() == -1)
|
||||
{
|
||||
run_bayergr2rgb_bg_impl(dst[1], src + border_size, width);
|
||||
std::memcpy(dst[0], dst[1], width * 3);
|
||||
std::copy_n(dst[1], width * 3, dst[0]);
|
||||
}
|
||||
else if (in.y() == height - LPI - 2 * border_size + 1)
|
||||
{
|
||||
run_bayergr2rgb_gr_impl(dst[0], src, width);
|
||||
std::memcpy(dst[1], dst[0], width * 3);
|
||||
std::copy_n(dst[0], width * 3, dst[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1831,7 +1831,7 @@ static void run_sepfilter5x5_char2short(short out[], const uchar *in[], int widt
|
||||
for (; l <= length - nlanes; l += nlanes)
|
||||
{
|
||||
v_uint16 t[kxLen];
|
||||
v_int16 sum;
|
||||
v_int16 sum = vx_setzero_s16();
|
||||
|
||||
for (int i = 0; i < kxLen; ++i)
|
||||
{
|
||||
@ -1862,7 +1862,7 @@ static void run_sepfilter5x5_char2short(short out[], const uchar *in[], int widt
|
||||
for (; l <= length - nlanes; l += nlanes)
|
||||
{
|
||||
v_int16 s[buffSize];
|
||||
v_int16 sum;
|
||||
v_int16 sum = vx_setzero_s16();
|
||||
|
||||
for (int i = 0; i < kyLen; ++i)
|
||||
{
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <opencv2/gapi/gcommon.hpp>
|
||||
#include <opencv2/gapi/garray.hpp>
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
#include <opencv2/gapi/util/any.hpp>
|
||||
#include <opencv2/gapi/gtype_traits.hpp>
|
||||
#include <opencv2/gapi/infer.hpp>
|
||||
@ -175,8 +176,10 @@ struct IEUnit {
|
||||
explicit IEUnit(const cv::gapi::ie::detail::ParamDesc &pp)
|
||||
: params(pp) {
|
||||
|
||||
IE::Core ie;
|
||||
net = ie.ReadNetwork(params.model_path, params.weights_path);
|
||||
IE::CNNNetReader reader;
|
||||
reader.ReadNetwork(params.model_path);
|
||||
reader.ReadWeights(params.weights_path);
|
||||
net = reader.getNetwork();
|
||||
inputs = net.getInputsInfo();
|
||||
outputs = net.getOutputsInfo();
|
||||
|
||||
@ -394,6 +397,10 @@ cv::GArg cv::gimpl::ie::GIEExecutable::packArg(const cv::GArg &arg) {
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
case GShape::GARRAY: return GArg(m_res.slot<cv::detail::VectorRef>().at(ref.id));
|
||||
|
||||
// Note: .at() is intentional for GOpaque as object MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
case GShape::GOPAQUE: return GArg(m_res.slot<cv::detail::OpaqueRef>().at(ref.id));
|
||||
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
break;
|
||||
|
@ -113,7 +113,8 @@ cv::GArg cv::gimpl::GOCLExecutable::packArg(const GArg &arg)
|
||||
// FIXME: this check has to be done somewhere in compilation stage.
|
||||
GAPI_Assert( arg.kind != cv::detail::ArgKind::GMAT
|
||||
&& arg.kind != cv::detail::ArgKind::GSCALAR
|
||||
&& arg.kind != cv::detail::ArgKind::GARRAY);
|
||||
&& arg.kind != cv::detail::ArgKind::GARRAY
|
||||
&& arg.kind != cv::detail::ArgKind::GOPAQUE);
|
||||
|
||||
if (arg.kind != cv::detail::ArgKind::GOBJREF)
|
||||
{
|
||||
@ -128,10 +129,13 @@ cv::GArg cv::gimpl::GOCLExecutable::packArg(const GArg &arg)
|
||||
switch (ref.shape)
|
||||
{
|
||||
case GShape::GMAT: return GArg(m_res.slot<cv::UMat>()[ref.id]);
|
||||
case GShape::GSCALAR: return GArg(m_res.slot<cv::gapi::own::Scalar>()[ref.id]);
|
||||
// Note: .at() is intentional for GArray as object MUST be already there
|
||||
case GShape::GSCALAR: return GArg(m_res.slot<cv::Scalar>()[ref.id]);
|
||||
// Note: .at() is intentional for GArray as object MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
case GShape::GARRAY: return GArg(m_res.slot<cv::detail::VectorRef>().at(ref.id));
|
||||
// Note: .at() is intentional for GOpaque as object MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
case GShape::GOPAQUE: return GArg(m_res.slot<cv::detail::OpaqueRef>().at(ref.id));
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
break;
|
||||
|
@ -19,14 +19,14 @@ cv::UMat& cv::GOCLContext::outMatR(int output)
|
||||
return (*(util::get<cv::UMat*>(m_results.at(output))));
|
||||
}
|
||||
|
||||
const cv::gapi::own::Scalar& cv::GOCLContext::inVal(int input)
|
||||
const cv::Scalar& cv::GOCLContext::inVal(int input)
|
||||
{
|
||||
return inArg<cv::gapi::own::Scalar>(input);
|
||||
return inArg<cv::Scalar>(input);
|
||||
}
|
||||
|
||||
cv::gapi::own::Scalar& cv::GOCLContext::outValR(int output)
|
||||
cv::Scalar& cv::GOCLContext::outValR(int output)
|
||||
{
|
||||
return *util::get<cv::gapi::own::Scalar*>(m_results.at(output));
|
||||
return *util::get<cv::Scalar*>(m_results.at(output));
|
||||
}
|
||||
|
||||
cv::detail::VectorRef& cv::GOCLContext::outVecRef(int output)
|
||||
|
@ -276,7 +276,8 @@ cv::GArg cv::gimpl::GPlaidMLExecutable::packArg(const GArg &arg)
|
||||
{
|
||||
GAPI_Assert( arg.kind != cv::detail::ArgKind::GMAT
|
||||
&& arg.kind != cv::detail::ArgKind::GSCALAR
|
||||
&& arg.kind != cv::detail::ArgKind::GARRAY);
|
||||
&& arg.kind != cv::detail::ArgKind::GARRAY
|
||||
&& arg.kind != cv::detail::ArgKind::GOPAQUE);
|
||||
|
||||
if (arg.kind != cv::detail::ArgKind::GOBJREF)
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ void cv::GCompiled::Priv::checkArgs(const cv::gimpl::GRuntimeArgs &args) const
|
||||
"for different metadata!"));
|
||||
// FIXME: Add details on what is actually wrong
|
||||
}
|
||||
validate_input_args(args.inObjs);
|
||||
}
|
||||
|
||||
bool cv::GCompiled::Priv::canReshape() const
|
||||
|
@ -332,6 +332,9 @@ void cv::gimpl::GCompiler::validateInputMeta()
|
||||
case GProtoArg::index_of<cv::detail::GArrayU>():
|
||||
return util::holds_alternative<cv::GArrayDesc>(meta);
|
||||
|
||||
case GProtoArg::index_of<cv::detail::GOpaqueU>():
|
||||
return util::holds_alternative<cv::GOpaqueDesc>(meta);
|
||||
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
}
|
||||
|
@ -16,18 +16,19 @@ namespace cv
|
||||
|
||||
namespace gimpl
|
||||
{
|
||||
// Union type for various user-defined type constructors (GArray<T>, etc)
|
||||
// Union type for various user-defined type constructors (GArray<T>, GOpaque<T>, etc)
|
||||
// FIXME: Replace construct-only API with a more generic one
|
||||
// (probably with bits of introspection)
|
||||
// Not required for non-user-defined types (GMat, GScalar, etc)
|
||||
using HostCtor = util::variant
|
||||
< util::monostate
|
||||
, detail::ConstructVec
|
||||
, detail::ConstructOpaque
|
||||
>;
|
||||
|
||||
using ConstVal = util::variant
|
||||
< util::monostate
|
||||
, cv::gapi::own::Scalar
|
||||
, cv::Scalar
|
||||
>;
|
||||
|
||||
struct RcDesc
|
||||
|
@ -32,6 +32,7 @@ void dumpDot(const ade::Graph &g, std::ostream& os)
|
||||
{cv::GShape::GMAT, "GMat"},
|
||||
{cv::GShape::GSCALAR, "GScalar"},
|
||||
{cv::GShape::GARRAY, "GArray"},
|
||||
{cv::GShape::GOPAQUE, "GOpaque"},
|
||||
};
|
||||
|
||||
auto format_op_label = [&gr](ade::NodeHandle nh) -> std::string {
|
||||
|
@ -112,15 +112,12 @@ void sync_data(cv::GRunArgs &results, cv::GRunArgsP &outputs)
|
||||
case T::index_of<cv::Mat*>():
|
||||
*cv::util::get<cv::Mat*>(out_obj) = std::move(cv::util::get<cv::Mat>(res_obj));
|
||||
break;
|
||||
case T::index_of<cv::Scalar*>():
|
||||
*cv::util::get<cv::Scalar*>(out_obj) = std::move(cv::util::get<cv::Scalar>(res_obj));
|
||||
break;
|
||||
#endif // !GAPI_STANDALONE
|
||||
case T::index_of<own::Mat*>():
|
||||
*cv::util::get<own::Mat*>(out_obj) = std::move(cv::util::get<own::Mat>(res_obj));
|
||||
break;
|
||||
case T::index_of<own::Scalar*>():
|
||||
*cv::util::get<own::Scalar*>(out_obj) = std::move(cv::util::get<own::Scalar>(res_obj));
|
||||
case T::index_of<cv::Scalar*>():
|
||||
*cv::util::get<cv::Scalar*>(out_obj) = std::move(cv::util::get<cv::Scalar>(res_obj));
|
||||
break;
|
||||
case T::index_of<cv::detail::VectorRef>():
|
||||
cv::util::get<cv::detail::VectorRef>(out_obj).mov(cv::util::get<cv::detail::VectorRef>(res_obj));
|
||||
@ -418,7 +415,7 @@ void islandActorThread(std::vector<cv::gimpl::RcDesc> in_rcs, //
|
||||
isl_input.second = cv::GRunArg{cv::to_own(cv::util::get<cv::Mat>(in_arg))};
|
||||
break;
|
||||
case cv::GRunArg::index_of<cv::Scalar>():
|
||||
isl_input.second = cv::GRunArg{cv::to_own(cv::util::get<cv::Scalar>(in_arg))};
|
||||
isl_input.second = cv::GRunArg{cv::util::get<cv::Scalar>(in_arg)};
|
||||
break;
|
||||
default:
|
||||
isl_input.second = in_arg;
|
||||
@ -443,7 +440,7 @@ void islandActorThread(std::vector<cv::gimpl::RcDesc> in_rcs, //
|
||||
using SclType = cv::Scalar;
|
||||
#else
|
||||
using MatType = cv::gapi::own::Mat;
|
||||
using SclType = cv::gapi::own::Scalar;
|
||||
using SclType = cv::Scalar;
|
||||
#endif // GAPI_STANDALONE
|
||||
|
||||
switch (r.shape) {
|
||||
@ -737,7 +734,7 @@ void cv::gimpl::GStreamingExecutor::setSource(GRunArgs &&ins)
|
||||
for (auto& op : m_ops)
|
||||
{
|
||||
op.isl_exec = m_gim.metadata(op.nh).get<IslandExec>().object;
|
||||
is_reshapable &= op.isl_exec->canReshape();
|
||||
is_reshapable = is_reshapable && op.isl_exec->canReshape();
|
||||
}
|
||||
update_int_metas(); // (7)
|
||||
m_reshapable = util::make_optional(is_reshapable);
|
||||
|
@ -245,7 +245,7 @@ TEST(GCompoundKernel, ReplaceDefaultKernel)
|
||||
comp.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat), cv::compile_args(full_pkg));
|
||||
ref_mat = in_mat1 - in_mat2 - in_mat2;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, DoubleAddC)
|
||||
@ -270,7 +270,7 @@ TEST(GCompoundKernel, DoubleAddC)
|
||||
comp.apply(cv::gin(in_mat1, in_mat2, scalar), cv::gout(out_mat), cv::compile_args(full_pkg));
|
||||
ref_mat = in_mat1 + in_mat2 + scalar + scalar + scalar;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, AddC)
|
||||
@ -295,7 +295,7 @@ TEST(GCompoundKernel, AddC)
|
||||
comp.apply(cv::gin(in_mat1, in_mat2, scalar), cv::gout(out_mat), cv::compile_args(full_pkg));
|
||||
ref_mat = in_mat1 + in_mat2 + scalar + scalar;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, MergeWithSplit)
|
||||
@ -315,7 +315,7 @@ TEST(GCompoundKernel, MergeWithSplit)
|
||||
comp.apply(cv::gin(in_mat), cv::gout(out_mat), cv::compile_args(full_pkg));
|
||||
ref_mat = in_mat;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, AddWithAddC)
|
||||
@ -338,7 +338,7 @@ TEST(GCompoundKernel, AddWithAddC)
|
||||
comp.apply(cv::gin(in_mat1, in_mat2, scalar), cv::gout(out_mat), cv::compile_args(full_pkg));
|
||||
ref_mat = in_mat1 + in_mat2 + scalar;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, SplitWithAdd)
|
||||
@ -364,8 +364,8 @@ TEST(GCompoundKernel, SplitWithAdd)
|
||||
ref_mat1 = channels[0] + channels[1];
|
||||
ref_mat2 = channels[2];
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat1 != ref_mat1));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat2 != ref_mat2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat1, ref_mat1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat2, ref_mat2, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, ParallelAddC)
|
||||
@ -391,8 +391,8 @@ TEST(GCompoundKernel, ParallelAddC)
|
||||
ref_mat1 = in_mat + scalar;
|
||||
ref_mat2 = in_mat + scalar;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat1 != ref_mat1));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat2 != ref_mat2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat1, ref_mat1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat2, ref_mat2, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, GCompundKernelAndDefaultUseOneData)
|
||||
@ -415,7 +415,7 @@ TEST(GCompoundKernel, GCompundKernelAndDefaultUseOneData)
|
||||
comp.apply(cv::gin(in_mat1, in_mat2, scalar), cv::gout(out_mat), cv::compile_args(full_pkg));
|
||||
ref_mat = in_mat1 + in_mat2 + scalar + in_mat2 + scalar;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, CompoundExpandedToCompound)
|
||||
@ -441,7 +441,7 @@ TEST(GCompoundKernel, CompoundExpandedToCompound)
|
||||
comp.apply(cv::gin(in_mat1, in_mat2, scalar), cv::gout(out_mat), cv::compile_args(full_pkg));
|
||||
ref_mat = in_mat1 + in_mat2 + scalar + scalar + scalar;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GCompoundKernel, MaxInArray)
|
||||
@ -494,7 +494,7 @@ TEST(GCompoundKernel, RightGArrayHandle)
|
||||
|
||||
comp.apply(cv::gin(in_mat1, in_v, in_mat2), cv::gout(out_mat), cv::compile_args(full_pkg));
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
|
||||
}
|
||||
} // opencv_test
|
||||
|
@ -141,6 +141,14 @@ struct BackendOutputAllocationTest : TestWithParamBase<>
|
||||
// FIXME: move all tests from this fixture to the base class once all issues are resolved
|
||||
struct BackendOutputAllocationLargeSizeWithCorrectSubmatrixTest : BackendOutputAllocationTest {};
|
||||
GAPI_TEST_FIXTURE(ReInitOutTest, initNothing, <cv::Size>, 1, out_sz)
|
||||
|
||||
GAPI_TEST_FIXTURE(WarpPerspectiveTest, initMatrixRandU,
|
||||
FIXTURE_API(CompareMats, double , double, int, int, cv::Scalar),
|
||||
6, cmpF, angle, scale, flags, border_mode, border_value)
|
||||
|
||||
GAPI_TEST_FIXTURE(WarpAffineTest, initMatrixRandU,
|
||||
FIXTURE_API(CompareMats, double , double, int, int, cv::Scalar),
|
||||
6, cmpF, angle, scale, flags, border_mode, border_value)
|
||||
} // opencv_test
|
||||
|
||||
#endif //OPENCV_GAPI_CORE_TESTS_HPP
|
||||
|
@ -120,18 +120,21 @@ TEST_P(MathOpTest, MatricesAccuracyTest)
|
||||
CV_MAT_DEPTH(out_mat_ocv.type()) != CV_64F)
|
||||
{
|
||||
// integral: allow 1% of differences, and no diffs by >1 unit
|
||||
EXPECT_LE(countNonZeroPixels(cv::abs(out_mat_gapi - out_mat_ocv) > 0),
|
||||
0.01*out_mat_ocv.total());
|
||||
EXPECT_LE(countNonZeroPixels(cv::abs(out_mat_gapi - out_mat_ocv) > 1), 0);
|
||||
EXPECT_LE(cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF), 1); // check: abs(a[i] - b[i]) <= 1
|
||||
float tolerance = 0.01f;
|
||||
#if defined(__arm__) || defined(__aarch64__)
|
||||
if (opType == DIV)
|
||||
tolerance = 0.05f;
|
||||
#endif
|
||||
EXPECT_LE(cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_L1), tolerance*out_mat_ocv.total());
|
||||
}
|
||||
else
|
||||
{
|
||||
// floating-point: expect 6 decimal digits - best we expect of F32
|
||||
EXPECT_EQ(0, cv::countNonZero(cv::abs(out_mat_gapi - out_mat_ocv) >
|
||||
1e-6*cv::abs(out_mat_ocv)));
|
||||
EXPECT_LE(cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF | NORM_RELATIVE), 1e-6);
|
||||
}
|
||||
#else
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
#endif
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
@ -157,18 +160,16 @@ TEST_P(MulDoubleTest, AccuracyTest)
|
||||
CV_MAT_DEPTH(out_mat_ocv.type()) != CV_64F)
|
||||
{
|
||||
// integral: allow 1% of differences, and no diffs by >1 unit
|
||||
EXPECT_LE(countNonZeroPixels(cv::abs(out_mat_gapi - out_mat_ocv) > 0),
|
||||
0.01*out_mat_ocv.total());
|
||||
EXPECT_LE(countNonZeroPixels(cv::abs(out_mat_gapi - out_mat_ocv) > 1), 0);
|
||||
EXPECT_LE(cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF), 1);
|
||||
EXPECT_LE(cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_L1 | NORM_RELATIVE), 0.01);
|
||||
}
|
||||
else
|
||||
{
|
||||
// floating-point: expect 6 decimal digits - best we expect of F32
|
||||
EXPECT_EQ(0, cv::countNonZero(cv::abs(out_mat_gapi - out_mat_ocv) >
|
||||
1e-6*cv::abs(out_mat_ocv)));
|
||||
EXPECT_LE(cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF | NORM_RELATIVE), 1e-6);
|
||||
}
|
||||
#else
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
#endif
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
@ -191,7 +192,7 @@ TEST_P(DivTest, DISABLED_DivByZeroTest) // https://github.com/opencv/opencv/pul
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
@ -215,9 +216,9 @@ TEST_P(DivCTest, DISABLED_DivByZeroTest) // https://github.com/opencv/opencv/pu
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
cv::Mat zeros = cv::Mat::zeros(sz, type);
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != zeros));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, zeros, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +262,7 @@ TEST_P(MaskTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,18 +302,15 @@ TEST_P(Polar2CartTest, AccuracyTest)
|
||||
//
|
||||
// TODO: Make threshold a configurable parameter of this test (ADE-221)
|
||||
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
|
||||
cv::Mat &outx = out_mat_gapi,
|
||||
&outy = out_mat2;
|
||||
cv::Mat &refx = out_mat_ocv,
|
||||
&refy = out_mat_ocv2;
|
||||
cv::Mat difx = cv::abs(refx - outx),
|
||||
dify = cv::abs(refy - outy);
|
||||
cv::Mat absx = cv::abs(refx),
|
||||
absy = cv::abs(refy);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(difx > 1e-6*absx));
|
||||
EXPECT_EQ(0, cv::countNonZero(dify > 1e-6*absy));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_LE(cvtest::norm(refx, outx, NORM_L1 | NORM_RELATIVE), 1e-6);
|
||||
EXPECT_LE(cvtest::norm(refy, outy, NORM_L1 | NORM_RELATIVE), 1e-6);
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,20 +345,17 @@ TEST_P(Cart2PolarTest, AccuracyTest)
|
||||
//
|
||||
// TODO: Make threshold a configurable parameter of this test (ADE-221)
|
||||
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
|
||||
cv::Mat &outm = out_mat_gapi,
|
||||
&outa = out_mat2;
|
||||
cv::Mat &refm = out_mat_ocv,
|
||||
&refa = out_mat_ocv2;
|
||||
cv::Mat difm = cv::abs(refm - outm),
|
||||
difa = cv::abs(refa - outa);
|
||||
cv::Mat absm = cv::abs(refm),
|
||||
absa = cv::abs(refa);
|
||||
|
||||
// FIXME: Angle result looks inaccurate at OpenCV
|
||||
// (expected relative accuracy like 1e-6)
|
||||
EXPECT_EQ(0, cv::countNonZero(difm > 1e-6*absm));
|
||||
EXPECT_EQ(0, cv::countNonZero(difa > 1e-3*absa));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_LE(cvtest::norm(refm, outm, NORM_INF), 1e-6);
|
||||
EXPECT_LE(cvtest::norm(refa, outa, NORM_INF), 1e-3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,8 +404,8 @@ TEST_P(CmpTest, AccuracyTest)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,8 +443,8 @@ TEST_P(BitwiseTest, AccuracyTest)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,8 +463,8 @@ TEST_P(NotTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,8 +487,8 @@ TEST_P(SelectTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -512,8 +507,8 @@ TEST_P(MinTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,8 +527,8 @@ TEST_P(MaxTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,8 +547,8 @@ TEST_P(AbsDiffTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -573,8 +568,8 @@ TEST_P(AbsDiffCTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -674,8 +669,8 @@ TEST_P(IntegralTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv1 != out_mat1));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv2 != out_mat2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv1, out_mat1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv2, out_mat2, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -723,7 +718,7 @@ TEST_P(ThresholdOTTest, AccuracyTestOtsu)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(ocv_res, out_gapi_scalar.val[0]);
|
||||
}
|
||||
@ -748,8 +743,8 @@ TEST_P(InRangeTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -772,9 +767,9 @@ TEST_P(Split3Test, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv2 != out_mat2));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv3 != out_mat3));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv2, out_mat2, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv3, out_mat3, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -800,10 +795,10 @@ TEST_P(Split4Test, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv2 != out_mat2));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv3 != out_mat3));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv4 != out_mat4));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv2, out_mat2, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv3, out_mat3, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv4, out_mat4, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -900,7 +895,7 @@ TEST_P(Merge3Test, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -927,7 +922,7 @@ TEST_P(Merge4Test, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -951,7 +946,7 @@ TEST_P(RemapTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
@ -970,7 +965,7 @@ TEST_P(FlipTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
@ -996,7 +991,7 @@ TEST_P(CropTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz_out);
|
||||
}
|
||||
}
|
||||
@ -1022,7 +1017,7 @@ TEST_P(CopyTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz_out);
|
||||
}
|
||||
}
|
||||
@ -1058,7 +1053,7 @@ TEST_P(ConcatHorTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1093,7 +1088,7 @@ TEST_P(ConcatVertTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1135,7 +1130,7 @@ TEST_P(ConcatVertVecTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1177,7 +1172,7 @@ TEST_P(ConcatHorVecTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1204,7 +1199,7 @@ TEST_P(LUTTest, AccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
@ -1248,7 +1243,7 @@ TEST_P(PhaseTest, AccuracyTest)
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// FIXME: use a comparison functor instead (after enabling OpenCL)
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1267,7 +1262,52 @@ TEST_P(SqrtTest, AccuracyTest)
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// FIXME: use a comparison functor instead (after enabling OpenCL)
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(WarpPerspectiveTest, AccuracyTest)
|
||||
{
|
||||
cv::Point center{in_mat1.size() / 2};
|
||||
cv::Mat xy = cv::getRotationMatrix2D(center, angle, scale);
|
||||
cv::Matx13d z (0, 0, 1);
|
||||
cv::Mat transform_mat;
|
||||
cv::vconcat(xy, z, transform_mat);
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
auto out = cv::gapi::warpPerspective(in, transform_mat, in_mat1.size(), flags, border_mode, border_value);
|
||||
|
||||
cv::GComputation c(in, out);
|
||||
c.apply(in_mat1, out_mat_gapi, getCompileArgs());
|
||||
|
||||
// OpenCV code /////////////////////////////////////////////////////////////
|
||||
cv::warpPerspective(in_mat1, out_mat_ocv, cv::Mat(transform_mat), in_mat1.size(), flags, border_mode, border_value);
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(WarpAffineTest, AccuracyTest)
|
||||
{
|
||||
cv::Point center{in_mat1.size() / 2};
|
||||
cv::Mat warp_mat = cv::getRotationMatrix2D(center, angle, scale);
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
auto out = cv::gapi::warpAffine(in, warp_mat, in_mat1.size(), flags, border_mode, border_value);
|
||||
|
||||
cv::GComputation c(in, out);
|
||||
c.apply(in_mat1, out_mat_gapi, getCompileArgs());
|
||||
|
||||
// OpenCV code /////////////////////////////////////////////////////////////
|
||||
cv::warpAffine(in_mat1, out_mat_ocv, warp_mat, in_mat1.size(), flags, border_mode, border_value);
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1311,7 +1351,7 @@ TEST_P(BackendOutputAllocationTest, EmptyOutput)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// Expected: output is allocated to the needed size
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(sz, out_mat_gapi.size());
|
||||
}
|
||||
|
||||
@ -1331,7 +1371,7 @@ TEST_P(BackendOutputAllocationTest, CorrectlyPreallocatedOutput)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// Expected: output is not reallocated
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(sz, out_mat_gapi.size());
|
||||
|
||||
EXPECT_EQ(out_mat_gapi_ref.data, out_mat_gapi.data);
|
||||
@ -1356,7 +1396,7 @@ TEST_P(BackendOutputAllocationTest, IncorrectOutputMeta)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// Expected: size is changed, type is changed, output is reallocated
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(sz, out_mat_gapi.size());
|
||||
EXPECT_EQ(type, out_mat_gapi.type());
|
||||
|
||||
@ -1388,7 +1428,7 @@ TEST_P(BackendOutputAllocationTest, SmallerPreallocatedSize)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// Expected: size is changed, output is reallocated due to original size < curr size
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(sz, out_mat_gapi.size());
|
||||
|
||||
EXPECT_NE(out_mat_gapi_ref.data, out_mat_gapi.data);
|
||||
@ -1414,7 +1454,7 @@ TEST_P(BackendOutputAllocationTest, SmallerPreallocatedSizeWithSubmatrix)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// Expected: submatrix is reallocated and is "detached", original matrix is unchanged
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi_submat != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi_submat, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(sz, out_mat_gapi_submat.size());
|
||||
EXPECT_EQ(sz / 2, out_mat_gapi.size());
|
||||
|
||||
@ -1438,7 +1478,7 @@ TEST_P(BackendOutputAllocationTest, LargerPreallocatedSize)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// Expected: size is changed, output is reallocated
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(sz, out_mat_gapi.size());
|
||||
|
||||
EXPECT_NE(out_mat_gapi_ref.data, out_mat_gapi.data);
|
||||
@ -1466,7 +1506,7 @@ TEST_P(BackendOutputAllocationLargeSizeWithCorrectSubmatrixTest,
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// Expected: submatrix is not reallocated, original matrix is not reallocated
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi_submat != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi_submat, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(sz, out_mat_gapi_submat.size());
|
||||
EXPECT_EQ(sz * 2, out_mat_gapi.size());
|
||||
|
||||
@ -1496,7 +1536,7 @@ TEST_P(BackendOutputAllocationTest, LargerPreallocatedSizeWithSmallSubmatrix)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// Expected: submatrix is reallocated and is "detached", original matrix is unchanged
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi_submat != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi_submat, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(sz, out_mat_gapi_submat.size());
|
||||
EXPECT_EQ(sz * 2, out_mat_gapi.size());
|
||||
|
||||
@ -1526,7 +1566,7 @@ TEST_P(ReInitOutTest, TestWithAdd)
|
||||
cv::add(in_mat1, in_mat2, out_mat_ocv, cv::noArray());
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
};
|
||||
|
||||
|
@ -56,10 +56,12 @@ GAPI_TEST_FIXTURE(RGB2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cm
|
||||
GAPI_TEST_FIXTURE(BGR2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2YUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(YUV2RGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(YUV2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toRGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toBGRpTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toRGBpTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toBGRTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toGrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2LabTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BGR2LUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(LUV2BGRTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
|
@ -504,6 +504,33 @@ TEST_P(NV12toBGRTest, AccuracyTest)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(NV12toGrayTest, AccuracyTest)
|
||||
{
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in_y;
|
||||
cv::GMat in_uv;
|
||||
auto out = cv::gapi::NV12toGray(in_y, in_uv);
|
||||
|
||||
// Additional mat for uv
|
||||
cv::Mat in_mat_uv(cv::Size(sz.width / 2, sz.height / 2), CV_8UC2);
|
||||
cv::randn(in_mat_uv, cv::Scalar::all(127), cv::Scalar::all(40.f));
|
||||
|
||||
cv::GComputation c(cv::GIn(in_y, in_uv), cv::GOut(out));
|
||||
c.apply(cv::gin(in_mat1, in_mat_uv), cv::gout(out_mat_gapi), getCompileArgs());
|
||||
|
||||
cv::Mat out_mat_ocv_planar;
|
||||
cv::Mat uv_planar(in_mat1.rows / 2, in_mat1.cols, CV_8UC1, in_mat_uv.data);
|
||||
// OpenCV code /////////////////////////////////////////////////////////////
|
||||
{
|
||||
cv::vconcat(in_mat1, uv_planar, out_mat_ocv_planar);
|
||||
cv::cvtColor(out_mat_ocv_planar, out_mat_ocv, cv::COLOR_YUV2GRAY_NV12);
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
|
||||
static void toPlanar(const cv::Mat& in, cv::Mat& out)
|
||||
{
|
||||
|
@ -30,8 +30,8 @@ TEST_P(MathOperatorMatScalarTest, OperatorAccuracyTest )
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ TEST_P(MathOperatorMatMatTest, OperatorAccuracyTest )
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,8 +73,8 @@ TEST_P(NotOperatorTest, OperatorAccuracyTest)
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
ASSERT_EQ(out_mat_gapi.size(), sz);
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
}
|
||||
} // opencv_test
|
||||
|
@ -157,28 +157,6 @@ public:
|
||||
|
||||
// empty function intended to show that nothing is to be initialized via TestFunctional methods
|
||||
void initNothing(int, cv::Size, int, bool = true) {}
|
||||
|
||||
static cv::Mat nonZeroPixels(const cv::Mat& mat)
|
||||
{
|
||||
int channels = mat.channels();
|
||||
std::vector<cv::Mat> split(channels);
|
||||
cv::split(mat, split);
|
||||
cv::Mat result;
|
||||
for (int c=0; c < channels; c++)
|
||||
{
|
||||
if (c == 0)
|
||||
result = split[c] != 0;
|
||||
else
|
||||
result = result | (split[c] != 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int countNonZeroPixels(const cv::Mat& mat)
|
||||
{
|
||||
return cv::countNonZero( nonZeroPixels(mat) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@ -453,7 +431,7 @@ public:
|
||||
Mat diff;
|
||||
cv::absdiff(in1, in2, diff);
|
||||
Mat err_mask = diff > _tol;
|
||||
int err_points = cv::countNonZero(err_mask.reshape(1));
|
||||
int err_points = (cv::countNonZero)(err_mask.reshape(1));
|
||||
double max_err_points = _percent * std::max((size_t)1000, in1.total());
|
||||
if (err_points > max_err_points)
|
||||
{
|
||||
|
@ -435,6 +435,32 @@ INSTANTIATE_TEST_CASE_P(ConcatHorVecTestCPU, ConcatHorVecTest,
|
||||
Values(-1),
|
||||
Values(CORE_CPU)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(WarpPerspectiveTestCPU, WarpPerspectiveTest,
|
||||
Combine(Values(CV_8UC1, CV_8UC3),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(-1),
|
||||
Values(CORE_CPU),
|
||||
Values(AbsExact().to_compare_obj()),
|
||||
Values(-50.0, 90.0),
|
||||
Values(0.6),
|
||||
Values(cv::INTER_LINEAR),
|
||||
Values(cv::BORDER_CONSTANT),
|
||||
Values(cv::Scalar())));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(WarpAffineTestCPU, WarpAffineTest,
|
||||
Combine(Values(CV_8UC1, CV_8UC3),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(-1),
|
||||
Values(CORE_CPU),
|
||||
Values(AbsExact().to_compare_obj()),
|
||||
Values(-50.0, 90.0),
|
||||
Values(0.6),
|
||||
Values(cv::INTER_LINEAR),
|
||||
Values(cv::BORDER_CONSTANT),
|
||||
Values(cv::Scalar())));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NormalizeTestCPU, NormalizeTest,
|
||||
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
|
||||
Values(cv::Size(1280, 720),
|
||||
|
@ -244,11 +244,19 @@ INSTANTIATE_TEST_CASE_P(NV12toBGRTestCPU, NV12toBGRTest,
|
||||
Values(IMGPROC_CPU),
|
||||
Values(AbsExact().to_compare_obj())));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NV12toGrayTestCPU, NV12toGrayTest,
|
||||
Combine(Values(CV_8UC1),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(CV_8UC1),
|
||||
Values(IMGPROC_CPU),
|
||||
Values(AbsExact().to_compare_obj())));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NV12toRGBpTestCPU, NV12toRGBpTest,
|
||||
Combine(Values(CV_8UC1),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(CV_8UC3),
|
||||
Values(CV_8UC1),
|
||||
Values(IMGPROC_CPU),
|
||||
Values(AbsExact().to_compare_obj())));
|
||||
|
||||
|
@ -388,11 +388,10 @@ namespace {
|
||||
switch (arg.index()){
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>() : result.emplace_back(*util::get<cv::Mat*>(arg)); break;
|
||||
case GRunArgP::index_of<cv::Scalar*>() : result.emplace_back(*util::get<cv::Scalar*>(arg)); break;
|
||||
case GRunArgP::index_of<cv::UMat*>() : result.emplace_back(*util::get<cv::UMat*>(arg)); break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>() : result.emplace_back(*util::get<cv::gapi::own::Mat*> (arg)); break;
|
||||
case GRunArgP::index_of<cv::gapi::own::Scalar*>() : result.emplace_back(*util::get<cv::gapi::own::Scalar*>(arg)); break;
|
||||
case GRunArgP::index_of<cv::Scalar*>() : result.emplace_back(*util::get<cv::Scalar*> (arg)); break;
|
||||
case GRunArgP::index_of<cv::detail::VectorRef>() : result.emplace_back(util::get<cv::detail::VectorRef> (arg)); break;
|
||||
default : ;
|
||||
}
|
||||
@ -406,12 +405,11 @@ namespace {
|
||||
switch (arg.index()){
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>() : result.emplace_back(&util::get<cv::Mat>(arg)); break;
|
||||
case GRunArg::index_of<cv::Scalar>() : result.emplace_back(&util::get<cv::Scalar>(arg)); break;
|
||||
case GRunArg::index_of<cv::UMat>() : result.emplace_back(&util::get<cv::UMat>(arg)); break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>() : result.emplace_back(&util::get<cv::gapi::own::Mat> (arg)); break;
|
||||
case GRunArg::index_of<cv::gapi::own::Scalar>() : result.emplace_back(&util::get<cv::gapi::own::Scalar>(arg)); break;
|
||||
case GRunArg::index_of<cv::detail::VectorRef>() : result.emplace_back(util::get<cv::detail::VectorRef> (arg)); break;
|
||||
case GRunArg::index_of<cv::Scalar>() : result.emplace_back(&util::get<cv::Scalar> (arg)); break;
|
||||
case GRunArg::index_of<cv::detail::VectorRef>() : result.emplace_back(util::get<cv::detail::VectorRef> (arg)); break;
|
||||
default : ;
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ TEST_F(GAPIHeteroTest, TestOCV)
|
||||
|
||||
cv::Mat ref = ocvBar(ocvFoo(m_in_mat), ocvFoo(m_in_mat));
|
||||
EXPECT_NO_THROW(m_comp.apply(m_in_mat, m_out_mat, cv::compile_args(m_ocv_kernels)));
|
||||
EXPECT_EQ(0, cv::countNonZero(ref != m_out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ref, m_out_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST_F(GAPIHeteroTest, TestFluid)
|
||||
@ -194,7 +194,7 @@ TEST_F(GAPIHeteroTest, TestFluid)
|
||||
|
||||
cv::Mat ref = fluidBar(fluidFoo(m_in_mat), fluidFoo(m_in_mat));
|
||||
EXPECT_NO_THROW(m_comp.apply(m_in_mat, m_out_mat, cv::compile_args(m_fluid_kernels)));
|
||||
EXPECT_EQ(0, cv::countNonZero(ref != m_out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ref, m_out_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST_F(GAPIHeteroTest, TestBoth)
|
||||
@ -204,7 +204,7 @@ TEST_F(GAPIHeteroTest, TestBoth)
|
||||
|
||||
cv::Mat ref = fluidBar(ocvFoo(m_in_mat), ocvFoo(m_in_mat));
|
||||
EXPECT_NO_THROW(m_comp.apply(m_in_mat, m_out_mat, cv::compile_args(m_hetero_kernels)));
|
||||
EXPECT_EQ(0, cv::countNonZero(ref != m_out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ref, m_out_mat, NORM_INF));
|
||||
}
|
||||
|
||||
struct GAPIBigHeteroTest : public ::testing::TestWithParam<std::array<int, 9>>
|
||||
@ -271,8 +271,8 @@ GAPIBigHeteroTest::GAPIBigHeteroTest()
|
||||
TEST_P(GAPIBigHeteroTest, Test)
|
||||
{
|
||||
EXPECT_NO_THROW(m_comp.apply(gin(m_in_mat), gout(m_out_mat1, m_out_mat2), cv::compile_args(m_kernels)));
|
||||
EXPECT_EQ(0, cv::countNonZero(m_ref_mat1 != m_out_mat1));
|
||||
EXPECT_EQ(0, cv::countNonZero(m_ref_mat2 != m_out_mat2));
|
||||
EXPECT_EQ(0, cvtest::norm(m_ref_mat1, m_out_mat1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(m_ref_mat2 != m_out_mat2, NORM_INF));
|
||||
}
|
||||
|
||||
static auto configurations = []()
|
||||
@ -306,7 +306,7 @@ TEST(GAPIHeteroTestLPI, Test)
|
||||
cv::Mat out_mat;
|
||||
EXPECT_NO_THROW(c.apply(in_mat, out_mat, cv::compile_args(cv::gapi::kernels<FluidFoo2lpi>())));
|
||||
cv::Mat ref = fluidFoo(fluidFoo(in_mat));
|
||||
EXPECT_EQ(0, cv::countNonZero(ref != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ref, out_mat, NORM_INF));
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
@ -22,7 +22,7 @@ namespace {
|
||||
cv::GFluidParallelOutputRois asGFluidParallelOutputRois(const std::vector<cv::Rect>& rois){
|
||||
cv::GFluidParallelOutputRois parallel_rois;
|
||||
for (auto const& roi : rois) {
|
||||
parallel_rois.parallel_rois.emplace_back(GFluidOutputRois{{to_own(roi)}});
|
||||
parallel_rois.parallel_rois.emplace_back(GFluidOutputRois{{roi}});
|
||||
}
|
||||
return parallel_rois;
|
||||
}
|
||||
@ -156,7 +156,7 @@ TEST_P(TiledComputation, Test)
|
||||
cp->run_with_gapi(in_mat, comp_args, out_mat_gapi);
|
||||
cp->run_with_ocv (in_mat, rois, out_mat_ocv);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv))
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF))
|
||||
<< "in_mat : \n" << in_mat << std::endl
|
||||
<< "diff matrix :\n " << (out_mat_gapi != out_mat_ocv) << std::endl
|
||||
<< "out_mat_gapi: \n" << out_mat_gapi << std::endl
|
||||
|
@ -422,9 +422,7 @@ TEST_P(ResizeTestFluid, SanityTest)
|
||||
cv::blur(in_mat1, mid_mat, {3,3}, {-1,-1}, cv::BORDER_REPLICATE);
|
||||
cv::resize(mid_mat, out_mat_ocv, sz_out, fx, fy, interp);
|
||||
|
||||
cv::Mat absDiff;
|
||||
cv::absdiff(out_mat(outRoi), out_mat_ocv(outRoi), absDiff);
|
||||
EXPECT_EQ(0, cv::countNonZero(absDiff > tolerance));
|
||||
EXPECT_LE(cvtest::norm(out_mat(outRoi), out_mat_ocv(outRoi), NORM_INF), tolerance);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ResizeTestCPU, ResizeTestFluid,
|
||||
@ -618,8 +616,8 @@ TEST_P(ResizeAndAnotherReaderTest, SanityTest)
|
||||
cv::Mat ocv_blur_out = cv::Mat::zeros(sz, CV_8UC1);
|
||||
cvBlur(in_mat, ocv_blur_out, kernelSize);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(gapi_resize_out(resizedRoi) != ocv_resize_out(resizedRoi)));
|
||||
EXPECT_EQ(0, cv::countNonZero(gapi_blur_out(roi) != ocv_blur_out(roi)));
|
||||
EXPECT_EQ(0, cvtest::norm(gapi_resize_out(resizedRoi), ocv_resize_out(resizedRoi), NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(gapi_blur_out(roi), ocv_blur_out(roi), NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ResizeTestCPU, ResizeAndAnotherReaderTest,
|
||||
@ -691,8 +689,8 @@ TEST_P(BlursAfterResizeTest, SanityTest)
|
||||
cvBlur(resized, ocv_out1, kernelSize1);
|
||||
cvBlur(resized, ocv_out2, kernelSize2);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(gapi_out1(outRoi) != ocv_out1(outRoi)));
|
||||
EXPECT_EQ(0, cv::countNonZero(gapi_out2(outRoi) != ocv_out2(outRoi)));
|
||||
EXPECT_EQ(0, cvtest::norm(gapi_out1(outRoi), ocv_out1(outRoi), NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(gapi_out2(outRoi), ocv_out2(outRoi), NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ResizeTestCPU, BlursAfterResizeTest,
|
||||
@ -746,13 +744,13 @@ TEST_P(NV12PlusResizeTest, Test)
|
||||
auto pkg = cv::gapi::combine(fluidTestPackage, cv::gapi::core::fluid::kernels());
|
||||
|
||||
c.apply(cv::gin(y_mat, uv_mat), cv::gout(out_mat)
|
||||
,cv::compile_args(pkg, cv::GFluidOutputRois{{to_own(roi)}}));
|
||||
,cv::compile_args(pkg, cv::GFluidOutputRois{{roi}}));
|
||||
|
||||
cv::Mat rgb_mat;
|
||||
cv::cvtColor(in_mat, rgb_mat, cv::COLOR_YUV2RGB_NV12);
|
||||
cv::resize(rgb_mat, out_mat_ocv, out_sz, 0, 0, interp);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat(roi) != out_mat_ocv(roi)));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat(roi), out_mat_ocv(roi), NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, NV12PlusResizeTest,
|
||||
@ -825,13 +823,13 @@ TEST_P(Preproc4lpiTest, Test)
|
||||
fluidResizeTestPackage(interp, in_sz, out_sz, 4));
|
||||
|
||||
c.apply(cv::gin(y_mat, uv_mat), cv::gout(out_mat)
|
||||
,cv::compile_args(pkg, cv::GFluidOutputRois{{to_own(roi)}}));
|
||||
,cv::compile_args(pkg, cv::GFluidOutputRois{{roi}}));
|
||||
|
||||
cv::Mat rgb_mat;
|
||||
cv::cvtColor(in_mat, rgb_mat, cv::COLOR_YUV2RGB_NV12);
|
||||
cv::resize(rgb_mat, out_mat_ocv, out_sz, 0, 0, interp);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat(roi) != out_mat_ocv(roi)));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat(roi), out_mat_ocv(roi), NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, Preproc4lpiTest,
|
||||
|
@ -38,14 +38,14 @@ TEST_P(PartialComputation, Test)
|
||||
cv::Mat out_mat_ocv = cv::Mat::zeros(sz, CV_8UC1);
|
||||
|
||||
// Run G-API
|
||||
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{to_own(roi)}}));
|
||||
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{roi}}));
|
||||
cc(cv::gin(in_mat), cv::gout(out_mat_gapi));
|
||||
|
||||
// Check with OpenCV
|
||||
if (roi == cv::Rect{}) roi = cv::Rect{0,0,sz.width,sz.height};
|
||||
cv::blur(in_mat(roi), out_mat_ocv(roi), {kernelSize, kernelSize}, anchor, borderType);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, PartialComputation,
|
||||
@ -72,14 +72,14 @@ TEST_P(PartialComputationAddC, Test)
|
||||
cv::Mat out_mat_ocv = cv::Mat::zeros(sz, CV_8UC1);
|
||||
|
||||
// Run G-API
|
||||
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{to_own(roi)}}));
|
||||
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{roi}}));
|
||||
cc(cv::gin(in_mat), cv::gout(out_mat_gapi));
|
||||
|
||||
// Check with OpenCV
|
||||
if (roi == cv::Rect{}) roi = cv::Rect{0,0,sz.width,sz.height};
|
||||
out_mat_ocv(roi) = in_mat(roi) + 1;
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(FluidRoi, PartialComputationAddC,
|
||||
@ -110,7 +110,7 @@ TEST_P(SequenceOfBlursRoiTest, Test)
|
||||
Mat out_mat_gapi = Mat::zeros(sz_in, CV_8UC1);
|
||||
|
||||
GComputation c(GIn(in), GOut(out));
|
||||
auto cc = c.compile(descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{to_own(roi)}}));
|
||||
auto cc = c.compile(descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{roi}}));
|
||||
cc(gin(in_mat), gout(out_mat_gapi));
|
||||
|
||||
cv::Mat mid_mat_ocv = Mat::zeros(sz_in, CV_8UC1);
|
||||
@ -125,7 +125,7 @@ TEST_P(SequenceOfBlursRoiTest, Test)
|
||||
|
||||
cv::blur(mid_mat_ocv(roi), out_mat_ocv(roi), {5,5}, anchor, borderType);
|
||||
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(FluidRoi, SequenceOfBlursRoiTest,
|
||||
@ -180,8 +180,8 @@ TEST_P(TwoBlursRoiTest, Test)
|
||||
cv::blur(in_mat(outRoi), out_mat_ocv1(outRoi), {kernelSize1, kernelSize1}, anchor, borderType1);
|
||||
cv::blur(in_mat(outRoi), out_mat_ocv2(outRoi), {kernelSize2, kernelSize2}, anchor, borderType2);
|
||||
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv1 != out_mat_gapi1));
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv2 != out_mat_gapi2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv1, out_mat_gapi1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv2, out_mat_gapi2, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(FluidRoi, TwoBlursRoiTest,
|
||||
|
@ -64,7 +64,7 @@ TEST(FluidBuffer, InputTest)
|
||||
view.priv().readDone(1,1);
|
||||
|
||||
cv::Mat from_buffer(1, buffer_size.width, CV_8U, const_cast<uint8_t*>(rrow));
|
||||
EXPECT_EQ(0, cv::countNonZero(in_mat.row(this_y) != from_buffer));
|
||||
EXPECT_EQ(0, cvtest::norm(in_mat.row(this_y), from_buffer, NORM_INF));
|
||||
|
||||
this_y++;
|
||||
}
|
||||
@ -75,7 +75,7 @@ TEST(FluidBuffer, CircularTest)
|
||||
const cv::Size buffer_size = {8,16};
|
||||
|
||||
cv::gapi::fluid::Buffer buffer(cv::GMatDesc{CV_8U,1,buffer_size}, 3, 1, 0, 1,
|
||||
util::make_optional(cv::gapi::fluid::Border{cv::BORDER_CONSTANT, cv::gapi::own::Scalar(255)}));
|
||||
util::make_optional(cv::gapi::fluid::Border{cv::BORDER_CONSTANT, cv::Scalar(255)}));
|
||||
cv::gapi::fluid::View view = buffer.mkView(1, {});
|
||||
view.priv().reset(3);
|
||||
view.priv().allocate(3, {});
|
||||
@ -141,9 +141,9 @@ TEST(FluidBuffer, CircularTest)
|
||||
cv::Mat read_thisLine(1, buffer_size.width, CV_8U, const_cast<uint8_t*>(rrow[1]));
|
||||
cv::Mat read_nextLine(1, buffer_size.width, CV_8U, const_cast<uint8_t*>(rrow[2]));
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(written_lastLine2 != read_prevLine));
|
||||
EXPECT_EQ(0, cv::countNonZero(written_lastLine1 != read_thisLine));
|
||||
EXPECT_EQ(0, cv::countNonZero(written_lastLine0 != read_nextLine));
|
||||
EXPECT_EQ(0, cvtest::norm(written_lastLine2, read_prevLine, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(written_lastLine1, read_thisLine, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(written_lastLine0, read_nextLine, NORM_INF));
|
||||
}
|
||||
num_reads++;
|
||||
}
|
||||
@ -190,7 +190,7 @@ TEST(Fluid, AddC_WithScalar)
|
||||
|
||||
cc(cv::gin(in_mat, in_s), cv::gout(out_mat));
|
||||
ref_mat = in_mat + in_s;
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, Scalar_In_Middle_Graph)
|
||||
@ -206,7 +206,7 @@ TEST(Fluid, Scalar_In_Middle_Graph)
|
||||
|
||||
cc(cv::gin(in_mat, in_s), cv::gout(out_mat));
|
||||
ref_mat = (in_mat + 5) + in_s;
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, Add_Scalar_To_Mat)
|
||||
@ -222,7 +222,7 @@ TEST(Fluid, Add_Scalar_To_Mat)
|
||||
|
||||
cc(cv::gin(in_s, in_mat), cv::gout(out_mat));
|
||||
ref_mat = in_mat + in_s;
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, Sum_2_Mats_And_Scalar)
|
||||
@ -241,7 +241,7 @@ TEST(Fluid, Sum_2_Mats_And_Scalar)
|
||||
|
||||
cc(cv::gin(in_mat1, in_s, in_mat2), cv::gout(out_mat));
|
||||
ref_mat = in_mat1 + in_mat2 + in_s;
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, EqualizeHist)
|
||||
@ -261,7 +261,7 @@ TEST(Fluid, EqualizeHist)
|
||||
|
||||
cv::equalizeHist(in_mat, ref_mat);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, Split3)
|
||||
@ -290,7 +290,7 @@ TEST(Fluid, Split3)
|
||||
cv::split(in_mat, chans);
|
||||
|
||||
// Compare
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != (chans[2]*3)));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, Mat(chans[2]*3), NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, ScratchTest)
|
||||
@ -319,11 +319,11 @@ TEST(Fluid, ScratchTest)
|
||||
cv::compile_args(fluidTestPackage));
|
||||
cc(in_mat, out_mat);
|
||||
GAPI_LOG_INFO(NULL, "\n" << out_mat);
|
||||
EXPECT_EQ(0, cv::countNonZero(ref != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ref, out_mat, NORM_INF));
|
||||
|
||||
cc(in_mat, out_mat);
|
||||
GAPI_LOG_INFO(NULL, "\n" << out_mat);
|
||||
EXPECT_EQ(0, cv::countNonZero(ref != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ref, out_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, MultipleOutRowsTest)
|
||||
@ -343,7 +343,7 @@ TEST(Fluid, MultipleOutRowsTest)
|
||||
std::cout << out_mat << std::endl;
|
||||
|
||||
cv::Mat ocv_ref = in_mat + 1 + 2;
|
||||
EXPECT_EQ(0, cv::countNonZero(ocv_ref != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ocv_ref, out_mat, NORM_INF));
|
||||
}
|
||||
|
||||
|
||||
@ -374,7 +374,7 @@ TEST(Fluid, LPIWindow)
|
||||
// OpenCV reference
|
||||
cv::Mat ocv_ref = eyes[0]+eyes[1]+eyes[2];
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(ocv_ref != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ocv_ref, out_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, MultipleReaders_SameLatency)
|
||||
@ -403,7 +403,7 @@ TEST(Fluid, MultipleReaders_SameLatency)
|
||||
// Check with OpenCV
|
||||
cv::Mat tmp = in_mat + 1;
|
||||
out_mat_ocv = (tmp+2) + (tmp+3);
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, MultipleReaders_DifferentLatency)
|
||||
@ -437,7 +437,7 @@ TEST(Fluid, MultipleReaders_DifferentLatency)
|
||||
cv::Mat ocv_d = ocv_a;
|
||||
cv::Mat ocv_c = ocv_a + ocv_d;
|
||||
cv::Mat out_mat_ocv = ocv_b + ocv_c;
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, MultipleOutputs)
|
||||
@ -464,8 +464,8 @@ TEST(Fluid, MultipleOutputs)
|
||||
// Check with OpenCV
|
||||
out_mat_ocv1 = in_mat + 1 + 2;
|
||||
out_mat_ocv2 = in_mat + 1 + 7;
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi1 != out_mat_ocv1));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi2 != out_mat_ocv2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi1, out_mat_ocv1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi2, out_mat_ocv2, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Fluid, EmptyOutputMatTest)
|
||||
@ -509,7 +509,7 @@ TEST_P(LPISequenceTest, LPISequenceTest)
|
||||
|
||||
// Check with OpenCV
|
||||
cv::blur(in_mat + 1, out_mat_ocv, {kernelSize,kernelSize}, {-1,-1}, cv::BORDER_CONSTANT);
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, LPISequenceTest,
|
||||
@ -547,7 +547,7 @@ TEST_P(InputImageBorderTest, InputImageBorderTest)
|
||||
cv::Mat out_mat_ocv = Mat::zeros(sz_in, CV_8UC1);
|
||||
cv::blur(in_mat1, out_mat_ocv, kernelSize, anchor, borderType);
|
||||
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, InputImageBorderTest,
|
||||
@ -585,7 +585,7 @@ TEST_P(SequenceOfBlursTest, Test)
|
||||
cv::blur(in_mat, mid_mat_ocv, {3,3}, anchor, borderType);
|
||||
cv::blur(mid_mat_ocv, out_mat_ocv, {5,5}, anchor, borderType);
|
||||
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv != out_mat_gapi));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv, out_mat_gapi, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, SequenceOfBlursTest,
|
||||
@ -637,8 +637,8 @@ TEST_P(TwoBlursTest, Test)
|
||||
cv::blur(in_mat, out_mat_ocv1, {kernelSize1, kernelSize1}, anchor, borderType1);
|
||||
cv::blur(in_mat, out_mat_ocv2, {kernelSize2, kernelSize2}, anchor, borderType2);
|
||||
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv1 != out_mat_gapi1));
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv2 != out_mat_gapi2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv1, out_mat_gapi1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv2, out_mat_gapi2, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, TwoBlursTest,
|
||||
@ -695,8 +695,8 @@ TEST_P(TwoReadersTest, Test)
|
||||
out_mat_ocv1 = in_mat;
|
||||
cv::blur(in_mat, out_mat_ocv2, {kernelSize, kernelSize}, anchor, borderType);
|
||||
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv1 != out_mat_gapi1));
|
||||
EXPECT_EQ(0, countNonZero(out_mat_ocv2 != out_mat_gapi2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv1, out_mat_gapi1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_ocv2, out_mat_gapi2, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, TwoReadersTest,
|
||||
@ -726,8 +726,8 @@ TEST(FluidTwoIslands, SanityTest)
|
||||
|
||||
GComputation c(GIn(in1, in2), GOut(out1, out2));
|
||||
EXPECT_NO_THROW(c.apply(gin(in_mat1, in_mat2), gout(out_mat1, out_mat2), cv::compile_args(fluidTestPackage)));
|
||||
EXPECT_EQ(0, countNonZero(in_mat1 != out_mat1));
|
||||
EXPECT_EQ(0, countNonZero(in_mat2 != out_mat2));
|
||||
EXPECT_EQ(0, cvtest::norm(in_mat1, out_mat1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(in_mat2, out_mat2, NORM_INF));
|
||||
}
|
||||
|
||||
struct NV12RoiTest : public TestWithParam <std::pair<cv::Size, cv::Rect>> {};
|
||||
@ -754,11 +754,11 @@ TEST_P(NV12RoiTest, Test)
|
||||
auto rgb = cv::gapi::NV12toRGB(y, uv);
|
||||
cv::GComputation c(cv::GIn(y, uv), cv::GOut(rgb));
|
||||
|
||||
c.apply(cv::gin(y_mat, uv_mat), cv::gout(out_mat), cv::compile_args(fluidTestPackage, cv::GFluidOutputRois{{to_own(roi)}}));
|
||||
c.apply(cv::gin(y_mat, uv_mat), cv::gout(out_mat), cv::compile_args(fluidTestPackage, cv::GFluidOutputRois{{roi}}));
|
||||
|
||||
cv::cvtColor(in_mat, out_mat_ocv, cv::COLOR_YUV2RGB_NV12);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat(roi) != out_mat_ocv(roi)));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat(roi), out_mat_ocv(roi), NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Fluid, NV12RoiTest,
|
||||
@ -835,7 +835,7 @@ TEST(Fluid, InvalidROIs)
|
||||
};
|
||||
|
||||
const auto compile_args = [] (cv::Rect roi) {
|
||||
return cv::compile_args(cv::gapi::core::fluid::kernels(), GFluidOutputRois{{to_own(roi)}});
|
||||
return cv::compile_args(cv::gapi::core::fluid::kernels(), GFluidOutputRois{{roi}});
|
||||
};
|
||||
|
||||
for (const auto& roi : invalid_rois)
|
||||
|
@ -184,7 +184,7 @@ GAPI_FLUID_KERNEL(FBlur3x3, TBlur3x3, false)
|
||||
|
||||
static cv::gapi::fluid::Border getBorder(const cv::GMatDesc &/*src*/, int borderType, cv::Scalar borderValue)
|
||||
{
|
||||
return { borderType, to_own(borderValue)};
|
||||
return { borderType, borderValue};
|
||||
}
|
||||
};
|
||||
|
||||
@ -200,7 +200,7 @@ GAPI_FLUID_KERNEL(FBlur5x5, TBlur5x5, false)
|
||||
|
||||
static cv::gapi::fluid::Border getBorder(const cv::GMatDesc &/*src*/, int borderType, cv::Scalar borderValue)
|
||||
{
|
||||
return { borderType, to_own(borderValue)};
|
||||
return { borderType, borderValue};
|
||||
}
|
||||
};
|
||||
|
||||
@ -217,7 +217,7 @@ GAPI_FLUID_KERNEL(FBlur3x3_2lpi, TBlur3x3_2lpi, false)
|
||||
|
||||
static cv::gapi::fluid::Border getBorder(const cv::GMatDesc &/*src*/, int borderType, cv::Scalar borderValue)
|
||||
{
|
||||
return { borderType, to_own(borderValue)};
|
||||
return { borderType, borderValue};
|
||||
}
|
||||
};
|
||||
|
||||
@ -234,7 +234,7 @@ GAPI_FLUID_KERNEL(FBlur5x5_2lpi, TBlur5x5_2lpi, false)
|
||||
|
||||
static cv::gapi::fluid::Border getBorder(const cv::GMatDesc &/*src*/, int borderType, cv::Scalar borderValue)
|
||||
{
|
||||
return { borderType, to_own(borderValue )};
|
||||
return { borderType, borderValue};
|
||||
}
|
||||
};
|
||||
|
||||
@ -261,7 +261,7 @@ GAPI_FLUID_KERNEL(FIdentity, TId, false)
|
||||
|
||||
static gapi::fluid::Border getBorder(const cv::GMatDesc &)
|
||||
{
|
||||
return { cv::BORDER_REPLICATE, cv::gapi::own::Scalar{} };
|
||||
return { cv::BORDER_REPLICATE, cv::Scalar{} };
|
||||
}
|
||||
};
|
||||
|
||||
@ -308,7 +308,7 @@ GAPI_FLUID_KERNEL(FId7x7, TId7x7, false)
|
||||
|
||||
static cv::gapi::fluid::Border getBorder(const cv::GMatDesc&/* src*/)
|
||||
{
|
||||
return { cv::BORDER_REPLICATE, cv::gapi::own::Scalar{} };
|
||||
return { cv::BORDER_REPLICATE, cv::Scalar{} };
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,7 @@ TEST_F(GCompiledValidateMetaTyped, ValidMeta)
|
||||
|
||||
TEST_F(GCompiledValidateMetaTyped, InvalidMeta)
|
||||
{
|
||||
auto f = m_cc.compile(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(64,32)},
|
||||
auto f = m_cc.compile(cv::GMatDesc{CV_8U,1,cv::Size(64,32)},
|
||||
cv::empty_scalar_desc());
|
||||
|
||||
cv::Scalar sc(33);
|
||||
@ -106,7 +106,7 @@ TEST_F(GCompiledValidateMetaUntyped, ValidMeta)
|
||||
|
||||
TEST_F(GCompiledValidateMetaUntyped, InvalidMetaValues)
|
||||
{
|
||||
auto f = m_ucc.compile(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(64,32)},
|
||||
auto f = m_ucc.compile(cv::GMatDesc{CV_8U,1,cv::Size(64,32)},
|
||||
cv::empty_scalar_desc());
|
||||
|
||||
cv::Scalar sc(33);
|
||||
@ -131,7 +131,7 @@ TEST_F(GCompiledValidateMetaUntyped, InvalidMetaValues)
|
||||
|
||||
TEST_F(GCompiledValidateMetaUntyped, InvalidMetaShape)
|
||||
{
|
||||
auto f = m_ucc.compile(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(64,32)},
|
||||
auto f = m_ucc.compile(cv::GMatDesc{CV_8U,1,cv::Size(64,32)},
|
||||
cv::empty_scalar_desc());
|
||||
|
||||
cv::Mat in1 = cv::Mat::eye(cv::Size(64,32), CV_8UC1);
|
||||
|
@ -19,13 +19,13 @@ namespace opencv_test
|
||||
static cv::GMatDesc outMeta(cv::GMatDesc in, cv::Size sz, double fx, double fy, int) {
|
||||
if (sz.width != 0 && sz.height != 0)
|
||||
{
|
||||
return in.withSize(to_own(sz));
|
||||
return in.withSize(sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
GAPI_Assert(fx != 0. && fy != 0.);
|
||||
return in.withSize
|
||||
(cv::gapi::own::Size(static_cast<int>(std::round(in.size.width * fx)),
|
||||
(cv::Size(static_cast<int>(std::round(in.size.width * fx)),
|
||||
static_cast<int>(std::round(in.size.height * fy))));
|
||||
}
|
||||
}
|
||||
@ -83,7 +83,7 @@ namespace opencv_test
|
||||
const auto& ref_mat = std::get<0>(it);
|
||||
const auto& out_mat = std::get<1>(it);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(ref_mat != out_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(ref_mat, out_mat, NORM_INF));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include <opencv2/gapi/cpu/gcpukernel.hpp>
|
||||
#include "gapi_mock_kernels.hpp"
|
||||
|
||||
#include <opencv2/gapi/cpu/gcpukernel.hpp> // cpu::backend
|
||||
|
197
inference-engine/thirdparty/fluid/modules/gapi/test/gapi_opaque_tests.cpp
vendored
Normal file
197
inference-engine/thirdparty/fluid/modules/gapi/test/gapi_opaque_tests.cpp
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
namespace ThisTest
|
||||
{
|
||||
using GPointOpaque = cv::GOpaque<cv::Point>;
|
||||
|
||||
G_TYPED_KERNEL(GeneratePoint, <GPointOpaque(GMat)>, "test.opaque.gen_point")
|
||||
{
|
||||
static GOpaqueDesc outMeta(const GMatDesc&) { return empty_gopaque_desc(); }
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(FillMat, <GMat(cv::GOpaque<int>, int, int, cv::Size)>, "test.opaque.fill_mat")
|
||||
{
|
||||
static GMatDesc outMeta(const GOpaqueDesc&, int depth, int chan, cv::Size size)
|
||||
{
|
||||
return cv::GMatDesc{depth, chan, size};
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(PaintPoint, <GMat(GPointOpaque, int, int, cv::Size)>, "test.opaque.paint_point")
|
||||
{
|
||||
static GMatDesc outMeta(const GOpaqueDesc&, int depth, int chan, cv::Size size)
|
||||
{
|
||||
return cv::GMatDesc{depth, chan, size};
|
||||
}
|
||||
};
|
||||
|
||||
struct MyCustomType{
|
||||
int num = -1;
|
||||
std::string s;
|
||||
};
|
||||
|
||||
using GOpaq2 = std::tuple<GOpaque<MyCustomType>,GOpaque<MyCustomType>>;
|
||||
|
||||
G_TYPED_KERNEL_M(GenerateOpaque, <GOpaq2(GMat, GMat, std::string)>, "test.opaque.gen_point_multy")
|
||||
{
|
||||
static std::tuple<GOpaqueDesc, GOpaqueDesc> outMeta(const GMatDesc&, const GMatDesc&, std::string)
|
||||
{
|
||||
return std::make_tuple(empty_gopaque_desc(), empty_gopaque_desc());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ThisTest
|
||||
|
||||
namespace
|
||||
{
|
||||
GAPI_OCV_KERNEL(OCVGeneratePoint, ThisTest::GeneratePoint)
|
||||
{
|
||||
static void run(const cv::Mat&, cv::Point& out)
|
||||
{
|
||||
out = cv::Point(42, 42);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(OCVFillMat, ThisTest::FillMat)
|
||||
{
|
||||
static void run(int a, int, int, cv::Size, cv::Mat& out)
|
||||
{
|
||||
out = cv::Scalar(a);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(OCVPaintPoint, ThisTest::PaintPoint)
|
||||
{
|
||||
static void run(cv::Point a, int, int, cv::Size, cv::Mat& out)
|
||||
{
|
||||
out.at<uint8_t>(a) = 77;
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(OCVGenerateOpaque, ThisTest::GenerateOpaque)
|
||||
{
|
||||
static void run(const cv::Mat& a, const cv::Mat& b, const std::string& s,
|
||||
ThisTest::MyCustomType &out1, ThisTest::MyCustomType &out2)
|
||||
{
|
||||
out1.num = a.size().width * a.size().height;
|
||||
out1.s = s;
|
||||
|
||||
out2.num = b.size().width * b.size().height;
|
||||
auto s2 = s;
|
||||
std::reverse(s2.begin(), s2.end());
|
||||
out2.s = s2;
|
||||
}
|
||||
};
|
||||
} // (anonymous namespace)
|
||||
|
||||
TEST(GOpaque, TestOpaqueOut)
|
||||
{
|
||||
cv::Mat input = cv::Mat(52, 52, CV_8U);
|
||||
cv::Point point;
|
||||
|
||||
cv::GMat in;
|
||||
auto out = ThisTest::GeneratePoint::on(in);
|
||||
|
||||
cv::GComputation c(cv::GIn(in), cv::GOut(out));
|
||||
c.apply(cv::gin(input), cv::gout(point), cv::compile_args(cv::gapi::kernels<OCVGeneratePoint>()));
|
||||
|
||||
EXPECT_TRUE(point == cv::Point(42, 42));
|
||||
}
|
||||
|
||||
TEST(GOpaque, TestOpaqueIn)
|
||||
{
|
||||
cv::Size sz = {42, 42};
|
||||
int depth = CV_8U;
|
||||
int chan = 1;
|
||||
cv::Mat mat = cv::Mat(sz, CV_MAKETYPE(depth, chan));
|
||||
int fill = 0;
|
||||
|
||||
cv::GOpaque<int> in;
|
||||
auto out = ThisTest::FillMat::on(in, depth, chan, sz);
|
||||
|
||||
cv::GComputation c(cv::GIn(in), cv::GOut(out));
|
||||
c.apply(cv::gin(fill), cv::gout(mat), cv::compile_args(cv::gapi::kernels<OCVFillMat>()));
|
||||
|
||||
auto diff = cv::Mat(sz, CV_MAKETYPE(depth, chan), cv::Scalar(fill)) - mat;
|
||||
EXPECT_EQ(0, cvtest::norm(diff, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GOpaque, TestOpaqueBetween)
|
||||
{
|
||||
cv::Size sz = {50, 50};
|
||||
int depth = CV_8U;
|
||||
int chan = 1;
|
||||
cv::Mat mat_in = cv::Mat::zeros(sz, CV_MAKETYPE(depth, chan));
|
||||
cv::Mat mat_out = cv::Mat::zeros(sz, CV_MAKETYPE(depth, chan));
|
||||
|
||||
cv::GMat in, out;
|
||||
auto betw = ThisTest::GeneratePoint::on(in);
|
||||
out = ThisTest::PaintPoint::on(betw, depth, chan, sz);
|
||||
|
||||
cv::GComputation c(cv::GIn(in), cv::GOut(out));
|
||||
c.apply(cv::gin(mat_in), cv::gout(mat_out), cv::compile_args(cv::gapi::kernels<OCVGeneratePoint, OCVPaintPoint>()));
|
||||
|
||||
int painted = mat_out.at<uint8_t>(42, 42);
|
||||
EXPECT_EQ(painted, 77);
|
||||
}
|
||||
|
||||
TEST(GOpaque, TestOpaqueCustomOut2)
|
||||
{
|
||||
cv::Mat input1 = cv::Mat(52, 52, CV_8U);
|
||||
cv::Mat input2 = cv::Mat(42, 42, CV_8U);
|
||||
std::string str = "opaque";
|
||||
std::string str2 = str;
|
||||
std::reverse(str2.begin(), str2.end());
|
||||
|
||||
ThisTest::MyCustomType out1, out2;
|
||||
|
||||
cv::GMat in1, in2;
|
||||
auto out = ThisTest::GenerateOpaque::on(in1, in2, str);
|
||||
|
||||
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(std::get<0>(out), std::get<1>(out)));
|
||||
c.apply(cv::gin(input1, input2), cv::gout(out1, out2), cv::compile_args(cv::gapi::kernels<OCVGenerateOpaque>()));
|
||||
|
||||
EXPECT_EQ(out1.num, input1.size().width * input1.size().height);
|
||||
EXPECT_EQ(out1.s, str);
|
||||
|
||||
EXPECT_EQ(out2.num, input2.size().width * input2.size().height);
|
||||
EXPECT_EQ(out2.s, str2);
|
||||
}
|
||||
|
||||
TEST(GOpaque_OpaqueRef, TestMov)
|
||||
{
|
||||
// Warning: this test is testing some not-very-public APIs
|
||||
// Test how OpaqueRef's mov() (aka poor man's move()) is working.
|
||||
|
||||
using I = std::string;
|
||||
|
||||
std::string str = "this string must be long due to short string optimization";
|
||||
const I gold(str);
|
||||
|
||||
I test = gold;
|
||||
const char* ptr = test.data();
|
||||
|
||||
cv::detail::OpaqueRef ref(test);
|
||||
cv::detail::OpaqueRef mov;
|
||||
mov.reset<I>();
|
||||
|
||||
EXPECT_EQ(gold, ref.rref<I>()); // ref = gold
|
||||
|
||||
mov.mov(ref);
|
||||
EXPECT_EQ(gold, mov.rref<I>()); // mov obtained the data
|
||||
EXPECT_EQ(ptr, mov.rref<I>().data()); // pointer is unchanged (same data)
|
||||
EXPECT_EQ(test, ref.rref<I>()); // ref = test
|
||||
EXPECT_NE(test, mov.rref<I>()); // ref lost the data
|
||||
}
|
||||
} // namespace opencv_test
|
@ -131,7 +131,7 @@ TEST_P(PlanarTest, Resize3c3p)
|
||||
cv::resize(in_mat, resized_mat, out_sz, 0, 0, interp);
|
||||
toPlanar(resized_mat, out_mat_ocv);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
TEST_P(PlanarTest, Resize3p3p)
|
||||
@ -161,7 +161,7 @@ TEST_P(PlanarTest, Resize3p3p)
|
||||
cv::resize(in_mat_roi, out_mat_roi, out_sz, 0, 0, interp);
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
TEST_P(PlanarTest, Pipeline)
|
||||
@ -193,7 +193,7 @@ TEST_P(PlanarTest, Pipeline)
|
||||
cv::resize(rgb, resized_mat, out_sz, 0, 0, interp);
|
||||
toPlanar(resized_mat, out_mat_ocv);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Sanity, PlanarTest,
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include <ade/util/iota_range.hpp>
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
@ -42,6 +44,11 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GCustom, <GMat(GMat)>, "org.opencv.test.custom")
|
||||
{
|
||||
static GMatDesc outMeta(GMatDesc in) { return in; }
|
||||
};
|
||||
|
||||
// These definitons test the correct macro work if the kernel has multiple output values
|
||||
G_TYPED_KERNEL(GRetGArrayTupleOfGMat2Kernel, <GArray<std::tuple<GMat, GMat>>(GMat, Scalar)>, "org.opencv.test.retarrayoftupleofgmat2kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat3Kernel, <GArray<std::tuple<GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat3kernel") {};
|
||||
@ -74,12 +81,12 @@ TEST(GAPI_Pipeline, OverloadUnary_MatMat)
|
||||
|
||||
cv::Mat out_mat;
|
||||
comp.apply(in_mat, out_mat);
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
|
||||
out_mat = cv::Mat();
|
||||
auto cc = comp.compile(cv::descr_of(in_mat));
|
||||
cc(in_mat, out_mat);
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GAPI_Pipeline, OverloadUnary_MatScalar)
|
||||
@ -110,12 +117,12 @@ TEST(GAPI_Pipeline, OverloadBinary_Mat)
|
||||
|
||||
cv::Mat out_mat;
|
||||
comp.apply(in_mat, in_mat, out_mat);
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
|
||||
out_mat = cv::Mat();
|
||||
auto cc = comp.compile(cv::descr_of(in_mat), cv::descr_of(in_mat));
|
||||
cc(in_mat, in_mat, out_mat);
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GAPI_Pipeline, OverloadBinary_Scalar)
|
||||
@ -186,9 +193,9 @@ TEST(GAPI_Pipeline, Sharpen)
|
||||
cv::Mat diff = out_mat_ocv != out_mat;
|
||||
std::vector<cv::Mat> diffBGR(3);
|
||||
cv::split(diff, diffBGR);
|
||||
EXPECT_EQ(0, cv::countNonZero(diffBGR[0]));
|
||||
EXPECT_EQ(0, cv::countNonZero(diffBGR[1]));
|
||||
EXPECT_EQ(0, cv::countNonZero(diffBGR[2]));
|
||||
EXPECT_EQ(0, cvtest::norm(diffBGR[0], NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(diffBGR[1], NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(diffBGR[2], NORM_INF));
|
||||
}
|
||||
|
||||
// Metadata check /////////////////////////////////////////////////////////
|
||||
@ -276,9 +283,9 @@ TEST(GAPI_Pipeline, CustomRGB2YUV)
|
||||
diff_u = diff(out_mats_cv[1], out_mats_gapi[1], 2),
|
||||
diff_v = diff(out_mats_cv[2], out_mats_gapi[2], 2);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_y));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_u));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_v));
|
||||
EXPECT_EQ(0, cvtest::norm(diff_y, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(diff_u, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(diff_v, NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,4 +342,107 @@ TEST(GAPI_Pipeline, CanUseOwnMatAsOutput)
|
||||
EXPECT_NO_THROW(comp.apply({in_own_mat}, {out_own_mat}));
|
||||
}
|
||||
|
||||
TEST(GAPI_Pipeline, CreateKernelImplFromLambda)
|
||||
{
|
||||
cv::Size size(300, 300);
|
||||
int type = CV_8UC3;
|
||||
cv::Mat in_mat(size, type);
|
||||
cv::randu(in_mat, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
int value = 5;
|
||||
|
||||
cv::GMat in;
|
||||
cv::GMat out = GCustom::on(in);
|
||||
cv::GComputation comp(in, out);
|
||||
|
||||
// OpenCV //////////////////////////////////////////////////////////////////////////
|
||||
auto ref_mat = in_mat + value;
|
||||
|
||||
// G-API //////////////////////////////////////////////////////////////////////////
|
||||
auto impl = cv::gapi::cpu::ocv_kernel<GCustom>([&value](const cv::Mat& src, cv::Mat& dst)
|
||||
{
|
||||
dst = src + value;
|
||||
});
|
||||
|
||||
cv::Mat out_mat;
|
||||
auto pkg = cv::gapi::kernels(impl);
|
||||
comp.apply(in_mat, out_mat, cv::compile_args(pkg));
|
||||
|
||||
EXPECT_EQ(0, cv::norm(out_mat, ref_mat));
|
||||
}
|
||||
|
||||
TEST(GAPI_Pipeline, ReplaceDefaultByLambda)
|
||||
{
|
||||
cv::Size size(300, 300);
|
||||
int type = CV_8UC3;
|
||||
cv::Mat in_mat1(size, type);
|
||||
cv::Mat in_mat2(size, type);
|
||||
cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
|
||||
cv::GMat in1, in2;
|
||||
cv::GMat out = cv::gapi::add(in1, in2);
|
||||
cv::GComputation comp(cv::GIn(in1, in2), cv::GOut(out));
|
||||
|
||||
// OpenCV //////////////////////////////////////////////////////////////////////////
|
||||
cv::Mat ref_mat = in_mat1 + in_mat2;
|
||||
|
||||
|
||||
// G-API //////////////////////////////////////////////////////////////////////////
|
||||
bool is_called = false;
|
||||
auto impl = cv::gapi::cpu::ocv_kernel<cv::gapi::core::GAdd>([&is_called]
|
||||
(const cv::Mat& src1, const cv::Mat& src2, int, cv::Mat& dst)
|
||||
{
|
||||
is_called = true;
|
||||
dst = src1 + src2;
|
||||
});
|
||||
|
||||
cv::Mat out_mat;
|
||||
auto pkg = cv::gapi::kernels(impl);
|
||||
comp.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat), cv::compile_args(pkg));
|
||||
|
||||
EXPECT_EQ(0, cv::norm(out_mat, ref_mat));
|
||||
EXPECT_TRUE(is_called);
|
||||
}
|
||||
|
||||
struct AddImpl
|
||||
{
|
||||
void operator()(const cv::Mat& in1, const cv::Mat& in2, int, cv::Mat& out)
|
||||
{
|
||||
out = in1 + in2;
|
||||
is_called = true;
|
||||
}
|
||||
|
||||
bool is_called = false;
|
||||
};
|
||||
|
||||
TEST(GAPI_Pipeline, ReplaceDefaultByFunctor)
|
||||
{
|
||||
cv::Size size(300, 300);
|
||||
int type = CV_8UC3;
|
||||
cv::Mat in_mat1(size, type);
|
||||
cv::Mat in_mat2(size, type);
|
||||
cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
|
||||
cv::GMat in1, in2;
|
||||
cv::GMat out = cv::gapi::add(in1, in2);
|
||||
cv::GComputation comp(cv::GIn(in1, in2), cv::GOut(out));
|
||||
|
||||
// OpenCV //////////////////////////////////////////////////////////////////////////
|
||||
cv::Mat ref_mat = in_mat1 + in_mat2;
|
||||
|
||||
|
||||
// G-API ///////////////////////////////////////////////////////////////////////////
|
||||
AddImpl f;
|
||||
EXPECT_FALSE(f.is_called);
|
||||
auto impl = cv::gapi::cpu::ocv_kernel<cv::gapi::core::GAdd>(f);
|
||||
|
||||
cv::Mat out_mat;
|
||||
auto pkg = cv::gapi::kernels(impl);
|
||||
comp.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat), cv::compile_args(pkg));
|
||||
|
||||
EXPECT_EQ(0, cv::norm(out_mat, ref_mat));
|
||||
EXPECT_TRUE(f.is_called);
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
@ -27,7 +27,7 @@ TEST(GAPI_Scalar, Argument)
|
||||
mulS.apply(in_mat, cv::Scalar(2), out_mat);
|
||||
|
||||
cv::Mat reference = in_mat*2;
|
||||
EXPECT_EQ(0, cv::countNonZero(cv::abs(out_mat - reference)));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, reference, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GAPI_Scalar, ReturnValue)
|
||||
@ -60,7 +60,7 @@ TEST(GAPI_Scalar, TmpScalar)
|
||||
mul_by_sum.apply(in_mat, out_mat);
|
||||
|
||||
cv::Mat reference = cv::Mat(sz, CV_8U, cv::Scalar(4));
|
||||
EXPECT_EQ(0, cv::countNonZero(cv::abs(out_mat - reference)));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, reference, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GAPI_ScalarWithValue, Simple_Arithmetic_Pipeline)
|
||||
@ -75,7 +75,7 @@ TEST(GAPI_ScalarWithValue, Simple_Arithmetic_Pipeline)
|
||||
ref_mat = (in_mat + 1) * 2;
|
||||
comp.apply(in_mat, out_mat);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GAPI_ScalarWithValue, GScalar_Initilization)
|
||||
@ -90,7 +90,7 @@ TEST(GAPI_ScalarWithValue, GScalar_Initilization)
|
||||
cv::multiply(in_mat, sc, ref_mat, 1, CV_8UC1);
|
||||
comp.apply(cv::gin(in_mat), cv::gout(out_mat));
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GAPI_ScalarWithValue, Constant_GScalar_In_Middle_Graph)
|
||||
@ -111,7 +111,7 @@ TEST(GAPI_ScalarWithValue, Constant_GScalar_In_Middle_Graph)
|
||||
cv::multiply(add_mat, sc, ref_mat, 1, CV_8UC1);
|
||||
comp.apply(cv::gin(in_mat, in_scalar), cv::gout(out_mat));
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat != ref_mat));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat, ref_mat, NORM_INF));
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
@ -91,7 +91,7 @@ TEST(GAPI, EmptyOutMat)
|
||||
EXPECT_EQ(640, out.cols);
|
||||
EXPECT_EQ(480, out.rows);
|
||||
EXPECT_EQ(CV_8U, out.type());
|
||||
EXPECT_EQ(0, cv::countNonZero(out - (in_mat+in_mat)));
|
||||
EXPECT_EQ(0, cvtest::norm(out, (in_mat+in_mat), NORM_INF));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,10 +22,27 @@ using GMat2 = std::tuple<GMat, GMat>;
|
||||
using GMat3 = std::tuple<GMat, GMat, GMat>;
|
||||
using GScalar = cv::GScalar;
|
||||
template <typename T> using GArray = cv::GArray<T>;
|
||||
template <typename T> using GOpaque = cv::GOpaque<T>;
|
||||
|
||||
using ArrayT = int;
|
||||
using WrongArrayT = char;
|
||||
|
||||
struct CustomType{
|
||||
cv::Mat mat;
|
||||
int i;
|
||||
void *v;
|
||||
CustomType* next;
|
||||
};
|
||||
|
||||
struct AnotherCustomType{
|
||||
cv::Mat mat;
|
||||
int i;
|
||||
void *v;
|
||||
};
|
||||
|
||||
using OpaqueT = CustomType;
|
||||
using WrongOpaqueT = AnotherCustomType;
|
||||
|
||||
GAPI_TRANSFORM(gmat_in_gmat_out, <GMat(GMat)>, "gmat_in_gmat_out")
|
||||
{
|
||||
static GMat pattern(GMat) { return {}; }
|
||||
@ -92,6 +109,36 @@ GAPI_TRANSFORM(gmat_gsc_garray_in_gmat2_out, <GMat2(GMat, GScalar, GArray<ArrayT
|
||||
static GMat2 substitute(GMat, GScalar, GArray<ArrayT>) { return {}; }
|
||||
};
|
||||
|
||||
GAPI_TRANSFORM(gop_in_gmat_out, <GMat(GOpaque<OpaqueT>)>, "gop_in_gmat_out")
|
||||
{
|
||||
static GMat pattern(GOpaque<OpaqueT>) { return {}; }
|
||||
static GMat substitute(GOpaque<OpaqueT>) { return {}; }
|
||||
};
|
||||
|
||||
GAPI_TRANSFORM(gmat_in_gop_out, <GOpaque<OpaqueT>(GMat)>, "gmat_in_gop_out")
|
||||
{
|
||||
static GOpaque<OpaqueT> pattern(GMat) { return {}; }
|
||||
static GOpaque<OpaqueT> substitute(GMat) { return {}; }
|
||||
};
|
||||
|
||||
GAPI_TRANSFORM(gop_in_gscalar_out, <GScalar(GOpaque<OpaqueT>)>, "gop_in_gscalar_out")
|
||||
{
|
||||
static GScalar pattern(GOpaque<OpaqueT>) { return {}; }
|
||||
static GScalar substitute(GOpaque<OpaqueT>) { return {}; }
|
||||
};
|
||||
|
||||
GAPI_TRANSFORM(gscalar_in_gop_out, <GOpaque<OpaqueT>(GScalar)>, "gscalar_in_gop_out")
|
||||
{
|
||||
static GOpaque<OpaqueT> pattern(GScalar) { return {}; }
|
||||
static GOpaque<OpaqueT> substitute(GScalar) { return {}; }
|
||||
};
|
||||
|
||||
GAPI_TRANSFORM(gmat_gsc_gopaque_in_gmat2_out, <GMat2(GMat, GScalar, GOpaque<OpaqueT>)>, "gmat_gsc_gopaque_in_gmat2_out")
|
||||
{
|
||||
static GMat2 pattern(GMat, GScalar, GOpaque<OpaqueT>) { return {}; }
|
||||
static GMat2 substitute(GMat, GScalar, GOpaque<OpaqueT>) { return {}; }
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
TEST(KernelPackageTransform, CreatePackage)
|
||||
@ -108,10 +155,15 @@ TEST(KernelPackageTransform, CreatePackage)
|
||||
, garr_in_gscalar_out
|
||||
, gscalar_in_garr_out
|
||||
, gmat_gsc_garray_in_gmat2_out
|
||||
, gop_in_gmat_out
|
||||
, gmat_in_gop_out
|
||||
, gop_in_gscalar_out
|
||||
, gscalar_in_gop_out
|
||||
, gmat_gsc_gopaque_in_gmat2_out
|
||||
>();
|
||||
|
||||
auto tr = pkg.get_transformations();
|
||||
EXPECT_EQ(11u, tr.size());
|
||||
EXPECT_EQ(16u, tr.size());
|
||||
}
|
||||
|
||||
TEST(KernelPackageTransform, Include)
|
||||
@ -164,6 +216,29 @@ TEST(KernelPackageTransform, gmat_gsc_garray_in_gmat2_out)
|
||||
check(tr.substitute());
|
||||
}
|
||||
|
||||
TEST(KernelPackageTransform, gmat_gsc_gopaque_in_gmat2_out)
|
||||
{
|
||||
auto tr = gmat_gsc_gopaque_in_gmat2_out::transformation();
|
||||
|
||||
auto check = [](const cv::GComputation &comp){
|
||||
const auto &p = comp.priv();
|
||||
EXPECT_EQ(3u, p.m_ins.size());
|
||||
EXPECT_EQ(2u, p.m_outs.size());
|
||||
|
||||
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_ins[0]));
|
||||
EXPECT_TRUE(ProtoContainsT<GScalar>(p.m_ins[1]));
|
||||
EXPECT_TRUE(ProtoContainsT<cv::detail::GOpaqueU>(p.m_ins[2]));
|
||||
EXPECT_TRUE(cv::util::get<cv::detail::GOpaqueU>(p.m_ins[2]).holds<OpaqueT>());
|
||||
EXPECT_FALSE(cv::util::get<cv::detail::GOpaqueU>(p.m_ins[2]).holds<WrongOpaqueT>());
|
||||
|
||||
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_outs[0]));
|
||||
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_outs[1]));
|
||||
};
|
||||
|
||||
check(tr.pattern());
|
||||
check(tr.substitute());
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template<typename ArgT>
|
||||
@ -176,7 +251,17 @@ namespace
|
||||
}
|
||||
|
||||
template<typename ArgT>
|
||||
typename std::enable_if<(cv::detail::GTypeTraits<ArgT>::kind != cv::detail::ArgKind::GARRAY), void>::type
|
||||
typename std::enable_if<(cv::detail::GTypeTraits<ArgT>::kind == cv::detail::ArgKind::GOPAQUE), void>::type
|
||||
arg_check(const cv::GProtoArg &arg)
|
||||
{
|
||||
EXPECT_TRUE(ProtoContainsT<cv::detail::GOpaqueU>(arg));
|
||||
EXPECT_TRUE(cv::util::get<cv::detail::GOpaqueU>(arg).holds<OpaqueT>());
|
||||
EXPECT_FALSE(cv::util::get<cv::detail::GOpaqueU>(arg).holds<WrongOpaqueT>());
|
||||
}
|
||||
|
||||
template<typename ArgT>
|
||||
typename std::enable_if<(cv::detail::GTypeTraits<ArgT>::kind != cv::detail::ArgKind::GARRAY &&
|
||||
cv::detail::GTypeTraits<ArgT>::kind != cv::detail::ArgKind::GOPAQUE), void>::type
|
||||
arg_check(const cv::GProtoArg &arg)
|
||||
{
|
||||
EXPECT_TRUE(ProtoContainsT<ArgT>(arg));
|
||||
@ -242,4 +327,24 @@ TEST(KernelPackageTransform, gscalar_in_garr_out)
|
||||
transformTest<gscalar_in_garr_out, GScalar, GArray<ArrayT>>();
|
||||
}
|
||||
|
||||
TEST(KernelPackageTransform, gop_in_gmat_out)
|
||||
{
|
||||
transformTest<gop_in_gmat_out, GOpaque<OpaqueT>, GMat>();
|
||||
}
|
||||
|
||||
TEST(KernelPackageTransform, gmat_in_gop_out)
|
||||
{
|
||||
transformTest<gmat_in_gop_out, GMat, GOpaque<OpaqueT>>();
|
||||
}
|
||||
|
||||
TEST(KernelPackageTransform, gop_in_gscalar_out)
|
||||
{
|
||||
transformTest<gop_in_gscalar_out, GOpaque<OpaqueT>, GScalar>();
|
||||
}
|
||||
|
||||
TEST(KernelPackageTransform, gscalar_in_gop_out)
|
||||
{
|
||||
transformTest<gscalar_in_gop_out, GScalar, GOpaque<OpaqueT>>();
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
@ -10,23 +10,6 @@
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
cv::Mat diff(cv::Mat m1, cv::Mat m2, int t)
|
||||
{
|
||||
return cv::abs(m1-m2) > t;
|
||||
}
|
||||
|
||||
int non_zero3(cv::Mat m3c)
|
||||
{
|
||||
std::vector<cv::Mat> mm(3);
|
||||
cv::split(m3c, mm);
|
||||
return ( cv::countNonZero(mm[0])
|
||||
+ cv::countNonZero(mm[1])
|
||||
+ cv::countNonZero(mm[2]));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GAPI_Typed, UnaryOp)
|
||||
{
|
||||
// Initialization //////////////////////////////////////////////////////////
|
||||
@ -60,14 +43,9 @@ TEST(GAPI_Typed, UnaryOp)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// FIXME: There must be OpenCV comparison test functions already available!
|
||||
cv::Mat
|
||||
diff_u = diff(out_mat_cv, out_mat_untyped, 0),
|
||||
diff_t = diff(out_mat_cv, out_mat_typed1, 0),
|
||||
diff_tc = diff(out_mat_cv, out_mat_typed2, 0);
|
||||
|
||||
EXPECT_EQ(0, non_zero3(diff_u));
|
||||
EXPECT_EQ(0, non_zero3(diff_t));
|
||||
EXPECT_EQ(0, non_zero3(diff_tc));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv, out_mat_untyped, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv, out_mat_typed1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv, out_mat_typed2, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GAPI_Typed, BinaryOp)
|
||||
@ -111,14 +89,9 @@ TEST(GAPI_Typed, BinaryOp)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// FIXME: There must be OpenCV comparison test functions already available!
|
||||
cv::Mat
|
||||
diff_u = diff(out_mat_cv, out_mat_untyped, 0),
|
||||
diff_t = diff(out_mat_cv, out_mat_typed1, 0),
|
||||
diff_tc = diff(out_mat_cv, out_mat_typed2, 0);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_u));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_t));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_tc));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv, out_mat_untyped, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv, out_mat_typed1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv, out_mat_typed2, NORM_INF));
|
||||
}
|
||||
|
||||
|
||||
@ -166,20 +139,12 @@ TEST(GAPI_Typed, MultipleOuts)
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
// FIXME: There must be OpenCV comparison test functions already available!
|
||||
cv::Mat
|
||||
diff_u1 = diff(out_mat_cv1, out_mat_unt1, 0),
|
||||
diff_u2 = diff(out_mat_cv2, out_mat_unt2, 0),
|
||||
diff_t1 = diff(out_mat_cv1, out_mat_typed1, 0),
|
||||
diff_t2 = diff(out_mat_cv2, out_mat_typed2, 0),
|
||||
diff_c1 = diff(out_mat_cv1, out_mat_comp1, 0),
|
||||
diff_c2 = diff(out_mat_cv2, out_mat_comp2, 0);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_u1));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_u2));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_t1));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_t2));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_c1));
|
||||
EXPECT_EQ(0, cv::countNonZero(diff_c2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv1, out_mat_unt1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv2, out_mat_unt2, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv1, out_mat_typed1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv2, out_mat_typed2, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv1, out_mat_comp1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_cv2, out_mat_comp2, NORM_INF));
|
||||
}
|
||||
|
||||
} // opencv_test
|
||||
|
@ -94,16 +94,19 @@ TEST(TestAgeGenderIE, InferBasicTensor)
|
||||
|
||||
IE::Blob::Ptr ie_age, ie_gender;
|
||||
{
|
||||
IE::Core ie;
|
||||
auto net = ie.ReadNetwork(topology_path, weights_path);
|
||||
IE::CNNNetReader reader;
|
||||
reader.ReadNetwork(topology_path);
|
||||
reader.ReadWeights(weights_path);
|
||||
auto net = reader.getNetwork();
|
||||
|
||||
const auto &iedims = net.getInputsInfo().begin()->second->getTensorDesc().getDims();
|
||||
auto cvdims = cv::gapi::ie::util::to_ocv(iedims);
|
||||
in_mat.create(cvdims, CV_32F);
|
||||
cv::randu(in_mat, -1, 1);
|
||||
|
||||
auto execNet = ie.LoadNetwork(net, "CPU");
|
||||
auto infer_request = execNet.CreateInferRequest();
|
||||
auto plugin = IE::PluginDispatcher().getPluginByDevice("CPU");
|
||||
auto plugin_net = plugin.LoadNetwork(net, {});
|
||||
auto infer_request = plugin_net.CreateInferRequest();
|
||||
|
||||
infer_request.SetBlob("data", cv::gapi::ie::util::to_ie(in_mat));
|
||||
infer_request.Infer();
|
||||
@ -150,14 +153,17 @@ TEST(TestAgeGenderIE, InferBasicImage)
|
||||
namespace IE = InferenceEngine;
|
||||
IE::Blob::Ptr ie_age, ie_gender;
|
||||
{
|
||||
IE::Core ie;
|
||||
auto net = reader.ReadNetwork(topology_path, weights_path);
|
||||
IE::CNNNetReader reader;
|
||||
reader.ReadNetwork(topology_path);
|
||||
reader.ReadWeights(weights_path);
|
||||
auto net = reader.getNetwork();
|
||||
auto &ii = net.getInputsInfo().at("data");
|
||||
ii->setPrecision(IE::Precision::U8);
|
||||
ii->setLayout(IE::Layout::NHWC);
|
||||
ii->getPreProcess().setResizeAlgorithm(IE::RESIZE_BILINEAR);
|
||||
|
||||
auto plugin_net = ie.LoadNetwork(net, "CPU");
|
||||
auto plugin = IE::PluginDispatcher().getPluginByDevice("CPU");
|
||||
auto plugin_net = plugin.LoadNetwork(net, {});
|
||||
auto infer_request = plugin_net.CreateInferRequest();
|
||||
|
||||
infer_request.SetBlob("data", cv::gapi::ie::util::to_ie(in_mat));
|
||||
@ -210,14 +216,17 @@ TEST(TestAgeGenderIE, InferROIList)
|
||||
namespace IE = InferenceEngine;
|
||||
std::vector<cv::Mat> ie_age, ie_gender;
|
||||
{
|
||||
IE::Core ie;
|
||||
auto net = ie.ReadNetwork(topology_path,weights_path );
|
||||
IE::CNNNetReader reader;
|
||||
reader.ReadNetwork(topology_path);
|
||||
reader.ReadWeights(weights_path);
|
||||
auto net = reader.getNetwork();
|
||||
auto &ii = net.getInputsInfo().at("data");
|
||||
ii->setPrecision(IE::Precision::U8);
|
||||
ii->setLayout(IE::Layout::NHWC);
|
||||
ii->getPreProcess().setResizeAlgorithm(IE::RESIZE_BILINEAR);
|
||||
|
||||
auto plugin_net = ie.LoadNetwork(net, "CPU");
|
||||
auto plugin = IE::PluginDispatcher().getPluginByDevice("CPU");
|
||||
auto plugin_net = plugin.LoadNetwork(net, {});
|
||||
auto infer_request = plugin_net.CreateInferRequest();
|
||||
auto frame_blob = cv::gapi::ie::util::to_ie(in_mat);
|
||||
|
||||
|
@ -70,8 +70,8 @@ TEST(GExecutor, SmokeTest)
|
||||
cv::boxFilter(ocv_tmp3, out_ocv[1], -1, cv::Size(3,3));
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_gapi[0] != out_ocv[0]));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_gapi[1] != out_ocv[1]));
|
||||
EXPECT_EQ(0, cvtest::norm(out_gapi[0], out_ocv[0], NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_gapi[1], out_ocv[1], NORM_INF));
|
||||
|
||||
// FIXME: check that GIslandModel has more than 1 island (e.g. fusion
|
||||
// with breakdown worked)
|
||||
|
@ -37,6 +37,10 @@ using GArg_Test_Types = ::testing::Types
|
||||
, Expected<cv::GArray<float>, cv::detail::ArgKind::GARRAY>
|
||||
, Expected<cv::GArray<cv::Point>, cv::detail::ArgKind::GARRAY>
|
||||
, Expected<cv::GArray<cv::Rect>, cv::detail::ArgKind::GARRAY>
|
||||
, Expected<cv::GOpaque<int>, cv::detail::ArgKind::GOPAQUE>
|
||||
, Expected<cv::GOpaque<float>, cv::detail::ArgKind::GOPAQUE>
|
||||
, Expected<cv::GOpaque<cv::Point>, cv::detail::ArgKind::GOPAQUE>
|
||||
, Expected<cv::GOpaque<cv::Rect>, cv::detail::ArgKind::GOPAQUE>
|
||||
|
||||
// Built-in types
|
||||
, Expected<int, cv::detail::ArgKind::OPAQUE_VAL>
|
||||
@ -85,6 +89,11 @@ TEST(GArg, HasWrap)
|
||||
"GArray<int> has custom marshalling logic");
|
||||
static_assert(cv::detail::has_custom_wrap<cv::GArray<std::string> >::value,
|
||||
"GArray<int> has custom marshalling logic");
|
||||
|
||||
static_assert(cv::detail::has_custom_wrap<cv::GOpaque<int> >::value,
|
||||
"GOpaque<int> has custom marshalling logic");
|
||||
static_assert(cv::detail::has_custom_wrap<cv::GOpaque<std::string> >::value,
|
||||
"GOpaque<int> has custom marshalling logic");
|
||||
}
|
||||
|
||||
TEST(GArg, GArrayU)
|
||||
@ -97,5 +106,15 @@ TEST(GArg, GArrayU)
|
||||
EXPECT_NO_THROW(arg2.get<cv::detail::GArrayU>());
|
||||
}
|
||||
|
||||
TEST(GArg, GOpaqueU)
|
||||
{
|
||||
// Placing a GOpaque<T> into GArg automatically strips it to GOpaqueU
|
||||
cv::GArg arg1 = cv::GArg(cv::GOpaque<int>());
|
||||
EXPECT_NO_THROW(arg1.get<cv::detail::GOpaqueU>());
|
||||
|
||||
cv::GArg arg2 = cv::GArg(cv::GOpaque<cv::Point>());
|
||||
EXPECT_NO_THROW(arg2.get<cv::detail::GOpaqueU>());
|
||||
}
|
||||
|
||||
|
||||
} // namespace opencv_test
|
||||
|
@ -141,7 +141,7 @@ TEST(GMetaArg, Can_Describe_RunArg)
|
||||
constexpr int w = 3, h = 3, c = 3;
|
||||
uchar data[w*h*c];
|
||||
cv::gapi::own::Mat om(h, w, CV_8UC3, data);
|
||||
cv::gapi::own::Scalar os;
|
||||
cv::Scalar os;
|
||||
std::vector<int> v;
|
||||
|
||||
GMetaArgs metas = {GMetaArg(descr_of(m)),
|
||||
@ -181,7 +181,7 @@ TEST(GMetaArg, Can_Describe_RunArgP)
|
||||
constexpr int w = 3, h = 3, c = 3;
|
||||
uchar data[w*h*c];
|
||||
cv::gapi::own::Mat om(h, w, CV_8UC3, data);
|
||||
cv::gapi::own::Scalar os;
|
||||
cv::Scalar os;
|
||||
std::vector<int> v;
|
||||
|
||||
GMetaArgs metas = {GMetaArg(descr_of(m)),
|
||||
|
@ -166,8 +166,8 @@ TEST(GModelBuilder, Constant_GScalar)
|
||||
EXPECT_EQ(9u, static_cast<std::size_t>(g.nodes().size())); // 6 data nodes (1 -input, 1 output, 2 constant, 2 temp) and 3 op nodes
|
||||
EXPECT_EQ(2u, static_cast<std::size_t>(addC_nh->inNodes().size())); // in and 3
|
||||
EXPECT_EQ(2u, static_cast<std::size_t>(mulC_nh->inNodes().size())); // addC output and c_s
|
||||
EXPECT_EQ(3, (util::get<cv::gapi::own::Scalar>(gm.metadata(s_3).get<cv::gimpl::ConstValue>().arg))[0]);
|
||||
EXPECT_EQ(5, (util::get<cv::gapi::own::Scalar>(gm.metadata(s_5).get<cv::gimpl::ConstValue>().arg))[0]);
|
||||
EXPECT_EQ(3, (util::get<cv::Scalar>(gm.metadata(s_3).get<cv::gimpl::ConstValue>().arg))[0]);
|
||||
EXPECT_EQ(5, (util::get<cv::Scalar>(gm.metadata(s_5).get<cv::gimpl::ConstValue>().arg))[0]);
|
||||
}
|
||||
|
||||
TEST(GModelBuilder, Check_Multiple_Outputs)
|
||||
|
@ -34,7 +34,7 @@ TEST(IslandFusion, TwoOps_OneIsland)
|
||||
cv::GComputation cc(in, out);
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Foo>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -77,7 +77,7 @@ TEST(IslandFusion, TwoOps_TwoIslands)
|
||||
cv::GComputation cc(in, out);
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, S::Bar>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -142,8 +142,8 @@ TEST(IslandFusion, ConsumerHasTwoInputs)
|
||||
cv::GComputation cc(cv::GIn(in[0], in[1]), cv::GOut(out));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)})};
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)})};
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, J::Bar>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -211,7 +211,7 @@ TEST(IslandFusion, DataNodeUsedDifferentBackend)
|
||||
cv::GComputation cc(cv::GIn(in), cv::GOut(out0, out1));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, S::Baz>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -272,7 +272,7 @@ TEST(IslandFusion, LoopBetweenDifferentBackends)
|
||||
cv::GComputation cc(cv::GIn(in), cv::GOut(out1, out0));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Baz, J::Quux, S::Foo, S::Qux>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -334,8 +334,8 @@ TEST(IslandsFusion, PartionOverlapUserIsland)
|
||||
cv::GComputation cc(cv::GIn(in[0], in[1]), cv::GOut(out));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)})};
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)})};
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, J::Bar>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -391,8 +391,8 @@ TEST(IslandsFusion, DISABLED_IslandContainsDifferentBackends)
|
||||
cv::GComputation cc(cv::GIn(in[0], in[1]), cv::GOut(out));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)})};
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)})};
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, S::Bar>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -424,7 +424,7 @@ TEST(IslandFusion, WithLoop)
|
||||
cv::GComputation cc(in, out);
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, J::Baz, J::Qux>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
|
@ -116,8 +116,8 @@ TEST(GComputationCompile, FluidReshapeResizeDownScale)
|
||||
cv::resize(in_mat1, cv_out_mat1, szOut);
|
||||
cv::resize(in_mat2, cv_out_mat2, szOut);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat1 != cv_out_mat1));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat2 != cv_out_mat2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat1, cv_out_mat1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat2, cv_out_mat2, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GComputationCompile, FluidReshapeSwitchToUpscaleFromDownscale)
|
||||
@ -151,9 +151,9 @@ TEST(GComputationCompile, FluidReshapeSwitchToUpscaleFromDownscale)
|
||||
cv::resize(in_mat2, cv_out_mat2, szOut);
|
||||
cv::resize(in_mat3, cv_out_mat3, szOut);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat1 != cv_out_mat1));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat2 != cv_out_mat2));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat3 != cv_out_mat3));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat1, cv_out_mat1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat2, cv_out_mat2, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat3, cv_out_mat3, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GComputationCompile, ReshapeBlur)
|
||||
@ -181,8 +181,8 @@ TEST(GComputationCompile, ReshapeBlur)
|
||||
cv::blur(in_mat1, cv_out_mat1, kernelSize);
|
||||
cv::blur(in_mat2, cv_out_mat2, kernelSize);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat1 != cv_out_mat1));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat2 != cv_out_mat2));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat1, cv_out_mat1, NORM_INF));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat2, cv_out_mat2, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(GComputationCompile, ReshapeRois)
|
||||
@ -216,7 +216,7 @@ TEST(GComputationCompile, ReshapeRois)
|
||||
int roiH = szOut.height / niter;
|
||||
cv::Rect roi{x, y, roiW, roiH};
|
||||
|
||||
cc.apply(in_mat, out_mat, cv::compile_args(cv::GFluidOutputRois{{to_own(roi)}}));
|
||||
cc.apply(in_mat, out_mat, cv::compile_args(cv::GFluidOutputRois{{roi}}));
|
||||
auto comp = cc.priv().m_lastCompiled;
|
||||
|
||||
EXPECT_EQ(&first_comp.priv(), &comp.priv());
|
||||
@ -225,7 +225,7 @@ TEST(GComputationCompile, ReshapeRois)
|
||||
cv::blur(in_mat, blur_mat, kernelSize);
|
||||
cv::resize(blur_mat, cv_out_mat, szOut);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat(roi) != cv_out_mat(roi)));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat(roi), cv_out_mat(roi), NORM_INF));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,12 @@ namespace opencv_test
|
||||
using Mat = cv::gapi::own::Mat;
|
||||
using Dims = std::vector<int>;
|
||||
|
||||
namespace {
|
||||
inline std::size_t multiply_dims(Dims const& dims){
|
||||
return std::accumulate(dims.begin(), dims.end(), static_cast<size_t>(1), std::multiplies<std::size_t>());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(OwnMat, DefaultConstruction)
|
||||
{
|
||||
Mat m;
|
||||
@ -36,7 +42,7 @@ TEST(OwnMat, Create)
|
||||
ASSERT_NE(m.data, nullptr);
|
||||
ASSERT_EQ((cv::gapi::own::Size{m.cols, m.rows}), size);
|
||||
|
||||
ASSERT_EQ(m.total(), static_cast<size_t>(size.height*size.width));
|
||||
ASSERT_EQ(m.total(), static_cast<size_t>(size.height) * size.width);
|
||||
ASSERT_EQ(m.type(), CV_8UC1);
|
||||
ASSERT_EQ(m.depth(), CV_8U);
|
||||
ASSERT_EQ(m.channels(), 1);
|
||||
@ -55,7 +61,7 @@ TEST(OwnMat, CreateND)
|
||||
ASSERT_NE(nullptr , m.data );
|
||||
ASSERT_EQ((cv::gapi::own::Size{0,0}), (cv::gapi::own::Size{m.cols, m.rows}));
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(dims[0]*dims[1]*dims[2]*dims[3]), m.total());
|
||||
ASSERT_EQ(multiply_dims(dims), m.total());
|
||||
ASSERT_EQ(CV_32F , m.type() );
|
||||
ASSERT_EQ(CV_32F , m.depth() );
|
||||
ASSERT_EQ(-1 , m.channels());
|
||||
@ -74,7 +80,7 @@ TEST(OwnMat, CreateOverload)
|
||||
ASSERT_NE(m.data, nullptr);
|
||||
ASSERT_EQ((cv::Size{m.cols, m.rows}), size);
|
||||
|
||||
ASSERT_EQ(m.total(), static_cast<size_t>(size.height*size.width));
|
||||
ASSERT_EQ(m.total(), static_cast<size_t>(size.height) * size.width);
|
||||
ASSERT_EQ(m.type(), CV_8UC1);
|
||||
ASSERT_EQ(m.depth(), CV_8U);
|
||||
ASSERT_EQ(m.channels(), 1);
|
||||
@ -220,7 +226,7 @@ TEST(OwnMatConversion, WithStep)
|
||||
auto ownMat = to_own(cvMat);
|
||||
auto cvMatFromOwn = cv::gapi::own::to_ocv(ownMat);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(cvMat != cvMatFromOwn))
|
||||
EXPECT_EQ(0, cvtest::norm(cvMat, cvMatFromOwn, NORM_INF))
|
||||
<< cvMat << std::endl
|
||||
<< (cvMat != cvMatFromOwn);
|
||||
}
|
||||
@ -285,7 +291,7 @@ TEST(OwnMat, CopyToWithStep)
|
||||
mat.copyTo(dst);
|
||||
|
||||
EXPECT_NE(mat.data, dst.data);
|
||||
EXPECT_EQ(0, cv::countNonZero(to_ocv(mat) != to_ocv(dst)))
|
||||
EXPECT_EQ(0, cvtest::norm(to_ocv(mat), to_ocv(dst), NORM_INF))
|
||||
<< to_ocv(mat) << std::endl
|
||||
<< (to_ocv(mat) != to_ocv(dst));
|
||||
}
|
||||
@ -301,7 +307,7 @@ TEST(OwnMat, AssignNDtoRegular)
|
||||
|
||||
ASSERT_NE(nullptr , a.data);
|
||||
ASSERT_EQ(sz , (cv::gapi::own::Size{a.cols, a.rows}));
|
||||
ASSERT_EQ(static_cast<size_t>(sz.width*sz.height), a.total());
|
||||
ASSERT_EQ(static_cast<size_t>(sz.width) * sz.height, a.total());
|
||||
ASSERT_EQ(CV_8U , a.type());
|
||||
ASSERT_EQ(CV_8U , a.depth());
|
||||
ASSERT_EQ(1 , a.channels());
|
||||
@ -316,7 +322,7 @@ TEST(OwnMat, AssignNDtoRegular)
|
||||
ASSERT_NE(nullptr , a.data);
|
||||
ASSERT_NE(old_ptr , a.data);
|
||||
ASSERT_EQ((cv::gapi::own::Size{0,0}), (cv::gapi::own::Size{a.cols, a.rows}));
|
||||
ASSERT_EQ(static_cast<size_t>(dims[0]*dims[1]*dims[2]*dims[3]), a.total());
|
||||
ASSERT_EQ(multiply_dims(dims), a.total());
|
||||
ASSERT_EQ(CV_32F , a.type());
|
||||
ASSERT_EQ(CV_32F , a.depth());
|
||||
ASSERT_EQ(-1 , a.channels());
|
||||
@ -336,7 +342,7 @@ TEST(OwnMat, AssignRegularToND)
|
||||
|
||||
ASSERT_NE(nullptr , a.data);
|
||||
ASSERT_EQ((cv::gapi::own::Size{0,0}), (cv::gapi::own::Size{a.cols, a.rows}));
|
||||
ASSERT_EQ(static_cast<size_t>(dims[0]*dims[1]*dims[2]*dims[3]), a.total());
|
||||
ASSERT_EQ(multiply_dims(dims), a.total());
|
||||
ASSERT_EQ(CV_32F , a.type());
|
||||
ASSERT_EQ(CV_32F , a.depth());
|
||||
ASSERT_EQ(-1 , a.channels());
|
||||
@ -351,7 +357,7 @@ TEST(OwnMat, AssignRegularToND)
|
||||
ASSERT_NE(nullptr , a.data);
|
||||
ASSERT_NE(old_ptr , a.data);
|
||||
ASSERT_EQ(sz , (cv::gapi::own::Size{a.cols, a.rows}));
|
||||
ASSERT_EQ(static_cast<size_t>(sz.width*sz.height), a.total());
|
||||
ASSERT_EQ(static_cast<size_t>(sz.width) * sz.height, a.total());
|
||||
ASSERT_EQ(CV_8U , a.type());
|
||||
ASSERT_EQ(CV_8U , a.depth());
|
||||
ASSERT_EQ(1 , a.channels());
|
||||
@ -371,7 +377,7 @@ TEST(OwnMat, CopyNDtoRegular)
|
||||
|
||||
ASSERT_NE(nullptr , a.data);
|
||||
ASSERT_EQ(sz , (cv::gapi::own::Size{a.cols, a.rows}));
|
||||
ASSERT_EQ(static_cast<size_t>(sz.width*sz.height), a.total());
|
||||
ASSERT_EQ(static_cast<size_t>(sz.width) * sz.height, a.total());
|
||||
ASSERT_EQ(CV_8U , a.type());
|
||||
ASSERT_EQ(CV_8U , a.depth());
|
||||
ASSERT_EQ(1 , a.channels());
|
||||
@ -387,7 +393,7 @@ TEST(OwnMat, CopyNDtoRegular)
|
||||
ASSERT_NE(old_ptr , a.data);
|
||||
ASSERT_NE(b.data , a.data);
|
||||
ASSERT_EQ((cv::gapi::own::Size{0,0}), (cv::gapi::own::Size{a.cols, a.rows}));
|
||||
ASSERT_EQ(static_cast<size_t>(dims[0]*dims[1]*dims[2]*dims[3]), a.total());
|
||||
ASSERT_EQ(multiply_dims(dims), a.total());
|
||||
ASSERT_EQ(CV_32F , a.type());
|
||||
ASSERT_EQ(CV_32F , a.depth());
|
||||
ASSERT_EQ(-1 , a.channels());
|
||||
@ -408,7 +414,7 @@ TEST(OwnMat, CopyRegularToND)
|
||||
|
||||
ASSERT_NE(nullptr , a.data);
|
||||
ASSERT_EQ((cv::gapi::own::Size{0,0}), (cv::gapi::own::Size{a.cols, a.rows}));
|
||||
ASSERT_EQ(static_cast<size_t>(dims[0]*dims[1]*dims[2]*dims[3]), a.total());
|
||||
ASSERT_EQ(multiply_dims(dims), a.total());
|
||||
ASSERT_EQ(CV_32F , a.type());
|
||||
ASSERT_EQ(CV_32F , a.depth());
|
||||
ASSERT_EQ(-1 , a.channels());
|
||||
@ -424,7 +430,7 @@ TEST(OwnMat, CopyRegularToND)
|
||||
ASSERT_NE(old_ptr , a.data);
|
||||
ASSERT_NE(b.data , a.data);
|
||||
ASSERT_EQ(sz , (cv::gapi::own::Size{a.cols, a.rows}));
|
||||
ASSERT_EQ(static_cast<size_t>(sz.width*sz.height), a.total());
|
||||
ASSERT_EQ(static_cast<size_t>(sz.width) * sz.height, a.total());
|
||||
ASSERT_EQ(CV_8U , a.type());
|
||||
ASSERT_EQ(CV_8U , a.depth());
|
||||
ASSERT_EQ(1 , a.channels());
|
||||
@ -460,8 +466,8 @@ TEST(OwnMat, ScalarAssign32SC1)
|
||||
}
|
||||
|
||||
auto cmp_result_mat = (cv::Mat{height, stepInPixels, CV_32S, data.data()} != cv::Mat{height, stepInPixels, CV_32S, expected.data()});
|
||||
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
|
||||
<< cmp_result_mat << std::endl;
|
||||
EXPECT_EQ(0, cvtest::norm(cmp_result_mat, NORM_INF))
|
||||
<< cmp_result_mat;
|
||||
}
|
||||
|
||||
TEST(OwnMat, ScalarAssign8UC1)
|
||||
@ -491,8 +497,8 @@ TEST(OwnMat, ScalarAssign8UC1)
|
||||
}
|
||||
|
||||
auto cmp_result_mat = (cv::Mat{height, stepInPixels, CV_8U, data.data()} != cv::Mat{height, stepInPixels, CV_8U, expected.data()});
|
||||
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
|
||||
<< cmp_result_mat << std::endl;
|
||||
EXPECT_EQ(0, cvtest::norm(cmp_result_mat, NORM_INF))
|
||||
<< cmp_result_mat;
|
||||
}
|
||||
|
||||
TEST(OwnMat, ScalarAssignND)
|
||||
@ -542,12 +548,12 @@ TEST(OwnMat, ScalarAssign8UC3)
|
||||
}
|
||||
|
||||
auto cmp_result_mat = (cv::Mat{height, stepInPixels, cv_type, data.data()} != cv::Mat{height, stepInPixels, cv_type, expected.data()});
|
||||
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
|
||||
<< cmp_result_mat << std::endl
|
||||
<< "data : " << std::endl
|
||||
<< cv::Mat{height, stepInPixels, cv_type, data.data()} << std::endl
|
||||
<< "expected : " << std::endl
|
||||
<< cv::Mat{height, stepInPixels, cv_type, expected.data()} << std::endl;
|
||||
EXPECT_EQ(0, cvtest::norm(cmp_result_mat, NORM_INF))
|
||||
<< cmp_result_mat << std::endl
|
||||
<< "data : " << std::endl
|
||||
<< cv::Mat{height, stepInPixels, cv_type, data.data()} << std::endl
|
||||
<< "expected : " << std::endl
|
||||
<< cv::Mat{height, stepInPixels, cv_type, expected.data()} << std::endl;
|
||||
}
|
||||
|
||||
TEST(OwnMat, ROIView)
|
||||
@ -583,9 +589,52 @@ TEST(OwnMat, ROIView)
|
||||
auto expected_cv_mat = cv::Mat{4, 4, CV_8U, expected.data()};
|
||||
|
||||
auto cmp_result_mat = (to_ocv(roi_view) != expected_cv_mat);
|
||||
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
|
||||
<< cmp_result_mat << std::endl
|
||||
<< to_ocv(roi_view) << std::endl
|
||||
<< expected_cv_mat << std::endl;
|
||||
EXPECT_EQ(0, cvtest::norm(cmp_result_mat, NORM_INF))
|
||||
<< cmp_result_mat << std::endl
|
||||
<< to_ocv(roi_view) << std::endl
|
||||
<< expected_cv_mat << std::endl;
|
||||
}
|
||||
|
||||
TEST(OwnMat, CreateWithNegativeDims)
|
||||
{
|
||||
Mat own_mat;
|
||||
ASSERT_ANY_THROW(own_mat.create(cv::Size{-1, -1}, CV_8U));
|
||||
}
|
||||
|
||||
TEST(OwnMat, CreateWithNegativeWidth)
|
||||
{
|
||||
Mat own_mat;
|
||||
ASSERT_ANY_THROW(own_mat.create(cv::Size{-1, 1}, CV_8U));
|
||||
}
|
||||
|
||||
TEST(OwnMat, CreateWithNegativeHeight)
|
||||
{
|
||||
Mat own_mat;
|
||||
ASSERT_ANY_THROW(own_mat.create(cv::Size{1, -1}, CV_8U));
|
||||
}
|
||||
|
||||
TEST(OwnMat, ZeroHeightMat)
|
||||
{
|
||||
cv::GMat in, a, b, c, d;
|
||||
std::tie(a, b, c, d) = cv::gapi::split4(in);
|
||||
cv::GMat out = cv::gapi::merge3(a, b, c);
|
||||
cv::Mat in_mat(cv::Size(8, 0), CV_8UC4);
|
||||
cv::Mat out_mat(cv::Size(8, 8), CV_8UC3);
|
||||
cv::GComputation comp(cv::GIn(in), cv::GOut(out));
|
||||
ASSERT_ANY_THROW(comp.apply(cv::gin(in_mat), cv::gout(out_mat),
|
||||
cv::compile_args(cv::gapi::core::fluid::kernels())));
|
||||
}
|
||||
|
||||
TEST(OwnMat, ZeroWidthMat)
|
||||
{
|
||||
cv::GMat in, a, b, c, d;
|
||||
std::tie(a, b, c, d) = cv::gapi::split4(in);
|
||||
cv::GMat out = cv::gapi::merge3(a, b, c);
|
||||
cv::Mat in_mat(cv::Size(0, 8), CV_8UC4);
|
||||
cv::Mat out_mat(cv::Size(8, 8), CV_8UC3);
|
||||
cv::GComputation comp(cv::GIn(in), cv::GOut(out));
|
||||
ASSERT_ANY_THROW(comp.apply(cv::gin(in_mat), cv::gout(out_mat),
|
||||
cv::compile_args(cv::gapi::core::fluid::kernels())));
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
@ -154,7 +154,7 @@ TEST_P(GAPI_Streaming, SmokeTest_ConstInput_GMat)
|
||||
// With constant inputs, the stream is endless so
|
||||
// the blocking pull() should never return `false`.
|
||||
EXPECT_TRUE(ccomp.pull(cv::gout(out_mat_gapi)));
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
|
||||
EXPECT_TRUE(ccomp.running());
|
||||
@ -202,7 +202,7 @@ TEST_P(GAPI_Streaming, SmokeTest_VideoInput_GMat)
|
||||
frames++;
|
||||
cv::Mat out_mat_ocv;
|
||||
opencv_ref(in_mat_gapi, out_mat_ocv);
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
EXPECT_EQ(0, cvtest::norm(out_mat_gapi, out_mat_ocv, NORM_INF));
|
||||
}
|
||||
EXPECT_LT(0u, frames);
|
||||
EXPECT_FALSE(ccomp.running());
|
||||
|
@ -28,4 +28,9 @@
|
||||
#include <opencv2/gapi/fluid/core.hpp>
|
||||
#include <opencv2/gapi/infer.hpp>
|
||||
|
||||
namespace cv {
|
||||
static inline void countNonZero_is_forbidden_in_tests_use_norm_instead() {}
|
||||
}
|
||||
#define countNonZero() countNonZero_is_forbidden_in_tests_use_norm_instead()
|
||||
|
||||
#endif // __OPENCV_GAPI_TEST_PRECOMP_HPP__
|
||||
|
@ -115,6 +115,18 @@ TEST(Variant, Assign_Basic)
|
||||
EXPECT_EQ(42, util::get<int>(vis));
|
||||
}
|
||||
|
||||
TEST(Variant, Assign_LValueRef)
|
||||
{
|
||||
TestVar vis;
|
||||
EXPECT_EQ(0u, vis.index());
|
||||
EXPECT_EQ(0, util::get<int>(vis));
|
||||
|
||||
int val = 42;
|
||||
vis = val;
|
||||
EXPECT_EQ(0u, vis.index());
|
||||
EXPECT_EQ(42, util::get<int>(vis));
|
||||
}
|
||||
|
||||
TEST(Variant, Assign_ValueUpdate_SameType)
|
||||
{
|
||||
TestVar vis(42);
|
||||
@ -139,6 +151,19 @@ TEST(Variant, Assign_ValueUpdate_DiffType)
|
||||
EXPECT_EQ("42", util::get<std::string>(vis));
|
||||
}
|
||||
|
||||
TEST(Variant, Assign_LValueRef_DiffType)
|
||||
{
|
||||
TestVar vis(42);
|
||||
|
||||
EXPECT_EQ(0u, vis.index());
|
||||
EXPECT_EQ(42, util::get<int>(vis));
|
||||
|
||||
std::string s("42");
|
||||
vis = s;
|
||||
EXPECT_EQ(1u, vis.index());
|
||||
EXPECT_EQ("42", util::get<std::string>(vis));
|
||||
}
|
||||
|
||||
TEST(Variant, Assign_ValueUpdate_Const)
|
||||
{
|
||||
TestVar va(42);
|
||||
|
@ -1 +1 @@
|
||||
master / 2020-01-24
|
||||
4.3.0
|
||||
|
Loading…
Reference in New Issue
Block a user