1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Alekhin
2021-12-30 16:23:27 +00:00
951 changed files with 158314 additions and 152668 deletions
+78 -9
View File
@@ -29,12 +29,11 @@ ocv_add_module(gapi
)
if(MSVC)
# Disable obsollete warning C4503 popping up on MSVC <<2017
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4503?view=vs-2019
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4503)
if (OPENCV_GAPI_INF_ENGINE AND NOT INF_ENGINE_RELEASE VERSION_GREATER "2021000000")
# Disable IE deprecated code warning C4996 for releases < 2021.1
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4996)
if(MSVC_VERSION LESS 1910)
# Disable obsolete warning C4503 popping up on MSVC << 15 2017
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4503?view=vs-2019
# and IE deprecated code warning C4996
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4503 /wd4996)
endif()
endif()
@@ -48,12 +47,14 @@ file(GLOB gapi_ext_hdrs
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/infer/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/ocl/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/own/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/plaidml/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/python/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/render/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/s11n/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/streaming/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/plaidml/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/streaming/gstreamer/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/streaming/onevpl/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/util/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/python/*.hpp"
)
set(gapi_srcs
@@ -124,6 +125,7 @@ set(gapi_srcs
src/backends/fluid/gfluidimgproc.cpp
src/backends/fluid/gfluidimgproc_func.dispatch.cpp
src/backends/fluid/gfluidcore.cpp
src/backends/fluid/gfluidcore_func.dispatch.cpp
# OCL Backend (currently built-in)
src/backends/ocl/goclbackend.cpp
@@ -163,27 +165,46 @@ set(gapi_srcs
src/backends/ie/bindings_ie.cpp
src/backends/python/gpythonbackend.cpp
# Streaming source
# OpenVPL Streaming source
src/streaming/onevpl/source.cpp
src/streaming/onevpl/source_priv.cpp
src/streaming/onevpl/file_data_provider.cpp
src/streaming/onevpl/cfg_params.cpp
src/streaming/onevpl/cfg_params_parser.cpp
src/streaming/onevpl/utils.cpp
src/streaming/onevpl/data_provider_interface_exception.cpp
src/streaming/onevpl/accelerators/surface/cpu_frame_adapter.cpp
src/streaming/onevpl/accelerators/surface/dx11_frame_adapter.cpp
src/streaming/onevpl/accelerators/surface/surface.cpp
src/streaming/onevpl/accelerators/surface/surface_pool.cpp
src/streaming/onevpl/accelerators/utils/shared_lock.cpp
src/streaming/onevpl/accelerators/accel_policy_cpu.cpp
src/streaming/onevpl/accelerators/accel_policy_dx11.cpp
src/streaming/onevpl/accelerators/dx11_alloc_resource.cpp
src/streaming/onevpl/engine/engine_session.cpp
src/streaming/onevpl/engine/processing_engine_base.cpp
src/streaming/onevpl/engine/decode/decode_engine_legacy.cpp
src/streaming/onevpl/engine/decode/decode_session.cpp
src/streaming/onevpl/demux/async_mfp_demux_data_provider.cpp
src/streaming/onevpl/data_provider_dispatcher.cpp
src/streaming/onevpl/cfg_param_device_selector.cpp
src/streaming/onevpl/device_selector_interface.cpp
# GStreamer Streaming source
src/streaming/gstreamer/gstreamer_pipeline_facade.cpp
src/streaming/gstreamer/gstreamerpipeline.cpp
src/streaming/gstreamer/gstreamersource.cpp
src/streaming/gstreamer/gstreamer_buffer_utils.cpp
src/streaming/gstreamer/gstreamer_media_adapter.cpp
src/streaming/gstreamer/gstreamerenv.cpp
# Utils (ITT tracing)
src/utils/itt.cpp
)
ocv_add_dispatched_file(backends/fluid/gfluidimgproc_func SSE4_1 AVX2)
ocv_add_dispatched_file(backends/fluid/gfluidcore_func SSE4_1 AVX2)
ocv_list_add_prefix(gapi_srcs "${CMAKE_CURRENT_LIST_DIR}/")
@@ -202,6 +223,10 @@ if(OPENCV_GAPI_INF_ENGINE)
ocv_target_link_libraries(${the_module} PRIVATE ${INF_ENGINE_TARGET})
endif()
if (HAVE_NGRAPH)
ocv_target_link_libraries(${the_module} PRIVATE ngraph::ngraph)
endif()
if(HAVE_TBB)
ocv_target_link_libraries(${the_module} PRIVATE tbb)
endif()
@@ -217,6 +242,9 @@ set(__test_extra_deps "")
if(OPENCV_GAPI_INF_ENGINE)
list(APPEND __test_extra_deps ${INF_ENGINE_TARGET})
endif()
if(HAVE_NGRAPH)
list(APPEND __test_extra_deps ngraph::ngraph)
endif()
ocv_add_accuracy_tests(${__test_extra_deps})
# FIXME: test binary is linked with ADE directly since ADE symbols
@@ -226,6 +254,9 @@ ocv_add_accuracy_tests(${__test_extra_deps})
if(TARGET opencv_test_gapi)
target_include_directories(opencv_test_gapi PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src")
target_link_libraries(opencv_test_gapi PRIVATE ade)
if (HAVE_NGRAPH)
ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_NGRAPH)
endif()
endif()
if(HAVE_TBB AND TARGET opencv_test_gapi)
@@ -254,17 +285,31 @@ if(HAVE_GAPI_ONEVPL)
if(TARGET opencv_test_gapi)
ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_ONEVPL)
ocv_target_link_libraries(opencv_test_gapi PRIVATE ${VPL_IMPORTED_TARGETS})
if(MSVC)
target_compile_options(opencv_test_gapi PUBLIC "/wd4201")
endif()
if(HAVE_D3D11 AND HAVE_OPENCL)
ocv_target_include_directories(opencv_test_gapi SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
endif()
endif()
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_ONEVPL)
ocv_target_link_libraries(${the_module} PRIVATE ${VPL_IMPORTED_TARGETS})
if(HAVE_D3D11 AND HAVE_OPENCL)
ocv_target_include_directories(${the_module} SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
endif()
endif()
ocv_option(OPENCV_GAPI_GSTREAMER "Build G-API with GStreamer support" HAVE_GSTREAMER)
if(HAVE_GSTREAMER AND OPENCV_GAPI_GSTREAMER)
if(TARGET opencv_test_gapi)
ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_GSTREAMER)
ocv_target_link_libraries(opencv_test_gapi PRIVATE ocv.3rdparty.gstreamer)
endif()
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_GSTREAMER)
ocv_target_link_libraries(${the_module} PRIVATE ocv.3rdparty.gstreamer)
endif()
if(WIN32)
# Required for htonl/ntohl on Windows
ocv_target_link_libraries(${the_module} PRIVATE wsock32 ws2_32)
@@ -281,3 +326,27 @@ endif()
ocv_add_perf_tests()
ocv_add_samples()
# Required for sample with inference on host
if (TARGET example_gapi_onevpl_infer_single_roi)
if(OPENCV_GAPI_INF_ENGINE)
ocv_target_link_libraries(example_gapi_onevpl_infer_single_roi PRIVATE ${INF_ENGINE_TARGET})
ocv_target_compile_definitions(example_gapi_onevpl_infer_single_roi PRIVATE -DHAVE_INF_ENGINE)
endif()
if(HAVE_D3D11 AND HAVE_OPENCL)
ocv_target_include_directories(example_gapi_onevpl_infer_single_roi SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
endif()
endif()
# perf test dependencies postprocessing
if(HAVE_GAPI_ONEVPL)
# NB: TARGET opencv_perf_gapi doesn't exist before `ocv_add_perf_tests`
if(TARGET opencv_perf_gapi)
ocv_target_compile_definitions(opencv_perf_gapi PRIVATE -DHAVE_ONEVPL)
ocv_target_link_libraries(opencv_perf_gapi PRIVATE ${VPL_IMPORTED_TARGETS})
if(HAVE_D3D11 AND HAVE_OPENCL)
ocv_target_include_directories(opencv_perf_gapi SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
endif()
endif()
endif()
+1 -1
View File
@@ -142,7 +142,7 @@ Graph execution is triggered in two ways:
Both methods are polimorphic and take a variadic number of arguments,
with validity checks performed in runtime. If a number, shapes, and
formats of passed data objects differ from expected, a run-time
formats of passed data objects differ from expected, a runtime
exception is thrown. G-API also provides _typed_ wrappers to move
these checks to the compile time -- see `cv::GComputationT<>`.
+6 -6
View File
@@ -47,7 +47,7 @@ an external parameter.
G-API provides a macro to define a new kernel interface --
G_TYPED_KERNEL():
@snippet modules/gapi/samples/kernel_api_snippets.cpp filter2d_api
@snippet samples/cpp/tutorial_code/gapi/doc_snippets/kernel_api_snippets.cpp filter2d_api
This macro is a shortcut to a new type definition. It takes three
arguments to register a new type, and requires type body to be present
@@ -81,18 +81,18 @@ Once a kernel is defined, it can be used in pipelines with special,
G-API-supplied method "::on()". This method has the same signature as
defined in kernel, so this code:
@snippet modules/gapi/samples/kernel_api_snippets.cpp filter2d_on
@snippet samples/cpp/tutorial_code/gapi/doc_snippets/kernel_api_snippets.cpp filter2d_on
is a perfectly legal construction. This example has some verbosity,
though, so usually a kernel declaration comes with a C++ function
wrapper ("factory method") which enables optional parameters, more
compact syntax, Doxygen comments, etc:
@snippet modules/gapi/samples/kernel_api_snippets.cpp filter2d_wrap
@snippet samples/cpp/tutorial_code/gapi/doc_snippets/kernel_api_snippets.cpp filter2d_wrap
so now it can be used like:
@snippet modules/gapi/samples/kernel_api_snippets.cpp filter2d_wrap_call
@snippet samples/cpp/tutorial_code/gapi/doc_snippets/kernel_api_snippets.cpp filter2d_wrap_call
# Extra information {#gapi_kernel_supp_info}
@@ -143,7 +143,7 @@ For example, the aforementioned `Filter2D` is implemented in
"reference" CPU (OpenCV) plugin this way (*NOTE* -- this is a
simplified form with improper border handling):
@snippet modules/gapi/samples/kernel_api_snippets.cpp filter2d_ocv
@snippet samples/cpp/tutorial_code/gapi/doc_snippets/kernel_api_snippets.cpp filter2d_ocv
Note how CPU (OpenCV) plugin has transformed the original kernel
signature:
@@ -174,7 +174,7 @@ point extraction to an STL vector:
A compound kernel _implementation_ can be defined using a generic
macro GAPI_COMPOUND_KERNEL():
@snippet modules/gapi/samples/kernel_api_snippets.cpp compound
@snippet samples/cpp/tutorial_code/gapi/doc_snippets/kernel_api_snippets.cpp compound
<!-- TODO: ADD on how Compound kernels may simplify dispatching -->
<!-- TODO: Add details on when expand() is called! -->
+17 -93
View File
@@ -9,10 +9,10 @@
#define OPENCV_GAPI_CORE_HPP
#include <math.h>
#include <utility> // std::tuple
#include <opencv2/imgproc.hpp>
#include <opencv2/gapi/imgproc.hpp>
#include <opencv2/gapi/gmat.hpp>
#include <opencv2/gapi/gscalar.hpp>
@@ -34,6 +34,9 @@ namespace cv { namespace gapi {
* Core module functionality.
*/
namespace core {
using GResize = cv::gapi::imgproc::GResize;
using GResizeP = cv::gapi::imgproc::GResizeP;
using GMat2 = std::tuple<GMat,GMat>;
using GMat3 = std::tuple<GMat,GMat,GMat>; // FIXME: how to avoid this?
using GMat4 = std::tuple<GMat,GMat,GMat,GMat>;
@@ -57,6 +60,7 @@ namespace core {
G_TYPED_KERNEL(GAddC, <GMat(GMat, GScalar, int)>, "org.opencv.core.math.addC") {
static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) {
GAPI_Assert(a.chan <= 4);
return a.withDepth(ddepth);
}
};
@@ -99,7 +103,7 @@ namespace core {
}
};
G_TYPED_KERNEL(GMulC, <GMat(GMat, GScalar, int)>, "org.opencv.core.math.mulC"){
G_TYPED_KERNEL(GMulC, <GMat(GMat, GScalar, int)>, "org.opencv.core.math.mulC") {
static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) {
return a.withDepth(ddepth);
}
@@ -200,37 +204,37 @@ namespace core {
}
};
G_TYPED_KERNEL(GCmpGTScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpGTScalar"){
G_TYPED_KERNEL(GCmpGTScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpGTScalar") {
static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
return a.withDepth(CV_8U);
}
};
G_TYPED_KERNEL(GCmpGEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpGEScalar"){
G_TYPED_KERNEL(GCmpGEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpGEScalar") {
static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
return a.withDepth(CV_8U);
}
};
G_TYPED_KERNEL(GCmpLEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpLEScalar"){
G_TYPED_KERNEL(GCmpLEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpLEScalar") {
static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
return a.withDepth(CV_8U);
}
};
G_TYPED_KERNEL(GCmpLTScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpLTScalar"){
G_TYPED_KERNEL(GCmpLTScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpLTScalar") {
static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
return a.withDepth(CV_8U);
}
};
G_TYPED_KERNEL(GCmpEQScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpEQScalar"){
G_TYPED_KERNEL(GCmpEQScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpEQScalar") {
static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
return a.withDepth(CV_8U);
}
};
G_TYPED_KERNEL(GCmpNEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpNEScalar"){
G_TYPED_KERNEL(GCmpNEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpNEScalar") {
static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
return a.withDepth(CV_8U);
}
@@ -397,32 +401,6 @@ namespace core {
}
};
G_TYPED_KERNEL(GResize, <GMat(GMat,Size,double,double,int)>, "org.opencv.core.transform.resize") {
static GMatDesc outMeta(GMatDesc in, Size sz, double fx, double fy, int) {
if (sz.width != 0 && sz.height != 0)
{
return in.withSize(sz);
}
else
{
int outSz_w = static_cast<int>(round(in.size.width * fx));
int outSz_h = static_cast<int>(round(in.size.height * fy));
GAPI_Assert(outSz_w > 0 && outSz_h > 0);
return in.withSize(Size(outSz_w, outSz_h));
}
}
};
G_TYPED_KERNEL(GResizeP, <GMatP(GMatP,Size,int)>, "org.opencv.core.transform.resizeP") {
static GMatDesc outMeta(GMatDesc in, Size sz, int interp) {
GAPI_Assert(in.depth == CV_8U);
GAPI_Assert(in.chan == 3);
GAPI_Assert(in.planar);
GAPI_Assert(interp == cv::INTER_LINEAR);
return in.withSize(sz);
}
};
G_TYPED_KERNEL(GMerge3, <GMat(GMat,GMat,GMat)>, "org.opencv.core.transform.merge3") {
static GMatDesc outMeta(GMatDesc in, GMatDesc, GMatDesc) {
// Preserve depth and add channel component
@@ -706,7 +684,7 @@ GAPI_EXPORTS GMat subC(const GMat& src, const GScalar& c, int ddepth = -1);
/** @brief Calculates the per-element difference between given scalar and the matrix.
The function can be replaced with matrix expressions:
\f[\texttt{dst} = \texttt{val} - \texttt{src}\f]
\f[\texttt{dst} = \texttt{c} - \texttt{src}\f]
Depth of the output matrix is determined by the ddepth parameter.
If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix.
@@ -770,7 +748,10 @@ GAPI_EXPORTS GMat mulC(const GScalar& multiplier, const GMat& src, int ddepth =
The function divides one matrix by another:
\f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f]
When src2(I) is zero, dst(I) will also be zero. Different channels of
For integer types when src2(I) is zero, dst(I) will also be zero.
Floating point case returns Inf/NaN (according to IEEE).
Different channels of
multi-channel matrices are processed independently.
The matrices can be single or multi channel. Output matrix must have the same size and depth as src.
@@ -1463,63 +1444,6 @@ GAPI_EXPORTS GMat inRange(const GMat& src, const GScalar& threshLow, const GScal
//! @addtogroup gapi_transform
//! @{
/** @brief Resizes an image.
The function resizes the image src down to or up to the specified size.
Output image size will have the size dsize (when dsize is non-zero) or the size computed from
src.size(), fx, and fy; the depth of output is the same as of src.
If you want to resize src so that it fits the pre-created dst,
you may call the function as follows:
@code
// explicitly specify dsize=dst.size(); fx and fy will be computed from that.
resize(src, dst, dst.size(), 0, 0, interpolation);
@endcode
If you want to decimate the image by factor of 2 in each direction, you can call the function this
way:
@code
// specify fx and fy and let the function compute the destination image size.
resize(src, dst, Size(), 0.5, 0.5, interpolation);
@endcode
To shrink an image, it will generally look best with cv::INTER_AREA interpolation, whereas to
enlarge an image, it will generally look best with cv::INTER_CUBIC (slow) or cv::INTER_LINEAR
(faster but still looks OK).
@note Function textual ID is "org.opencv.core.transform.resize"
@param src input image.
@param dsize output image size; if it equals zero, it is computed as:
\f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f]
Either dsize or both fx and fy must be non-zero.
@param fx scale factor along the horizontal axis; when it equals 0, it is computed as
\f[\texttt{(double)dsize.width/src.cols}\f]
@param fy scale factor along the vertical axis; when it equals 0, it is computed as
\f[\texttt{(double)dsize.height/src.rows}\f]
@param interpolation interpolation method, see cv::InterpolationFlags
@sa warpAffine, warpPerspective, remap, resizeP
*/
GAPI_EXPORTS_W GMat resize(const GMat& src, const Size& dsize, double fx = 0, double fy = 0, int interpolation = INTER_LINEAR);
/** @brief Resizes a planar image.
The function resizes the image src down to or up to the specified size.
Planar image memory layout is three planes laying in the memory contiguously,
so the image height should be plane_height*plane_number, image type is @ref CV_8UC1.
Output image size will have the size dsize, the depth of output is the same as of src.
@note Function textual ID is "org.opencv.core.transform.resizeP"
@param src input image, must be of @ref CV_8UC1 type;
@param dsize output image size;
@param interpolation interpolation method, only cv::INTER_LINEAR is supported at the moment
@sa warpAffine, warpPerspective, remap, resize
*/
GAPI_EXPORTS GMatP resizeP(const GMatP& src, const Size& dsize, int interpolation = cv::INTER_LINEAR);
/** @brief Creates one 4-channel matrix out of 4 single-channel ones.
The function merges several matrices to make a single multi-channel matrix. That is, each
@@ -16,7 +16,7 @@ namespace gapi {
namespace core {
namespace cpu {
GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels();
GAPI_EXPORTS_W cv::GKernelPackage kernels();
} // namespace cpu
} // namespace core
@@ -28,14 +28,6 @@ namespace gimpl
{
// Forward-declare an internal class
class GCPUExecutable;
namespace render
{
namespace ocv
{
class GRenderExecutable;
}
}
} // namespace gimpl
namespace gapi
@@ -133,7 +125,6 @@ protected:
std::unordered_map<std::size_t, GRunArgP> m_results;
friend class gimpl::GCPUExecutable;
friend class gimpl::render::ocv::GRenderExecutable;
};
class GAPI_EXPORTS GCPUKernel
@@ -13,7 +13,7 @@
namespace cv { namespace gapi { namespace core { namespace fluid {
GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels();
GAPI_EXPORTS_W cv::GKernelPackage kernels();
}}}}
@@ -25,7 +25,7 @@ namespace fluid {
struct Border
{
// This constructor is required to support existing kernels which are part of G-API
Border(int _type, cv::Scalar _val) : type(_type), value(_val) {};
Border(int _type, cv::Scalar _val) : type(_type), value(_val) {}
int type;
cv::Scalar value;
+4 -4
View File
@@ -171,7 +171,7 @@ using GRunArgs = std::vector<GRunArg>;
* It's an ordinary overload of addition assignment operator.
*
* Example of usage:
* @snippet modules/gapi/samples/dynamic_graph.cpp GRunArgs usage
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GRunArgs usage
*
*/
inline GRunArgs& operator += (GRunArgs &lhs, const GRunArgs &rhs)
@@ -223,7 +223,7 @@ using GRunArgsP = std::vector<GRunArgP>;
* It's an ordinary overload of addition assignment operator.
*
* Example of usage:
* @snippet modules/gapi/samples/dynamic_graph.cpp GRunArgsP usage
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GRunArgsP usage
*
*/
inline GRunArgsP& operator += (GRunArgsP &lhs, const GRunArgsP &rhs)
@@ -247,7 +247,7 @@ namespace gapi
* it needs to be wrapped by this function.
*
* Example of usage:
* @snippet modules/gapi/samples/api_ref_snippets.cpp bind after deserialization
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp bind after deserialization
*
* @param out_args deserialized GRunArgs.
* @return the same GRunArgs wrapped in GRunArgsP.
@@ -260,7 +260,7 @@ GAPI_EXPORTS cv::GRunArgsP bind(cv::GRunArgs &out_args);
* which this function does.
*
* Example of usage:
* @snippet modules/gapi/samples/api_ref_snippets.cpp bind before serialization
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp bind before serialization
*
* @param out output GRunArgsP available during graph execution.
* @return the same GRunArgsP wrapped in serializable GRunArgs.
+1 -1
View File
@@ -236,7 +236,7 @@ namespace detail
class VectorRef
{
std::shared_ptr<BasicVectorRef> m_ref;
cv::detail::OpaqueKind m_kind;
cv::detail::OpaqueKind m_kind = cv::detail::OpaqueKind::CV_UNKNOWN;
template<typename T> inline void check() const
{
@@ -134,12 +134,12 @@ namespace detail {
*
* For example, if an example computation is executed like this:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp graph_decl_apply
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_decl_apply
*
* Extra parameter specifying which kernels to compile with can be
* passed like this:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp apply_with_param
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp apply_with_param
*/
/**
@@ -61,11 +61,11 @@ namespace s11n {
* executed. The below example expresses calculation of Sobel operator
* for edge detection (\f$G = \sqrt{G_x^2 + G_y^2}\f$):
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp graph_def
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_def
*
* Full pipeline can be now captured with this object declaration:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp graph_cap_full
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_cap_full
*
* Input/output data objects on which a call graph should be
* reconstructed are passed using special wrappers cv::GIn and
@@ -78,7 +78,7 @@ namespace s11n {
* expects that image gradients are already pre-calculated may be
* defined like this:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp graph_cap_sub
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_cap_sub
*
* The resulting graph would expect two inputs and produce one
* output. In this case, it doesn't matter if gx/gy data objects are
@@ -130,7 +130,7 @@ public:
* Graph can be defined in-place directly at the moment of its
* construction with a lambda:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp graph_gen
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_gen
*
* This may be useful since all temporary objects (cv::GMats) and
* namespaces can be localized to scope of lambda, without
+27 -24
View File
@@ -410,9 +410,13 @@ namespace std
};
} // namespace std
namespace cv {
class GAPI_EXPORTS_W_SIMPLE GKernelPackage;
namespace gapi {
GAPI_EXPORTS cv::GKernelPackage combine(const cv::GKernelPackage &lhs,
const cv::GKernelPackage &rhs);
/// @private
class GFunctor
{
@@ -427,6 +431,7 @@ namespace gapi {
private:
const char* m_id;
};
} // namespace gapi
/** \addtogroup gapi_compile_args
* @{
@@ -463,7 +468,7 @@ namespace gapi {
{
/// @private
using M = std::unordered_map<std::string, std::pair<GBackend, GKernelImpl>>;
using M = std::unordered_map<std::string, std::pair<cv::gapi::GBackend, cv::GKernelImpl>>;
/// @private
M m_id_kernels;
@@ -500,10 +505,8 @@ namespace gapi {
}
public:
void include(const GFunctor& functor)
{
m_id_kernels[functor.id()] = std::make_pair(functor.backend(), functor.impl());
}
void include(const cv::gapi::GFunctor& functor);
/**
* @brief Returns total number of kernels
* in the package (across all backends included)
@@ -555,7 +558,7 @@ namespace gapi {
*
* @param backend backend which kernels to remove
*/
void remove(const GBackend& backend);
void remove(const cv::gapi::GBackend& backend);
/**
* @brief Remove all kernels implementing the given API from
@@ -595,7 +598,7 @@ namespace gapi {
*
*/
template<typename KAPI>
GBackend lookup() const
cv::gapi::GBackend lookup() const
{
return lookup(KAPI::id()).first;
}
@@ -621,18 +624,14 @@ namespace gapi {
* @param backend backend associated with the kernel
* @param kernel_id a name/id of the kernel
*/
void include(const cv::gapi::GBackend& backend, const std::string& kernel_id)
{
removeAPI(kernel_id);
m_id_kernels[kernel_id] = std::make_pair(backend, GKernelImpl{{}, {}});
}
void include(const cv::gapi::GBackend& backend, const std::string& kernel_id);
/**
* @brief Lists all backends which are included into package
*
* @return vector of backends
*/
std::vector<GBackend> backends() const;
std::vector<cv::gapi::GBackend> backends() const;
// TODO: Doxygen bug -- it wants me to place this comment
// here, not below.
@@ -643,9 +642,17 @@ namespace gapi {
* @param rhs "Right-hand-side" package in the process
* @return a new kernel package.
*/
friend GAPI_EXPORTS GKernelPackage combine(const GKernelPackage &lhs,
const GKernelPackage &rhs);
friend GAPI_EXPORTS GKernelPackage cv::gapi::combine(const GKernelPackage &lhs,
const GKernelPackage &rhs);
};
/** @} */
namespace gapi {
using GKernelPackage = cv::GKernelPackage; // Keep backward compatibility
/** \addtogroup gapi_compile_args
* @{
*/
/**
* @brief Create a kernel package object containing kernels
@@ -659,7 +666,7 @@ namespace gapi {
* Use this function to pass kernel implementations (defined in
* either way) and transformations to the system. Example:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp kernels_snippet
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp kernels_snippet
*
* Note that kernels() itself is a function returning object, not
* a type, so having `()` at the end is important -- it must be a
@@ -695,10 +702,6 @@ namespace gapi {
/** @} */
// FYI - this function is already commented above
GAPI_EXPORTS GKernelPackage combine(const GKernelPackage &lhs,
const GKernelPackage &rhs);
/**
* @brief Combines multiple G-API kernel packages into one
*
@@ -710,7 +713,7 @@ namespace gapi {
* @return The resulting kernel package
*/
template<typename... Ps>
GKernelPackage combine(const GKernelPackage &a, const GKernelPackage &b, Ps&&... rest)
cv::GKernelPackage combine(const cv::GKernelPackage &a, const cv::GKernelPackage &b, Ps&&... rest)
{
return combine(a, combine(b, rest...));
}
@@ -719,7 +722,7 @@ namespace gapi {
* @{
*/
/**
* @brief cv::use_only() is a special combinator which hints G-API to use only
* @brief cv::gapi::use_only() is a special combinator which hints G-API to use only
* kernels specified in cv::GComputation::compile() (and not to extend kernels available by
* default with that package).
*/
@@ -733,7 +736,7 @@ namespace gapi {
namespace detail
{
template<> struct CompileArgTag<cv::gapi::GKernelPackage>
template<> struct CompileArgTag<cv::GKernelPackage>
{
static const char* tag() { return "gapi.kernel_package"; }
};
@@ -232,7 +232,7 @@ namespace detail
class OpaqueRef
{
std::shared_ptr<BasicOpaqueRef> m_ref;
cv::detail::OpaqueKind m_kind;
cv::detail::OpaqueKind m_kind = cv::detail::OpaqueKind::CV_UNKNOWN;
template<typename T> inline void check() const
{
+1 -1
View File
@@ -71,7 +71,7 @@ public:
* It's an ordinary overload of addition assignment operator.
*
* Example of usage:
* @snippet modules/gapi/samples/dynamic_graph.cpp GIOProtoArgs usage
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GIOProtoArgs usage
*
*/
template<typename Tg>
@@ -88,7 +88,7 @@ public:
* This constructor overload is not marked `explicit` and can be
* used in G-API expression code like this:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp gscalar_implicit
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp gscalar_implicit
*
* Here operator+(GMat,GScalar) is used to wrap cv::gapi::addC()
* and a value-initialized GScalar is created on the fly.
@@ -31,7 +31,7 @@ struct GAPI_EXPORTS GTransform
F pattern;
F substitute;
GTransform(const std::string& d, const F &p, const F &s) : description(d), pattern(p), substitute(s){};
GTransform(const std::string& d, const F &p, const F &s) : description(d), pattern(p), substitute(s) {}
};
namespace detail
@@ -19,11 +19,25 @@
#include <opencv2/gapi/streaming/source.hpp>
#include <opencv2/gapi/media.hpp>
#include <opencv2/gapi/gcommon.hpp>
#include <opencv2/gapi/util/util.hpp>
#include <opencv2/gapi/own/convert.hpp>
namespace cv
{
namespace detail
{
template<typename, typename = void>
struct contains_shape_field : std::false_type {};
template<typename TaggedTypeCandidate>
struct contains_shape_field<TaggedTypeCandidate,
void_t<decltype(TaggedTypeCandidate::shape)>> :
std::is_same<typename std::decay<decltype(TaggedTypeCandidate::shape)>::type, GShape>
{};
template<typename Type>
struct has_gshape : contains_shape_field<Type> {};
// FIXME: These traits and enum and possible numerous switch(kind)
// block may be replaced with a special Handler<T> object or with
// a double dispatch
@@ -181,10 +195,16 @@ namespace detail
}
template<typename U> static auto wrap_in (const U &u) -> typename GTypeTraits<T>::strip_type
{
static_assert(!(cv::detail::has_gshape<GTypeTraits<U>>::value
|| cv::detail::contains<typename std::decay<U>::type, GAPI_OWN_TYPES_LIST>::value),
"gin/gout must not be used with G* classes or cv::gapi::own::*");
return GTypeTraits<T>::wrap_in(u);
}
template<typename U> static auto wrap_out(U &u) -> typename GTypeTraits<T>::strip_type
{
static_assert(!(cv::detail::has_gshape<GTypeTraits<U>>::value
|| cv::detail::contains<typename std::decay<U>::type, GAPI_OWN_TYPES_LIST>::value),
"gin/gout must not be used with G* classses or cv::gapi::own::*");
return GTypeTraits<T>::wrap_out(u);
}
};
+2 -2
View File
@@ -57,7 +57,7 @@ namespace detail
*
* Refer to the following example. Regular (untyped) code is written this way:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp Untyped_Example
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp Untyped_Example
*
* Here:
*
@@ -71,7 +71,7 @@ namespace detail
*
* Now the same code written with typed API:
*
* @snippet modules/gapi/samples/api_ref_snippets.cpp Typed_Example
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp Typed_Example
*
* The key difference is:
*
+91 -4
View File
@@ -23,6 +23,7 @@
@defgroup gapi_colorconvert Graph API: Converting image from one color space to another
@defgroup gapi_feature Graph API: Image Feature Detection
@defgroup gapi_shape Graph API: Image Structural Analysis and Shape Descriptors
@defgroup gapi_transform Graph API: Image and channel composition functions
@}
*/
@@ -56,7 +57,7 @@ namespace imgproc {
using GMat3 = std::tuple<GMat,GMat,GMat>; // FIXME: how to avoid this?
using GFindContoursOutput = std::tuple<GArray<GArray<Point>>,GArray<Vec4i>>;
G_TYPED_KERNEL(GFilter2D, <GMat(GMat,int,Mat,Point,Scalar,int,Scalar)>,"org.opencv.imgproc.filters.filter2D") {
G_TYPED_KERNEL(GFilter2D, <GMat(GMat,int,Mat,Point,Scalar,int,Scalar)>, "org.opencv.imgproc.filters.filter2D") {
static GMatDesc outMeta(GMatDesc in, int ddepth, Mat, Point, Scalar, int, Scalar) {
return in.withDepth(ddepth);
}
@@ -74,7 +75,7 @@ namespace imgproc {
}
};
G_TYPED_KERNEL(GBlur, <GMat(GMat,Size,Point,int,Scalar)>, "org.opencv.imgproc.filters.blur"){
G_TYPED_KERNEL(GBlur, <GMat(GMat,Size,Point,int,Scalar)>, "org.opencv.imgproc.filters.blur") {
static GMatDesc outMeta(GMatDesc in, Size, Point, int, Scalar) {
return in;
}
@@ -138,13 +139,13 @@ namespace imgproc {
}
};
G_TYPED_KERNEL(GEqHist, <GMat(GMat)>, "org.opencv.imgproc.equalizeHist"){
G_TYPED_KERNEL(GEqHist, <GMat(GMat)>, "org.opencv.imgproc.equalizeHist") {
static GMatDesc outMeta(GMatDesc in) {
return in.withType(CV_8U, 1);
}
};
G_TYPED_KERNEL(GCanny, <GMat(GMat,double,double,int,bool)>, "org.opencv.imgproc.feature.canny"){
G_TYPED_KERNEL(GCanny, <GMat(GMat,double,double,int,bool)>, "org.opencv.imgproc.feature.canny") {
static GMatDesc outMeta(GMatDesc in, double, double, int, bool) {
return in.withType(CV_8U, 1);
}
@@ -495,6 +496,32 @@ namespace imgproc {
}
};
G_TYPED_KERNEL(GResize, <GMat(GMat,Size,double,double,int)>, "org.opencv.imgproc.transform.resize") {
static GMatDesc outMeta(GMatDesc in, Size sz, double fx, double fy, int /*interp*/) {
if (sz.width != 0 && sz.height != 0)
{
return in.withSize(sz);
}
else
{
int outSz_w = static_cast<int>(round(in.size.width * fx));
int outSz_h = static_cast<int>(round(in.size.height * fy));
GAPI_Assert(outSz_w > 0 && outSz_h > 0);
return in.withSize(Size(outSz_w, outSz_h));
}
}
};
G_TYPED_KERNEL(GResizeP, <GMatP(GMatP,Size,int)>, "org.opencv.imgproc.transform.resizeP") {
static GMatDesc outMeta(GMatDesc in, Size sz, int interp) {
GAPI_Assert(in.depth == CV_8U);
GAPI_Assert(in.chan == 3);
GAPI_Assert(in.planar);
GAPI_Assert(interp == cv::INTER_LINEAR);
return in.withSize(sz);
}
};
} //namespace imgproc
//! @addtogroup gapi_filters
@@ -1676,6 +1703,66 @@ image type is @ref CV_8UC1.
GAPI_EXPORTS GMatP NV12toBGRp(const GMat &src_y, const GMat &src_uv);
//! @} gapi_colorconvert
//! @addtogroup gapi_transform
//! @{
/** @brief Resizes an image.
The function resizes the image src down to or up to the specified size.
Output image size will have the size dsize (when dsize is non-zero) or the size computed from
src.size(), fx, and fy; the depth of output is the same as of src.
If you want to resize src so that it fits the pre-created dst,
you may call the function as follows:
@code
// explicitly specify dsize=dst.size(); fx and fy will be computed from that.
resize(src, dst, dst.size(), 0, 0, interpolation);
@endcode
If you want to decimate the image by factor of 2 in each direction, you can call the function this
way:
@code
// specify fx and fy and let the function compute the destination image size.
resize(src, dst, Size(), 0.5, 0.5, interpolation);
@endcode
To shrink an image, it will generally look best with cv::INTER_AREA interpolation, whereas to
enlarge an image, it will generally look best with cv::INTER_CUBIC (slow) or cv::INTER_LINEAR
(faster but still looks OK).
@note Function textual ID is "org.opencv.imgproc.transform.resize"
@param src input image.
@param dsize output image size; if it equals zero, it is computed as:
\f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f]
Either dsize or both fx and fy must be non-zero.
@param fx scale factor along the horizontal axis; when it equals 0, it is computed as
\f[\texttt{(double)dsize.width/src.cols}\f]
@param fy scale factor along the vertical axis; when it equals 0, it is computed as
\f[\texttt{(double)dsize.height/src.rows}\f]
@param interpolation interpolation method, see cv::InterpolationFlags
@sa warpAffine, warpPerspective, remap, resizeP
*/
GAPI_EXPORTS_W GMat resize(const GMat& src, const Size& dsize, double fx = 0, double fy = 0, int interpolation = INTER_LINEAR);
/** @brief Resizes a planar image.
The function resizes the image src down to or up to the specified size.
Planar image memory layout is three planes laying in the memory contiguously,
so the image height should be plane_height*plane_number, image type is @ref CV_8UC1.
Output image size will have the size dsize, the depth of output is the same as of src.
@note Function textual ID is "org.opencv.imgproc.transform.resizeP"
@param src input image, must be of @ref CV_8UC1 type;
@param dsize output image size;
@param interpolation interpolation method, only cv::INTER_LINEAR is supported at the moment
@sa warpAffine, warpPerspective, remap, resize
*/
GAPI_EXPORTS GMatP resizeP(const GMatP& src, const Size& dsize, int interpolation = cv::INTER_LINEAR);
//! @} gapi_transform
} //namespace gapi
} //namespace cv
@@ -44,6 +44,9 @@ public:
GAPI_WRAP
PyParams& cfgNumRequests(size_t nireq);
GAPI_WRAP
PyParams& cfgBatchSize(const size_t size);
GBackend backend() const;
std::string tag() const;
cv::util::any params() const;
+28 -2
View File
@@ -79,6 +79,11 @@ struct ParamDesc {
// NB: An optional config to setup RemoteContext for IE
cv::util::any context_config;
// NB: batch_size can't be equal to 1 by default, because some of models
// have 2D (Layout::NC) input and if the first dimension not equal to 1
// net.setBatchSize(1) will overwrite it.
cv::optional<size_t> batch_size;
};
} // namespace detail
@@ -120,6 +125,7 @@ public:
, {}
, {}
, 1u
, {}
, {}} {
};
@@ -141,6 +147,7 @@ public:
, {}
, {}
, 1u
, {}
, {}} {
};
@@ -316,6 +323,19 @@ public:
return *this;
}
/** @brief Specifies the inference batch size.
The function is used to specify inference batch size.
Follow https://docs.openvinotoolkit.org/latest/classInferenceEngine_1_1CNNNetwork.html#a8e9d19270a48aab50cb5b1c43eecb8e9 for additional information
@param size batch size which will be used.
@return reference to this parameter structure.
*/
Params<Net>& cfgBatchSize(const size_t size) {
desc.batch_size = cv::util::make_optional(size);
return *this;
}
// BEGIN(G-API's network parametrization API)
GBackend backend() const { return cv::gapi::ie::backend(); }
std::string tag() const { return Net::tag(); }
@@ -350,7 +370,7 @@ public:
const std::string &device)
: desc{ model, weights, device, {}, {}, {}, 0u, 0u,
detail::ParamDesc::Kind::Load, true, {}, {}, {}, 1u,
{}},
{}, {}},
m_tag(tag) {
};
@@ -368,7 +388,7 @@ public:
const std::string &device)
: desc{ model, {}, device, {}, {}, {}, 0u, 0u,
detail::ParamDesc::Kind::Import, true, {}, {}, {}, 1u,
{}},
{}, {}},
m_tag(tag) {
};
@@ -435,6 +455,12 @@ public:
return *this;
}
/** @see ie::Params::cfgBatchSize */
Params& cfgBatchSize(const size_t size) {
desc.batch_size = cv::util::make_optional(size);
return *this;
}
// BEGIN(G-API's network parametrization API)
GBackend backend() const { return cv::gapi::ie::backend(); }
std::string tag() const { return m_tag; }
@@ -16,7 +16,7 @@ namespace gapi {
namespace core {
namespace ocl {
GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels();
GAPI_EXPORTS_W cv::GKernelPackage kernels();
} // namespace ocl
} // namespace core
@@ -14,6 +14,12 @@
# include <opencv2/core/cvdef.h>
# include <opencv2/core/types.hpp>
# include <opencv2/core/base.hpp>
#define GAPI_OWN_TYPES_LIST cv::gapi::own::Rect, \
cv::gapi::own::Size, \
cv::gapi::own::Point, \
cv::gapi::own::Point2f, \
cv::gapi::own::Scalar, \
cv::gapi::own::Mat
#else // Without OpenCV
# include <opencv2/gapi/own/cvdefs.hpp>
# include <opencv2/gapi/own/types.hpp> // cv::gapi::own::Rect/Size/Point
@@ -28,6 +34,8 @@ namespace cv {
using Scalar = gapi::own::Scalar;
using Mat = gapi::own::Mat;
} // namespace cv
#define GAPI_OWN_TYPES_LIST cv::gapi::own::VoidType
#endif // !defined(GAPI_STANDALONE)
#endif // OPENCV_GAPI_OPENCV_INCLUDES_HPP
@@ -20,11 +20,12 @@ typedef char schar;
typedef unsigned short ushort;
#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0"
#define CV_CN_MAX 512
#define CV_CN_SHIFT 3
#define CV_DEPTH_MAX (1 << CV_CN_SHIFT)
#define CV_8U 0
#define CV_8S 1
#define CV_16U 2
@@ -32,7 +33,7 @@ typedef unsigned short ushort;
#define CV_32S 4
#define CV_32F 5
#define CV_64F 6
#define CV_USRTYPE1 7
#define CV_16F 7
#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1)
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
@@ -70,6 +71,12 @@ typedef unsigned short ushort;
#define CV_32SC4 CV_MAKETYPE(CV_32S,4)
#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n))
#define CV_16FC1 CV_MAKETYPE(CV_16F,1)
#define CV_16FC2 CV_MAKETYPE(CV_16F,2)
#define CV_16FC3 CV_MAKETYPE(CV_16F,3)
#define CV_16FC4 CV_MAKETYPE(CV_16F,4)
#define CV_16FC(n) CV_MAKETYPE(CV_16F,(n))
#define CV_32FC1 CV_MAKETYPE(CV_32F,1)
#define CV_32FC2 CV_MAKETYPE(CV_32F,2)
#define CV_32FC3 CV_MAKETYPE(CV_32F,3)
@@ -84,6 +91,16 @@ typedef unsigned short ushort;
// cvdef.h:
#ifndef CV_ALWAYS_INLINE
# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
# define CV_ALWAYS_INLINE inline __attribute__((always_inline))
# elif defined(_MSC_VER)
# define CV_ALWAYS_INLINE __forceinline
# else
# define CV_ALWAYS_INLINE inline
# endif
#endif
#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
@@ -96,10 +113,10 @@ typedef unsigned short ushort;
#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT)
#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
///** Size of each channel item,
//** Size of each channel item,
// 0x8442211 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
//#define CV_ELEM_SIZE1(type) \
// ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15)
#define CV_ELEM_SIZE1(type) \
((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15)
#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
@@ -11,9 +11,9 @@
#include <math.h>
#include <limits>
#include <type_traits>
#include <opencv2/gapi/own/assert.hpp>
#include <opencv2/gapi/util/type_traits.hpp>
namespace cv { namespace gapi { namespace own {
//-----------------------------
@@ -22,16 +22,12 @@ namespace cv { namespace gapi { namespace own {
//
//-----------------------------
template<typename DST, typename SRC>
static inline DST saturate(SRC x)
template<typename DST, typename SRC,
typename = cv::util::enable_if_t<!std::is_same<DST, SRC>::value &&
std::is_integral<DST>::value &&
std::is_integral<SRC>::value> >
static CV_ALWAYS_INLINE DST saturate(SRC x)
{
// only integral types please!
GAPI_DbgAssert(std::is_integral<DST>::value &&
std::is_integral<SRC>::value);
if (std::is_same<DST, SRC>::value)
return static_cast<DST>(x);
if (sizeof(DST) > sizeof(SRC))
return static_cast<DST>(x);
@@ -44,38 +40,35 @@ static inline DST saturate(SRC x)
std::numeric_limits<DST>::max():
static_cast<DST>(x);
}
template<typename T>
static CV_ALWAYS_INLINE T saturate(T x)
{
return x;
}
template<typename DST, typename SRC, typename R,
cv::util::enable_if_t<std::is_floating_point<DST>::value, bool> = true >
static CV_ALWAYS_INLINE DST saturate(SRC x, R)
{
return static_cast<DST>(x);
}
template<typename DST, typename SRC, typename R,
cv::util::enable_if_t<std::is_integral<DST>::value &&
std::is_integral<SRC>::value , bool> = true >
static CV_ALWAYS_INLINE DST saturate(SRC x, R)
{
return saturate<DST>(x);
}
// Note, that OpenCV rounds differently:
// - like std::round() for add, subtract
// - like std::rint() for multiply, divide
template<typename DST, typename SRC, typename R>
static inline DST saturate(SRC x, R round)
template<typename DST, typename SRC, typename R,
cv::util::enable_if_t<std::is_integral<DST>::value &&
std::is_floating_point<SRC>::value, bool> = true >
static CV_ALWAYS_INLINE DST saturate(SRC x, R round)
{
if (std::is_floating_point<DST>::value)
{
return static_cast<DST>(x);
}
else if (std::is_integral<SRC>::value)
{
GAPI_DbgAssert(std::is_integral<DST>::value &&
std::is_integral<SRC>::value);
return saturate<DST>(x);
}
else
{
GAPI_DbgAssert(std::is_integral<DST>::value &&
std::is_floating_point<SRC>::value);
#ifdef _WIN32
// Suppress warning about converting x to floating-point
// Note that x is already floating-point at this point
#pragma warning(disable: 4244)
#endif
int ix = static_cast<int>(round(x));
#ifdef _WIN32
#pragma warning(default: 4244)
#endif
return saturate<DST>(ix);
}
int ix = static_cast<int>(round(x));
return saturate<DST>(ix);
}
// explicit suffix 'd' for double type
@@ -143,6 +143,7 @@ inline std::ostream& operator<<(std::ostream& o, const Size& s)
return o;
}
struct VoidType {};
} // namespace own
} // namespace gapi
} // namespace cv
@@ -13,7 +13,7 @@
namespace cv { namespace gapi { namespace core { namespace plaidml {
GAPI_EXPORTS cv::gapi::GKernelPackage kernels();
GAPI_EXPORTS cv::GKernelPackage kernels();
}}}}
@@ -59,7 +59,7 @@ public:
using F = std::function<void(GPlaidMLContext &)>;
GPlaidMLKernel() = default;
explicit GPlaidMLKernel(const F& f) : m_f(f) {};
explicit GPlaidMLKernel(const F& f) : m_f(f) {}
void apply(GPlaidMLContext &ctx) const
{
@@ -177,7 +177,7 @@ namespace render
{
namespace ocv
{
GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels();
GAPI_EXPORTS_W cv::GKernelPackage kernels();
} // namespace ocv
} // namespace render
+10 -8
View File
@@ -25,11 +25,11 @@ namespace cv {
// "Remote Mat", a general class which provides an abstraction layer over the data
// storage and placement (host, remote device etc) and allows to access this data.
//
// The device specific implementation is hidden in the RMat::Adapter class
// The device specific implementation is hidden in the RMat::IAdapter class
//
// The basic flow is the following:
// * Backend which is aware of the remote device:
// - Implements own AdapterT class which is derived from RMat::Adapter
// - Implements own AdapterT class which is derived from RMat::IAdapter
// - Wraps device memory into RMat via make_rmat utility function:
// cv::RMat rmat = cv::make_rmat<AdapterT>(args);
//
@@ -101,25 +101,27 @@ public:
};
enum class Access { R, W };
class Adapter
class IAdapter
// Adapter class is going to be deleted and renamed as IAdapter
{
public:
virtual ~Adapter() = default;
virtual ~IAdapter() = default;
virtual GMatDesc desc() const = 0;
// Implementation is responsible for setting the appropriate callback to
// the view when accessed for writing, to ensure that the data from the view
// is transferred to the device when the view is destroyed
virtual View access(Access) = 0;
virtual void serialize(cv::gapi::s11n::IOStream&) {
GAPI_Assert(false && "Generic serialize method of RMat::Adapter does nothing by default. "
GAPI_Assert(false && "Generic serialize method of RMat::IAdapter does nothing by default. "
"Please, implement it in derived class to properly serialize the object.");
}
virtual void deserialize(cv::gapi::s11n::IIStream&) {
GAPI_Assert(false && "Generic deserialize method of RMat::Adapter does nothing by default. "
GAPI_Assert(false && "Generic deserialize method of RMat::IAdapter does nothing by default. "
"Please, implement it in derived class to properly deserialize the object.");
}
};
using AdapterP = std::shared_ptr<Adapter>;
using Adapter = IAdapter; // Keep backward compatibility
using AdapterP = std::shared_ptr<IAdapter>;
RMat() = default;
RMat(AdapterP&& a) : m_adapter(std::move(a)) {}
@@ -136,7 +138,7 @@ public:
// return nullptr if underlying type is different
template<typename T> T* get() const
{
static_assert(std::is_base_of<Adapter, T>::value, "T is not derived from Adapter!");
static_assert(std::is_base_of<IAdapter, T>::value, "T is not derived from IAdapter!");
GAPI_Assert(m_adapter != nullptr);
return dynamic_cast<T*>(m_adapter.get());
}
+1 -1
View File
@@ -431,7 +431,7 @@ struct deserialize_runarg {
static GRunArg exec(cv::gapi::s11n::IIStream& is, uint32_t idx) {
if (idx == GRunArg::index_of<RMat>()) {
// Type or void (if not found)
using TA = typename cv::util::find_adapter_impl<RMat::Adapter, Types...>::type;
using TA = typename cv::util::find_adapter_impl<RMat::IAdapter, Types...>::type;
return deserialize_arg_with_adapter<RMat, TA>::exec(is);
} else if (idx == GRunArg::index_of<MediaFrame>()) {
// Type or void (if not found)
@@ -40,7 +40,7 @@ struct NotImplemented {
* which can be utilized when serializing a custom type.
*
* Example of usage:
* @snippet modules/gapi/samples/api_ref_snippets.cpp S11N usage
* @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp S11N usage
*
*/
template<typename T>
@@ -13,7 +13,7 @@ namespace cv {
namespace gapi {
namespace streaming {
GAPI_EXPORTS cv::gapi::GKernelPackage kernels();
GAPI_EXPORTS cv::GKernelPackage kernels();
G_API_OP(GBGR, <GMat(GFrame)>, "org.opencv.streaming.BGR")
{
@@ -0,0 +1,47 @@
// 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) 2021 Intel Corporation
#ifndef OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP
#define OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP
#include <opencv2/gapi/streaming/gstreamer/gstreamersource.hpp>
#include <opencv2/gapi/own/exports.hpp>
#include <string>
#include <unordered_map>
#include <memory>
namespace cv {
namespace gapi {
namespace wip {
namespace gst {
class GAPI_EXPORTS GStreamerPipeline
{
public:
class Priv;
explicit GStreamerPipeline(const std::string& pipeline);
IStreamSource::Ptr getStreamingSource(const std::string& appsinkName,
const GStreamerSource::OutputType outputType =
GStreamerSource::OutputType::MAT);
virtual ~GStreamerPipeline();
protected:
explicit GStreamerPipeline(std::unique_ptr<Priv> priv);
std::unique_ptr<Priv> m_priv;
};
} // namespace gst
using GStreamerPipeline = gst::GStreamerPipeline;
} // namespace wip
} // namespace gapi
} // namespace cv
#endif // OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP
@@ -0,0 +1,89 @@
// 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) 2021 Intel Corporation
#ifndef OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP
#define OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP
#include <opencv2/gapi/streaming/source.hpp>
#include <opencv2/gapi/garg.hpp>
#include <memory>
namespace cv {
namespace gapi {
namespace wip {
namespace gst {
/**
* @brief OpenCV's GStreamer streaming source.
* Streams cv::Mat-s/cv::MediaFrame from passed GStreamer pipeline.
*
* This class implements IStreamSource interface.
*
* To create GStreamerSource instance you need to pass 'pipeline' and, optionally, 'outputType'
* arguments into constructor.
* 'pipeline' should represent GStreamer pipeline in form of textual description.
* Almost any custom pipeline is supported which can be successfully ran via gst-launch.
* The only two limitations are:
* - there should be __one__ appsink element in the pipeline to pass data to OpenCV app.
* Pipeline can actually contain many sink elements, but it must have one and only one
* appsink among them.
*
* - data passed to appsink should be video-frame in NV12 format.
*
* 'outputType' is used to select type of output data to produce: 'cv::MediaFrame' or 'cv::Mat'.
* To produce 'cv::MediaFrame'-s you need to pass 'GStreamerSource::OutputType::FRAME' and,
* correspondingly, 'GStreamerSource::OutputType::MAT' to produce 'cv::Mat'-s.
* Please note, that in the last case, output 'cv::Mat' will be of BGR format, internal conversion
* from NV12 GStreamer data will happen.
* Default value for 'outputType' is 'GStreamerSource::OutputType::MAT'.
*
* @note Stream sources are passed to G-API via shared pointers, so please use gapi::make_src<>
* to create objects and ptr() to pass a GStreamerSource to cv::gin().
*
* @note You need to build OpenCV with GStreamer support to use this class.
*/
class GStreamerPipelineFacade;
class GAPI_EXPORTS GStreamerSource : public IStreamSource
{
public:
class Priv;
// Indicates what type of data should be produced by GStreamerSource: cv::MediaFrame or cv::Mat
enum class OutputType {
FRAME,
MAT
};
GStreamerSource(const std::string& pipeline,
const GStreamerSource::OutputType outputType =
GStreamerSource::OutputType::MAT);
GStreamerSource(std::shared_ptr<GStreamerPipelineFacade> pipeline,
const std::string& appsinkName,
const GStreamerSource::OutputType outputType =
GStreamerSource::OutputType::MAT);
bool pull(cv::gapi::wip::Data& data) override;
GMetaArg descr_of() const override;
~GStreamerSource() override;
protected:
explicit GStreamerSource(std::unique_ptr<Priv> priv);
std::unique_ptr<Priv> m_priv;
};
} // namespace gst
using GStreamerSource = gst::GStreamerSource;
} // namespace wip
} // namespace gapi
} // namespace cv
#endif // OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP
@@ -46,9 +46,72 @@ struct GAPI_EXPORTS CfgParam {
double_t,
void*,
std::string>;
/**
* @brief frames_pool_size_name
*
* Special configuration parameter name for onevp::GSource:
*
* @note frames_pool_size_name allows to allocate surfaces pool appropriate size to keep
* decoded frames in accelerator memory ready before
* they would be consumed by onevp::GSource::pull operation. If you see
* a lot of WARNING about lack of free surface then it's time to increase
* frames_pool_size_name but be aware of accelerator free memory volume.
* If not set then MFX implementation use
* mfxFrameAllocRequest::NumFrameSuggested behavior
*
*/
static constexpr const char *frames_pool_size_name() { return "frames_pool_size"; }
static CfgParam create_frames_pool_size(size_t value);
/**
* Create onevp::GSource configuration parameter.
* @brief acceleration_mode_name
*
* Special configuration parameter names for onevp::GSource:
*
* @note acceleration_mode_name allows to activate hardware acceleration &
* device memory management.
* Supported values:
* - MFX_ACCEL_MODE_VIA_D3D11 Will activate DX11 acceleration and will produces
* MediaFrames with data allocated in DX11 device memory
*
* If not set then MFX implementation will use default acceleration behavior:
* all decoding operation uses default GPU resources but MediaFrame produces
* data allocated by using host RAM
*
*/
static constexpr const char *acceleration_mode_name() { return "mfxImplDescription.AccelerationMode"; }
static CfgParam create_acceleration_mode(uint32_t value);
static CfgParam create_acceleration_mode(const char* value);
/**
* @brief decoder_id_name
*
* Special configuration parameter names for onevp::GSource:
*
* @note decoder_id_name allows to specify VPL decoder type which MUST present
* in case of RAW video input data and MUST NOT present as CfgParam if video
* stream incapsulated into container(*.mp4, *.mkv and so on). In latter case
* onevp::GSource will determine it automatically
* Supported values:
* - MFX_CODEC_AVC
* - MFX_CODEC_HEVC
* - MFX_CODEC_MPEG2
* - MFX_CODEC_VC1
* - MFX_CODEC_CAPTURE
* - MFX_CODEC_VP9
* - MFX_CODEC_AV1
*
*/
static constexpr const char *decoder_id_name() { return "mfxImplDescription.mfxDecoderDescription.decoder.CodecID"; }
static CfgParam create_decoder_id(uint32_t value);
static CfgParam create_decoder_id(const char* value);
static constexpr const char *implementation_name() { return "mfxImplDescription.Impl"; }
static CfgParam create_implementation(uint32_t value);
static CfgParam create_implementation(const char* value);
/**
* Create generic onevp::GSource configuration parameter.
*
*@param name name of parameter.
*@param value value of parameter.
@@ -7,28 +7,39 @@
#ifndef GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP
#define GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP
#include <exception>
#include <memory>
#include <string>
#include <opencv2/gapi/own/exports.hpp> // GAPI_EXPORTS
namespace cv {
namespace gapi {
namespace wip {
namespace onevpl {
struct GAPI_EXPORTS DataProviderException : public std::exception {
virtual ~DataProviderException() {};
};
DataProviderException(const std::string& descr);
DataProviderException(std::string&& descr);
struct GAPI_EXPORTS DataProviderSystemErrorException : public DataProviderException {
DataProviderSystemErrorException(int error_code, const std::string& desription = std::string());
virtual ~DataProviderSystemErrorException();
virtual ~DataProviderException() = default;
virtual const char* what() const noexcept override;
private:
std::string reason;
};
struct GAPI_EXPORTS DataProviderSystemErrorException final : public DataProviderException {
DataProviderSystemErrorException(int error_code, const std::string& desription = std::string());
~DataProviderSystemErrorException() = default;
};
struct GAPI_EXPORTS DataProviderUnsupportedException final : public DataProviderException {
DataProviderUnsupportedException(const std::string& description);
~DataProviderUnsupportedException() = default;
};
struct GAPI_EXPORTS DataProviderImplementationException : public DataProviderException {
DataProviderImplementationException(const std::string& description);
~DataProviderImplementationException() = default;
};
/**
* @brief Public interface allows to customize extraction of video stream data
* used by onevpl::GSource instead of reading stream from file (by default).
@@ -41,21 +52,41 @@ private:
*/
struct GAPI_EXPORTS IDataProvider {
using Ptr = std::shared_ptr<IDataProvider>;
using mfx_codec_id_type = uint32_t;
virtual ~IDataProvider() {};
/**
* NB: here is supposed to be forward declaration of mfxBitstream
* But according to current oneVPL implementation it is impossible to forward
* declare untagged struct mfxBitstream.
*
* IDataProvider makes sense only for HAVE_VPL is ON and to keep IDataProvider
* interface API/ABI compliant between core library and user application layer
* let's introduce wrapper mfx_bitstream which inherits mfxBitstream in private
* G-API code section and declare forward for wrapper mfx_bitstream here
*/
struct mfx_bitstream;
virtual ~IDataProvider() = default;
/**
* The function is used by onevpl::GSource to extract codec id from data
*
*/
virtual mfx_codec_id_type get_mfx_codec_id() const = 0;
/**
* The function is used by onevpl::GSource to extract binary data stream from @ref IDataProvider
* implementation.
*
* It MUST throw `DataProviderException` kind exceptions in fail cases.
* It MUST return 0 in EOF which considered as not-fail case.
* It MUST return MFX_ERR_MORE_DATA in EOF which considered as not-fail case.
*
* @param out_data_bytes_size the available capacity of out_data buffer.
* @param out_data the output consumer buffer with capacity out_data_bytes_size.
* @return fetched bytes count.
* @param in_out_bitsream the input-output reference on MFX bitstream buffer which MUST be empty at the first request
* to allow implementation to allocate it by itself and to return back. Subsequent invocation of `fetch_bitstream_data`
* MUST use the previously used in_out_bitsream to avoid skipping rest of frames which haven't been consumed
* @return true for fetched data, false on EOF and throws exception on error
*/
virtual size_t fetch_data(size_t out_data_bytes_size, void* out_data) = 0;
virtual bool fetch_bitstream_data(std::shared_ptr<mfx_bitstream> &in_out_bitsream) = 0;
/**
* The function is used by onevpl::GSource to check more binary data availability.
@@ -0,0 +1,102 @@
// 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) 2021 Intel Corporation
#ifndef GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP
#define GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP
#include <limits>
#include <map>
#include <string>
#include <vector>
#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS
namespace cv {
namespace gapi {
namespace wip {
namespace onevpl {
enum class AccelType: uint8_t {
HOST,
DX11,
LAST_VALUE = std::numeric_limits<uint8_t>::max()
};
GAPI_EXPORTS const char* to_cstring(AccelType type);
struct IDeviceSelector;
struct GAPI_EXPORTS Device {
friend struct IDeviceSelector;
using Ptr = void*;
~Device();
const std::string& get_name() const;
Ptr get_ptr() const;
AccelType get_type() const;
private:
Device(Ptr device_ptr, const std::string& device_name,
AccelType device_type);
std::string name;
Ptr ptr;
AccelType type;
};
struct GAPI_EXPORTS Context {
friend struct IDeviceSelector;
using Ptr = void*;
~Context();
Ptr get_ptr() const;
AccelType get_type() const;
private:
Context(Ptr ctx_ptr, AccelType ctx_type);
Ptr ptr;
AccelType type;
};
struct GAPI_EXPORTS IDeviceSelector {
using Ptr = std::shared_ptr<IDeviceSelector>;
struct GAPI_EXPORTS Score {
friend struct IDeviceSelector;
using Type = int16_t;
static constexpr Type MaxActivePriority = std::numeric_limits<Type>::max();
static constexpr Type MinActivePriority = 0;
static constexpr Type MaxPassivePriority = MinActivePriority - 1;
static constexpr Type MinPassivePriority = std::numeric_limits<Type>::min();
Score(Type val);
~Score();
operator Type () const;
Type get() const;
friend bool operator< (Score lhs, Score rhs) {
return lhs.get() < rhs.get();
}
private:
Type value;
};
using DeviceScoreTable = std::map<Score, Device>;
using DeviceContexts = std::vector<Context>;
virtual ~IDeviceSelector();
virtual DeviceScoreTable select_devices() const = 0;
virtual DeviceContexts select_context() = 0;
protected:
template<typename Entity, typename ...Args>
static Entity create(Args &&...args) {
return Entity(std::forward<Args>(args)...);
}
};
} // namespace onevpl
} // namespace wip
} // namespace gapi
} // namespace cv
#endif // GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP
@@ -12,6 +12,7 @@
#include <opencv2/gapi/streaming/source.hpp>
#include <opencv2/gapi/streaming/onevpl/cfg_params.hpp>
#include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
namespace cv {
namespace gapi {
@@ -38,8 +39,31 @@ public:
GSource(const std::string& filePath,
const CfgParams& cfg_params = CfgParams{});
GSource(const std::string& filePath,
const CfgParams& cfg_params,
const std::string& device_id,
void* accel_device_ptr,
void* accel_ctx_ptr);
GSource(const std::string& filePath,
const CfgParams& cfg_params,
std::shared_ptr<IDeviceSelector> selector);
GSource(std::shared_ptr<IDataProvider> source,
const CfgParams& cfg_params = CfgParams{});
GSource(std::shared_ptr<IDataProvider> source,
const CfgParams& cfg_params,
const std::string& device_id,
void* accel_device_ptr,
void* accel_ctx_ptr);
GSource(std::shared_ptr<IDataProvider> source,
const CfgParams& cfg_params,
std::shared_ptr<IDeviceSelector> selector);
~GSource() override;
bool pull(cv::gapi::wip::Data& data) override;
@@ -51,6 +75,8 @@ private:
};
} // namespace onevpl
using GVPLSource = onevpl::GSource;
template<class... Args>
GAPI_EXPORTS_W cv::Ptr<IStreamSource> inline make_onevpl_src(Args&&... args)
{
@@ -31,7 +31,11 @@ namespace internal
#if defined(__GXX_RTTI) || defined(_CPPRTTI)
return dynamic_cast<T>(operand);
#else
#warning used static cast instead of dynamic because RTTI is disabled
#ifdef __GNUC__
#warning used static cast instead of dynamic because RTTI is disabled
#else
#pragma message("WARNING: used static cast instead of dynamic because RTTI is disabled")
#endif
return static_cast<T>(operand);
#endif
}
@@ -33,7 +33,7 @@ namespace util
// Constructors
// NB.: there were issues with Clang 3.8 when =default() was used
// instead {}
optional() {};
optional() {}
optional(const optional&) = default;
explicit optional(T&&) noexcept;
explicit optional(const T&) noexcept;
@@ -116,6 +116,13 @@ namespace detail
using type = std::tuple<Objs...>;
static type get(std::tuple<Objs...>&& objs) { return std::forward<std::tuple<Objs...>>(objs); }
};
template<typename... Ts>
struct make_void { typedef void type;};
template<typename... Ts>
using void_t = typename make_void<Ts...>::type;
} // namespace detail
namespace util
+2 -2
View File
@@ -11,7 +11,7 @@
#include <opencv2/gapi/python/python.hpp>
// NB: Python wrapper replaces :: with _ for classes
using gapi_GKernelPackage = cv::gapi::GKernelPackage;
using gapi_GKernelPackage = cv::GKernelPackage;
using gapi_GNetPackage = cv::gapi::GNetPackage;
using gapi_ie_PyParams = cv::gapi::ie::PyParams;
using gapi_wip_IStreamSource_Ptr = cv::Ptr<cv::gapi::wip::IStreamSource>;
@@ -829,7 +829,7 @@ static GMetaArgs run_py_meta(cv::detail::PyObjectHolder out_meta,
static PyObject* pyopencv_cv_gapi_kernels(PyObject* , PyObject* py_args, PyObject*)
{
using namespace cv;
gapi::GKernelPackage pkg;
GKernelPackage pkg;
Py_ssize_t size = PyTuple_Size(py_args);
for (int i = 0; i < size; ++i)
+1 -1
View File
@@ -5,7 +5,7 @@ namespace cv
{
struct GAPI_EXPORTS_W_SIMPLE GCompileArg
{
GAPI_WRAP GCompileArg(gapi::GKernelPackage arg);
GAPI_WRAP GCompileArg(GKernelPackage arg);
GAPI_WRAP GCompileArg(gapi::GNetPackage arg);
GAPI_WRAP GCompileArg(gapi::streaming::queue_capacity arg);
};
@@ -26,62 +26,62 @@ namespace opencv_test
};
//------------------------------------------------------------------------------
class AddPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class AddCPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class SubPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class SubCPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class SubRCPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class MulPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class MulDoublePerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class MulCPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class DivPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class DivCPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class DivRCPerfTest : public TestPerfParams<tuple<compare_f,cv::Size, MatType, int, cv::GCompileArgs>> {};
class MaskPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class MeanPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class PhasePerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class SqrtPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class AddPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class AddCPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class SubPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class SubCPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class SubRCPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class MulPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, double, cv::GCompileArgs>> {};
class MulDoublePerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class MulCPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class DivPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, double, cv::GCompileArgs>> {};
class DivCPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, double, cv::GCompileArgs>> {};
class DivRCPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, double, cv::GCompileArgs>> {};
class MaskPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class MeanPerfTest : public TestPerfParams<tuple<compare_scalar_f, cv::Size, MatType, cv::GCompileArgs>> {};
class Polar2CartPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
class Cart2PolarPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
class CmpPerfTest : public TestPerfParams<tuple<CmpTypes, cv::Size, MatType, cv::GCompileArgs>> {};
class CmpPerfTest : public TestPerfParams<tuple<compare_f, CmpTypes, cv::Size, MatType, cv::GCompileArgs>> {};
class CmpWithScalarPerfTest : public TestPerfParams<tuple<compare_f, CmpTypes, cv::Size, MatType, cv::GCompileArgs>> {};
class BitwisePerfTest : public TestPerfParams<tuple<bitwiseOp, bool, cv::Size, MatType, cv::GCompileArgs>> {};
class BitwiseNotPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class SelectPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class MinPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class MaxPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class AbsDiffPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class AbsDiffCPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class BitwisePerfTest : public TestPerfParams<tuple<compare_f, bitwiseOp, bool, cv::Size, MatType, cv::GCompileArgs>> {};
class BitwiseNotPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class SelectPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class MinPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class MaxPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class AbsDiffPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class AbsDiffCPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class SumPerfTest : public TestPerfParams<tuple<compare_scalar_f, cv::Size, MatType, cv::GCompileArgs>> {};
class CountNonZeroPerfTest : public TestPerfParams<tuple<compare_scalar_f, cv::Size, MatType, cv::GCompileArgs>> {};
class AddWeightedPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class NormPerfTest : public TestPerfParams<tuple<compare_scalar_f, NormTypes, cv::Size, MatType, cv::GCompileArgs>> {};
class IntegralPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class ThresholdPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class ThresholdOTPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class InRangePerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class Split3PerfTest : public TestPerfParams<tuple<cv::Size, cv::GCompileArgs>> {};
class Split4PerfTest : public TestPerfParams<tuple<cv::Size, cv::GCompileArgs>> {};
class Merge3PerfTest : public TestPerfParams<tuple<cv::Size, cv::GCompileArgs>> {};
class Merge4PerfTest : public TestPerfParams<tuple<cv::Size, cv::GCompileArgs>> {};
class RemapPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class FlipPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
class CropPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::Rect, cv::GCompileArgs>> {};
class CopyPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class ConcatHorPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class ConcatHorVecPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class ConcatVertPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class ConcatVertVecPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
class LUTPerfTest : public TestPerfParams<tuple<MatType, MatType, cv::Size, cv::GCompileArgs>> {};
class IntegralPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class ThresholdPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class ThresholdOTPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class InRangePerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class Split3PerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
class Split4PerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
class Merge3PerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
class Merge4PerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
class RemapPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class FlipPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
class CropPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::Rect, cv::GCompileArgs>> {};
class CopyPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class ConcatHorPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class ConcatHorVecPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class ConcatVertPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class ConcatVertVecPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class LUTPerfTest : public TestPerfParams<tuple<compare_f, MatType, MatType, cv::Size, cv::GCompileArgs>> {};
class ConvertToPerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, double, double, cv::GCompileArgs>> {};
class KMeansNDPerfTest : public TestPerfParams<tuple<cv::Size, CompareMats, int,
cv::KmeansFlags, cv::GCompileArgs>> {};
class KMeans2DPerfTest : public TestPerfParams<tuple<int, int, cv::KmeansFlags,
cv::GCompileArgs>> {};
class KMeans3DPerfTest : public TestPerfParams<tuple<int, int, cv::KmeansFlags,
cv::GCompileArgs>> {};
class KMeansNDPerfTest : public TestPerfParams<tuple<cv::Size, CompareMats, int, cv::KmeansFlags, cv::GCompileArgs>> {};
class KMeans2DPerfTest : public TestPerfParams<tuple<int, int, cv::KmeansFlags, cv::GCompileArgs>> {};
class KMeans3DPerfTest : public TestPerfParams<tuple<int, int, cv::KmeansFlags, cv::GCompileArgs>> {};
class TransposePerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class ResizePerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, cv::Size, cv::GCompileArgs>> {};
class BottleneckKernelsConstInputPerfTest : public TestPerfParams<tuple<compare_f, std::string, cv::GCompileArgs>> {};
class ResizeFxFyPerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, double, double, cv::GCompileArgs>> {};
class ResizeInSimpleGraphPerfTest : public TestPerfParams<tuple<compare_f, MatType, cv::Size, double, double, cv::GCompileArgs>> {};
class ParseSSDBLPerfTest : public TestPerfParams<tuple<cv::Size, float, int, cv::GCompileArgs>>, public ParserSSDTest {};
class ParseSSDPerfTest : public TestPerfParams<tuple<cv::Size, float, bool, bool, cv::GCompileArgs>>, public ParserSSDTest {};
class ParseYoloPerfTest : public TestPerfParams<tuple<cv::Size, float, float, int, cv::GCompileArgs>>, public ParserYoloTest {};
File diff suppressed because it is too large Load Diff
@@ -130,7 +130,7 @@ PERF_TEST_P_(BuildPyr_CalcOptFlow_PipelinePerfTest, TestPerformance)
auto customKernel = gapi::kernels<GCPUMinScalar>();
auto kernels = gapi::combine(customKernel,
params.compileArgs[0].get<gapi::GKernelPackage>());
params.compileArgs[0].get<GKernelPackage>());
params.compileArgs = compile_args(kernels);
OptFlowLKTestOutput outOCV { outPtsOCV, outStatusOCV, outErrOCV };
@@ -159,7 +159,6 @@ PERF_TEST_P_(BuildPyr_CalcOptFlow_PipelinePerfTest, TestPerformance)
PERF_TEST_P_(BackgroundSubtractorPerfTest, TestPerformance)
{
namespace gvideo = cv::gapi::video;
initTestDataPath();
gvideo::BackgroundSubtractorType opType;
std::string filePath = "";
+275 -211
View File
@@ -14,100 +14,127 @@
namespace opencv_test
{
INSTANTIATE_TEST_CASE_P(PhasePerfTestFluid, PhasePerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_32FC1, CV_64FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(SqrtPerfTestFluid, SqrtPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_32FC1, CV_64FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(AddPerfTestCPU, AddPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(AddCPerfTestCPU, AddCPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(SubPerfTestCPU, SubPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(SubCPerfTestCPU, SubCPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(SubRCPerfTestCPU, SubRCPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(MulPerfTestCPU, MulPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(2.0),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(MulDoublePerfTestCPU, MulDoublePerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(MulCPerfTestCPU, MulCPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(DivPerfTestCPU, DivPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_16S, CV_32F),
Values(2.3),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(DivCPerfTestCPU, DivCPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(1.0),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(DivRCPerfTestCPU, DivRCPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(1.0),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(MaskPerfTestCPU, MaskPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(MeanPerfTestCPU, MeanPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(Polar2CartPerfTestCPU, Polar2CartPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(Cart2PolarPerfTestCPU, Cart2PolarPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(CmpPerfTestCPU, CmpPerfTest,
Combine(Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(CmpWithScalarPerfTestCPU, CmpWithScalarPerfTest,
Combine(Values(AbsExact().to_compare_f()),
@@ -117,161 +144,184 @@ INSTANTIATE_TEST_CASE_P(CmpWithScalarPerfTestCPU, CmpWithScalarPerfTest,
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(BitwisePerfTestCPU, BitwisePerfTest,
Combine(Values(AND, OR, XOR),
Combine(Values(AbsExact().to_compare_f()),
Values(AND, OR, XOR),
testing::Bool(),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(BitwiseNotPerfTestCPU, BitwiseNotPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(SelectPerfTestCPU, SelectPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(MinPerfTestCPU, MinPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(MaxPerfTestCPU, MaxPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(AbsDiffPerfTestCPU, AbsDiffPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(AbsDiffCPerfTestCPU, AbsDiffCPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(SumPerfTestCPU, SumPerfTest,
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
//Values(0.0),
Values(cv::compile_args(CORE_CPU))));
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(CountNonZeroPerfTestCPU, CountNonZeroPerfTest,
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(AddWeightedPerfTestCPU, AddWeightedPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_32F),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(NormPerfTestCPU, NormPerfTest,
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(NORM_INF, NORM_L1, NORM_L2),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Values(NORM_INF, NORM_L1, NORM_L2),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(IntegralPerfTestCPU, IntegralPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ThresholdPerfTestCPU, ThresholdPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ThresholdPerfTestCPU, ThresholdOTPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1),
Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1),
Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(InRangePerfTestCPU, InRangePerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(Split3PerfTestCPU, Split3PerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(Split4PerfTestCPU, Split4PerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(Merge3PerfTestCPU, Merge3PerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(Merge4PerfTestCPU, Merge4PerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(RemapPerfTestCPU, RemapPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(FlipPerfTestCPU, FlipPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(0, 1, -1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(0, 1, -1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(CropPerfTestCPU, CropPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(CopyPerfTestCPU, CopyPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ConcatHorPerfTestCPU, ConcatHorPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ConcatHorVecPerfTestCPU, ConcatHorVecPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ConcatVertPerfTestCPU, ConcatVertPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ConcatVertVecPerfTestCPU, ConcatVertVecPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(LUTPerfTestCPU, LUTPerfTest,
Combine(Values(CV_8UC1, CV_8UC3),
Values(CV_8UC1),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC1, CV_8UC3),
Values(CV_8UC1),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(LUTPerfTestCustomCPU, LUTPerfTest,
Combine(Values(CV_8UC3),
Values(CV_8UC3),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC3),
Values(CV_8UC3),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ConvertToPerfTestCPU, ConvertToPerfTest,
Combine(Values(AbsExact().to_compare_f()),
@@ -283,86 +333,100 @@ INSTANTIATE_TEST_CASE_P(ConvertToPerfTestCPU, ConvertToPerfTest,
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(KMeansNDPerfTestCPU, KMeansNDPerfTest,
Combine(Values(cv::Size(1, 20),
cv::Size(16, 4096)),
Values(AbsTolerance(0.01).to_compare_obj()),
Values(5, 15),
Values(cv::KMEANS_RANDOM_CENTERS,
cv::KMEANS_PP_CENTERS,
cv::KMEANS_RANDOM_CENTERS | cv::KMEANS_USE_INITIAL_LABELS,
cv::KMEANS_PP_CENTERS | cv::KMEANS_USE_INITIAL_LABELS),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(cv::Size(1, 20),
cv::Size(16, 4096)),
Values(AbsTolerance(0.01).to_compare_obj()),
Values(5, 15),
Values(cv::KMEANS_RANDOM_CENTERS,
cv::KMEANS_PP_CENTERS,
cv::KMEANS_RANDOM_CENTERS | cv::KMEANS_USE_INITIAL_LABELS,
cv::KMEANS_PP_CENTERS | cv::KMEANS_USE_INITIAL_LABELS),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(KMeans2DPerfTestCPU, KMeans2DPerfTest,
Combine(Values(20, 4096),
Values(5, 15),
Values(cv::KMEANS_RANDOM_CENTERS,
cv::KMEANS_PP_CENTERS,
cv::KMEANS_RANDOM_CENTERS | cv::KMEANS_USE_INITIAL_LABELS,
cv::KMEANS_PP_CENTERS | cv::KMEANS_USE_INITIAL_LABELS),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(20, 4096),
Values(5, 15),
Values(cv::KMEANS_RANDOM_CENTERS,
cv::KMEANS_PP_CENTERS,
cv::KMEANS_RANDOM_CENTERS | cv::KMEANS_USE_INITIAL_LABELS,
cv::KMEANS_PP_CENTERS | cv::KMEANS_USE_INITIAL_LABELS),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(KMeans3DPerfTestCPU, KMeans3DPerfTest,
Combine(Values(20, 4096),
Values(5, 15),
Values(cv::KMEANS_RANDOM_CENTERS,
cv::KMEANS_PP_CENTERS,
cv::KMEANS_RANDOM_CENTERS | cv::KMEANS_USE_INITIAL_LABELS,
cv::KMEANS_PP_CENTERS | cv::KMEANS_USE_INITIAL_LABELS),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(20, 4096),
Values(5, 15),
Values(cv::KMEANS_RANDOM_CENTERS,
cv::KMEANS_PP_CENTERS,
cv::KMEANS_RANDOM_CENTERS | cv::KMEANS_USE_INITIAL_LABELS,
cv::KMEANS_PP_CENTERS | cv::KMEANS_USE_INITIAL_LABELS),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(TransposePerfTestCPU, TransposePerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ResizePerfTestCPU, ResizePerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::Size(64, 64),
cv::Size(30, 30)),
Values(cv::compile_args(CORE_CPU))));
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values( cv::Size(64, 64),
cv::Size(32, 32)),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(BottleneckKernelsPerfTestCPU, BottleneckKernelsConstInputPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values( "cv/optflow/frames/1080p_00.png", "cv/optflow/frames/720p_00.png",
"cv/optflow/frames/VGA_00.png", "cv/dnn_face/recognition/Aaron_Tippin_0001.jpg"),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ResizeInSimpleGraphPerfTestCPU, ResizeInSimpleGraphPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC3),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5),
Values(0.5),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ResizeFxFyPerfTestCPU, ResizeFxFyPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5, 0.1),
Values(0.5, 0.1),
Values(cv::compile_args(CORE_CPU))));
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5, 0.1),
Values(0.5, 0.1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ParseSSDBLPerfTestCPU, ParseSSDBLPerfTest,
Combine(Values(sz720p, sz1080p),
Values(0.3f, 0.7f),
Values(0, 1),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(sz720p, sz1080p),
Values(0.3f, 0.7f),
Values(0, 1),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ParseSSDPerfTestCPU, ParseSSDPerfTest,
Combine(Values(sz720p, sz1080p),
Values(0.3f, 0.7f),
testing::Bool(),
testing::Bool(),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(sz720p, sz1080p),
Values(0.3f, 0.7f),
testing::Bool(),
testing::Bool(),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ParseYoloPerfTestCPU, ParseYoloPerfTest,
Combine(Values(sz720p, sz1080p),
Values(0.3f, 0.7f),
Values(0.5),
Values(7, 80),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(sz720p, sz1080p),
Values(0.3f, 0.7f),
Values(0.5),
Values(7, 80),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(SizePerfTestCPU, SizePerfTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_32FC1),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(CV_8UC1, CV_8UC3, CV_32FC1),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(SizeRPerfTestCPU, SizeRPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_CPU))));
} // opencv_test
@@ -12,99 +12,128 @@
namespace opencv_test
{
INSTANTIATE_TEST_CASE_P(PhasePerfTestFluid, PhasePerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_32FC1, CV_64FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(SqrtPerfTestFluid, SqrtPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_32FC1, CV_64FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(AddPerfTestFluid, AddPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(AddCPerfTestFluid, AddCPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(AddCPerfTestFluid, AddCPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_16S, CV_32F),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(SubPerfTestFluid, SubPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(SubCPerfTestFluid, SubCPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(SubCPerfTestFluid, SubCPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(SubRCPerfTestFluid, SubRCPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(SubRCPerfTestFluid, SubRCPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(MulPerfTestFluid, MulPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(MulPerfTestFluid, MulPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_16S, CV_32F),
Values(2.0),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(MulDoublePerfTestFluid, MulDoublePerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(MulDoublePerfTestFluid, MulDoublePerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(MulCPerfTestFluid, MulCPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(MulCPerfTestFluid, MulCPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(DivPerfTestFluid, DivPerfTest,
// Combine(Values(AbsExact().to_compare_f()),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(DivPerfTestFluid, DivPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_16U, CV_16S, CV_32F),
Values(2.3),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(DivCPerfTestFluid, DivCPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(DivCPerfTestFluid, DivCPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F),
Values(1.0),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(DivRCPerfTestFluid, DivRCPerfTest,
// Combine(Values(AbsExact().to_compare_f()),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(-1, CV_8U, CV_16U, CV_32F),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(DivRCPerfTestFluid, DivRCPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_32FC1),
Values(-1, CV_8U, CV_32F),
Values(1.0),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(MaskPerfTestFluid, MaskPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(MeanPerfTestFluid, MeanPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(MeanPerfTestFluid, MeanPerfTest,
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(Polar2CartPerfTestFluid, Polar2CartPerfTest,
// Combine(Values(AbsExact().to_compare_f()),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(Polar2CartPerfTestFluid, Polar2CartPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(Cart2PolarPerfTestFluid, Cart2PolarPerfTest,
// Combine(Values(AbsExact().to_compare_f()),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(Cart2PolarPerfTestFluid, Cart2PolarPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-04, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(CmpPerfTestFluid, CmpPerfTest,
// Combine(Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(CmpPerfTestFluid, CmpPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(CmpWithScalarPerfTestFluid, CmpWithScalarPerfTest,
Combine(Values(AbsSimilarPoints(1, 0.01).to_compare_f()),
@@ -114,50 +143,54 @@ INSTANTIATE_TEST_CASE_P(CmpWithScalarPerfTestFluid, CmpWithScalarPerfTest,
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(BitwisePerfTestFluid, BitwisePerfTest,
Combine(Values(AND, OR, XOR),
Combine(Values(AbsExact().to_compare_f()),
Values(AND, OR, XOR),
testing::Bool(),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(BitwiseNotPerfTestFluid, BitwiseNotPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(SelectPerfTestFluid, SelectPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(SelectPerfTestFluid, SelectPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(MinPerfTestFluid, MinPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(MinPerfTestFluid, MinPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(MaxPerfTestFluid, MaxPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(MaxPerfTestFluid, MaxPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(AbsDiffPerfTestFluid, AbsDiffPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(AbsDiffCPerfTestFluid, AbsDiffCPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_8UC2,
CV_16UC2, CV_16SC2, CV_8UC3, CV_16UC3,
CV_16SC3, CV_8UC4, CV_16UC4, CV_16SC4),
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(SumPerfTestFluid, SumPerfTest,
// Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// //Values(0.0),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(SumPerfTestFluid, SumPerfTest,
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(AddWeightedPerfTestFluid, AddWeightedPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
@@ -173,102 +206,121 @@ INSTANTIATE_TEST_CASE_P(AddWeightedPerfTestFluid_short, AddWeightedPerfTest,
Values(-1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(NormPerfTestFluid, NormPerfTest,
// Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
// Values(NORM_INF, NORM_L1, NORM_L2),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(IntegralPerfTestFluid, IntegralPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(ThresholdPerfTestFluid, ThresholdPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV),
// Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(ThresholdPerfTestFluid, ThresholdOTPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1),
// Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE),
// Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(InRangePerfTestFluid, InRangePerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(Split3PerfTestFluid, Split3PerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
INSTANTIATE_TEST_CASE_P(NormPerfTestFluid, NormPerfTest,
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(NORM_INF, NORM_L1, NORM_L2),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(Split4PerfTestFluid, Split4PerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(IntegralPerfTestFluid, IntegralPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(Merge3PerfTestFluid, Merge3PerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(ThresholdPerfTestFluid, ThresholdPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC,
cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(Merge4PerfTestFluid, Merge4PerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(ThresholdPerfTestFluid, ThresholdOTPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1),
Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(RemapPerfTestFluid, RemapPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(InRangePerfTestFluid, InRangePerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(FlipPerfTestFluid, FlipPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(0, 1, -1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(Split3PerfTestFluid, Split3PerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(CropPerfTestFluid, CropPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(Split4PerfTestFluid, Split4PerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(ConcatHorPerfTestFluid, ConcatHorPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(Merge3PerfTestFluid, Merge3PerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(ConcatHorVecPerfTestFluid, ConcatHorVecPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(Merge4PerfTestFluid, Merge4PerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(ConcatVertPerfTestFluid, ConcatVertPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(RemapPerfTestFluid, RemapPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(ConcatVertVecPerfTestFluid, ConcatVertVecPerfTest,
// Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(FlipPerfTestFluid, FlipPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(0, 1, -1),
Values(cv::compile_args(CORE_FLUID))));
// INSTANTIATE_TEST_CASE_P(LUTPerfTestFluid, LUTPerfTest,
// Combine(Values(CV_8UC1, CV_8UC3),
// Values(CV_8UC1),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(CropPerfTestFluid, CropPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(ConcatHorPerfTestFluid, ConcatHorPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(ConcatHorVecPerfTestFluid, ConcatHorVecPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(ConcatVertPerfTestFluid, ConcatVertPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(ConcatVertVecPerfTestFluid, ConcatVertVecPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(LUTPerfTestFluid, LUTPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC1, CV_8UC3),
Values(CV_8UC1),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::compile_args(CORE_FLUID))));
// FIXIT: This test case doesn't work [3030]
// INSTANTIATE_TEST_CASE_P(LUTPerfTestCustomFluid, LUTPerfTest,
// Combine(Values(CV_8UC3),
// Values(CV_8UC3),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(cv::compile_args(CORE_FLUID))));
// Combine(Values(AbsExact().to_compare_f()),
// Values(CV_8UC3),
// Values(CV_8UC3),
// Values(szSmall128, szVGA, sz720p, sz1080p),
// Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(ConvertToPerfTestFluid, ConvertToPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(szSmall128, szVGA, sz720p, sz1080p),
@@ -277,20 +329,35 @@ INSTANTIATE_TEST_CASE_P(ConvertToPerfTestFluid, ConvertToPerfTest,
Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(ResizePerfTestFluid, ResizePerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC3/*CV_8UC1, CV_16UC1, CV_16SC1*/),
Values(/*cv::INTER_NEAREST,*/ cv::INTER_LINEAR/*, cv::INTER_AREA*/),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::Size(64, 64),
cv::Size(30, 30)),
Values(cv::compile_args(CORE_FLUID))));
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values(CV_8UC3),
Values(cv::INTER_LINEAR),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(cv::Size(64, 64),
cv::Size(30, 30)),
Values(cv::compile_args(CORE_FLUID))));
#define IMGPROC_FLUID cv::gapi::imgproc::fluid::kernels()
INSTANTIATE_TEST_CASE_P(BottleneckKernelsPerfTestFluid, BottleneckKernelsConstInputPerfTest,
Combine(Values(AbsSimilarPoints(0, 1).to_compare_f()),
Values("cv/optflow/frames/1080p_00.png", "cv/optflow/frames/720p_00.png",
"cv/optflow/frames/VGA_00.png", "cv/dnn_face/recognition/Aaron_Tippin_0001.jpg"),
Values(cv::compile_args(CORE_FLUID, IMGPROC_FLUID))));
INSTANTIATE_TEST_CASE_P(ResizeInSimpleGraphPerfTestFluid, ResizeInSimpleGraphPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values(CV_8UC3),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5),
Values(0.5),
Values(cv::compile_args(CORE_FLUID, IMGPROC_FLUID))));
INSTANTIATE_TEST_CASE_P(ResizeFxFyPerfTestFluid, ResizeFxFyPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC3/*CV_8UC1, CV_16UC1, CV_16SC1*/),
Values(/*cv::INTER_NEAREST,*/ cv::INTER_LINEAR/*, cv::INTER_AREA*/),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5, 0.1),
Values(0.5, 0.1),
Values(cv::compile_args(CORE_FLUID))));
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values(CV_8UC3),
Values(cv::INTER_LINEAR),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5, 0.1),
Values(0.5, 0.1),
Values(cv::compile_args(CORE_FLUID))));
} // opencv_test
+235 -195
View File
@@ -14,291 +14,331 @@ namespace opencv_test
{
INSTANTIATE_TEST_CASE_P(AddPerfTestGPU, AddPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(AddCPerfTestGPU, AddCPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(SubPerfTestGPU, SubPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(SubCPerfTestGPU, SubCPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(SubRCPerfTestGPU, SubRCPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(MulPerfTestGPU, MulPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(2.0),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(MulDoublePerfTestGPU, MulDoublePerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(MulCPerfTestGPU, MulCPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(DivPerfTestGPU, DivPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsTolerance(2).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(2.3),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(DivCPerfTestGPU, DivCPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(1.0),
Values(cv::compile_args(CORE_GPU))));
// FIXIT: CV_16SC1 test case doesn't work with OpenCL [3031]
INSTANTIATE_TEST_CASE_P(DivRCPerfTestGPU, DivRCPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
//TODO: mask test doesn't work
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, /*CV_16SC1,*/ CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(1.0),
Values(cv::compile_args(CORE_GPU))));
// FIXIT: mask test on GPU doesn't work [3032]
INSTANTIATE_TEST_CASE_P(DISABLED_MaskPerfTestGPU, MaskPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(MeanPerfTestGPU, MeanPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(Polar2CartPerfTestGPU, Polar2CartPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(Cart2PolarPerfTestGPU, Cart2PolarPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-2, 2).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(Tolerance_FloatRel_IntAbs(1e-2, 2).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(CmpPerfTestGPU, CmpPerfTest,
Combine(Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(CmpWithScalarPerfTestGPU, CmpWithScalarPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(BitwisePerfTestGPU, BitwisePerfTest,
Combine(Values(AND, OR, XOR),
testing::Bool(),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(AND, OR, XOR),
testing::Bool(),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(BitwiseNotPerfTestGPU, BitwiseNotPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(SelectPerfTestGPU, SelectPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(MinPerfTestGPU, MinPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(MaxPerfTestGPU, MaxPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(AbsDiffPerfTestGPU, AbsDiffPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(AbsDiffCPerfTestGPU, AbsDiffCPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(SumPerfTestGPU, SumPerfTest,
Combine(Values(AbsToleranceScalar(1e-5).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsToleranceScalar(1e-5).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(CountNonZeroPerfTestGPU, CountNonZeroPerfTest,
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(AddWeightedPerfTestGPU, AddWeightedPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( -1, CV_8U, CV_16U, CV_32F ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(NormPerfTestGPU, NormPerfTest,
Combine(Values(AbsToleranceScalar(1e-5).to_compare_f()),
Values(NORM_INF, NORM_L1, NORM_L2),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsToleranceScalar(1e-5).to_compare_f()),
Values(NORM_INF, NORM_L1, NORM_L2),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(IntegralPerfTestGPU, IntegralPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ThresholdPerfTestGPU, ThresholdPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV,
cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ThresholdPerfTestGPU, ThresholdOTPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1 ),
Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1 ),
Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(InRangePerfTestGPU, InRangePerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(Split3PerfTestGPU, Split3PerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(Split4PerfTestGPU, Split4PerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(Merge3PerfTestGPU, Merge3PerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(Merge4PerfTestGPU, Merge4PerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(RemapPerfTestGPU, RemapPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(FlipPerfTestGPU, FlipPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(0,1,-1),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(0,1,-1),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(CropPerfTestGPU, CropPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ConcatHorPerfTestGPU, ConcatHorPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ConcatVertPerfTestGPU, ConcatVertPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
//TODO: fix this backend to allow ConcatVertVec ConcatHorVec
INSTANTIATE_TEST_CASE_P(DISABLED_ConcatHorVecPerfTestGPU, ConcatHorVecPerfTest,
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ConcatHorVecPerfTestGPU, ConcatHorVecPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(DISABLED_ConcatVertVecPerfTestGPU, ConcatVertVecPerfTest,
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ConcatVertVecPerfTestGPU, ConcatVertVecPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(LUTPerfTestGPU, LUTPerfTest,
Combine(Values(CV_8UC1, CV_8UC3),
Values(CV_8UC1),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC1, CV_8UC3),
Values(CV_8UC1),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(LUTPerfTestCustomGPU, LUTPerfTest,
Combine(Values(CV_8UC3),
Values(CV_8UC3),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC3),
Values(CV_8UC3),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ConvertToPerfTestGPU, ConvertToPerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_32FC1),
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(2.5, 1.0),
Values(0.0),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_32FC1),
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(2.5, 1.0),
Values(0.0),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(TransposePerfTestGPU, TransposePerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ResizePerfTestGPU, ResizePerfTest,
Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::Size(64,64),
cv::Size(30,30)),
Values(cv::compile_args(CORE_GPU))));
Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::Size(64,64),
cv::Size(30,30)),
Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ResizeFxFyPerfTestGPU, ResizeFxFyPerfTest,
Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(0.5, 0.1),
Values(0.5, 0.1),
Values(cv::compile_args(CORE_GPU))));
}
Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(0.5, 0.1),
Values(0.5, 0.1),
Values(cv::compile_args(CORE_GPU))));
} // opencv_test
@@ -0,0 +1,99 @@
// 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) 2021 Intel Corporation
#ifdef HAVE_ONEVPL
#include "../perf_precomp.hpp"
#include "../../test/common/gapi_tests_common.hpp"
#include <opencv2/gapi/streaming/onevpl/source.hpp>
#include <opencv2/gapi/streaming/cap.hpp>
namespace opencv_test
{
using namespace perf;
const std::string files[] = {
"highgui/video/big_buck_bunny.h265",
"highgui/video/big_buck_bunny.h264",
"highgui/video/sample_322x242_15frames.yuv420p.libx265.mp4",
};
const std::string codec[] = {
"MFX_CODEC_HEVC",
"MFX_CODEC_AVC",
"",
};
using source_t = std::string;
using codec_t = std::string;
using accel_mode_t = std::string;
using source_description_t = std::tuple<source_t, codec_t, accel_mode_t>;
class OneVPLSourcePerfTest : public TestPerfParams<source_description_t> {};
class VideoCapSourcePerfTest : public TestPerfParams<source_t> {};
PERF_TEST_P_(OneVPLSourcePerfTest, TestPerformance)
{
using namespace cv::gapi::wip::onevpl;
const auto params = GetParam();
source_t src = findDataFile(get<0>(params));
codec_t type = get<1>(params);
accel_mode_t mode = get<2>(params);
std::vector<CfgParam> cfg_params {
CfgParam::create_implementation("MFX_IMPL_TYPE_HARDWARE"),
};
if (!type.empty()) {
cfg_params.push_back(CfgParam::create_decoder_id(type.c_str()));
}
if (!mode.empty()) {
cfg_params.push_back(CfgParam::create_acceleration_mode(mode.c_str()));
}
auto source_ptr = cv::gapi::wip::make_onevpl_src(src, cfg_params);
cv::gapi::wip::Data out;
TEST_CYCLE()
{
source_ptr->pull(out);
}
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(VideoCapSourcePerfTest, TestPerformance)
{
using namespace cv::gapi::wip;
source_t src = findDataFile(GetParam());
auto source_ptr = make_src<GCaptureSource>(src);
Data out;
TEST_CYCLE()
{
source_ptr->pull(out);
}
SANITY_CHECK_NOTHING();
}
INSTANTIATE_TEST_CASE_P(Streaming, OneVPLSourcePerfTest,
Values(source_description_t(files[0], codec[0], ""),
source_description_t(files[0], codec[0], "MFX_ACCEL_MODE_VIA_D3D11"),
source_description_t(files[1], codec[1], ""),
source_description_t(files[1], codec[1], "MFX_ACCEL_MODE_VIA_D3D11"),
source_description_t(files[2], codec[2], ""),
source_description_t(files[2], codec[2], "MFX_ACCEL_MODE_VIA_D3D11")));
INSTANTIATE_TEST_CASE_P(Streaming, VideoCapSourcePerfTest,
Values(files[0],
files[1],
files[2]));
} // namespace opencv_test
#endif // HAVE_ONEVPL
-253
View File
@@ -1,253 +0,0 @@
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/gapi.hpp>
#include <opencv2/gapi/core.hpp>
#include <opencv2/gapi/imgproc.hpp>
#include <opencv2/gapi/s11n.hpp>
#include <opencv2/gapi/garg.hpp>
#include <opencv2/gapi/gcommon.hpp>
#include <opencv2/gapi/cpu/gcpukernel.hpp>
#include <opencv2/gapi/fluid/core.hpp>
#include <opencv2/gapi/fluid/imgproc.hpp>
static void gscalar_example()
{
//! [gscalar_implicit]
cv::GMat a;
cv::GMat b = a + 1;
//! [gscalar_implicit]
}
static void typed_example()
{
const cv::Size sz(32, 32);
cv::Mat
in_mat1 (sz, CV_8UC1),
in_mat2 (sz, CV_8UC1),
out_mat_untyped(sz, CV_8UC1),
out_mat_typed1 (sz, CV_8UC1),
out_mat_typed2 (sz, CV_8UC1);
cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255));
cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255));
//! [Untyped_Example]
// Untyped G-API ///////////////////////////////////////////////////////////
cv::GComputation cvtU([]()
{
cv::GMat in1, in2;
cv::GMat out = cv::gapi::add(in1, in2);
return cv::GComputation({in1, in2}, {out});
});
std::vector<cv::Mat> u_ins = {in_mat1, in_mat2};
std::vector<cv::Mat> u_outs = {out_mat_untyped};
cvtU.apply(u_ins, u_outs);
//! [Untyped_Example]
//! [Typed_Example]
// Typed G-API /////////////////////////////////////////////////////////////
cv::GComputationT<cv::GMat (cv::GMat, cv::GMat)> cvtT([](cv::GMat m1, cv::GMat m2)
{
return m1+m2;
});
cvtT.apply(in_mat1, in_mat2, out_mat_typed1);
auto cvtTC = cvtT.compile(cv::descr_of(in_mat1), cv::descr_of(in_mat2));
cvtTC(in_mat1, in_mat2, out_mat_typed2);
//! [Typed_Example]
}
static void bind_serialization_example()
{
// ! [bind after deserialization]
cv::GCompiled compd;
std::vector<char> bytes;
auto graph = cv::gapi::deserialize<cv::GComputation>(bytes);
auto meta = cv::gapi::deserialize<cv::GMetaArgs>(bytes);
compd = graph.compile(std::move(meta), cv::compile_args());
auto in_args = cv::gapi::deserialize<cv::GRunArgs>(bytes);
auto out_args = cv::gapi::deserialize<cv::GRunArgs>(bytes);
compd(std::move(in_args), cv::gapi::bind(out_args));
// ! [bind after deserialization]
}
static void bind_deserialization_example()
{
// ! [bind before serialization]
std::vector<cv::GRunArgP> graph_outs;
cv::GRunArgs out_args;
for (auto &&out : graph_outs) {
out_args.emplace_back(cv::gapi::bind(out));
}
const auto sargsout = cv::gapi::serialize(out_args);
// ! [bind before serialization]
}
struct SimpleCustomType {
bool val;
bool operator==(const SimpleCustomType& other) const {
return val == other.val;
}
};
struct SimpleCustomType2 {
int val;
std::string name;
std::vector<float> vec;
std::map<int, uint64_t> mmap;
bool operator==(const SimpleCustomType2& other) const {
return val == other.val && name == other.name &&
vec == other.vec && mmap == other.mmap;
}
};
// ! [S11N usage]
namespace cv {
namespace gapi {
namespace s11n {
namespace detail {
template<> struct S11N<SimpleCustomType> {
static void serialize(IOStream &os, const SimpleCustomType &p) {
os << p.val;
}
static SimpleCustomType deserialize(IIStream &is) {
SimpleCustomType p;
is >> p.val;
return p;
}
};
template<> struct S11N<SimpleCustomType2> {
static void serialize(IOStream &os, const SimpleCustomType2 &p) {
os << p.val << p.name << p.vec << p.mmap;
}
static SimpleCustomType2 deserialize(IIStream &is) {
SimpleCustomType2 p;
is >> p.val >> p.name >> p.vec >> p.mmap;
return p;
}
};
} // namespace detail
} // namespace s11n
} // namespace gapi
} // namespace cv
// ! [S11N usage]
namespace cv {
namespace detail {
template<> struct CompileArgTag<SimpleCustomType> {
static const char* tag() {
return "org.opencv.test.simple_custom_type";
}
};
template<> struct CompileArgTag<SimpleCustomType2> {
static const char* tag() {
return "org.opencv.test.simple_custom_type_2";
}
};
} // namespace detail
} // namespace cv
static void s11n_example()
{
SimpleCustomType customVar1 { false };
SimpleCustomType2 customVar2 { 1248, "World", {1280, 720, 640, 480},
{ {5, 32434142342}, {7, 34242432} } };
std::vector<char> sArgs = cv::gapi::serialize(
cv::compile_args(customVar1, customVar2));
cv::GCompileArgs dArgs = cv::gapi::deserialize<cv::GCompileArgs,
SimpleCustomType,
SimpleCustomType2>(sArgs);
SimpleCustomType dCustomVar1 = cv::gapi::getCompileArg<SimpleCustomType>(dArgs).value();
SimpleCustomType2 dCustomVar2 = cv::gapi::getCompileArg<SimpleCustomType2>(dArgs).value();
(void) dCustomVar1;
(void) dCustomVar2;
}
G_TYPED_KERNEL(IAdd, <cv::GMat(cv::GMat)>, "test.custom.add") {
static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
};
G_TYPED_KERNEL(IFilter2D, <cv::GMat(cv::GMat)>, "test.custom.filter2d") {
static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
};
G_TYPED_KERNEL(IRGB2YUV, <cv::GMat(cv::GMat)>, "test.custom.add") {
static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
};
GAPI_OCV_KERNEL(CustomAdd, IAdd) { static void run(cv::Mat, cv::Mat &) {} };
GAPI_OCV_KERNEL(CustomFilter2D, IFilter2D) { static void run(cv::Mat, cv::Mat &) {} };
GAPI_OCV_KERNEL(CustomRGB2YUV, IRGB2YUV) { static void run(cv::Mat, cv::Mat &) {} };
int main(int argc, char *argv[])
{
if (argc < 3)
return -1;
cv::Mat input = cv::imread(argv[1]);
cv::Mat output;
{
//! [graph_def]
cv::GMat in;
cv::GMat gx = cv::gapi::Sobel(in, CV_32F, 1, 0);
cv::GMat gy = cv::gapi::Sobel(in, CV_32F, 0, 1);
cv::GMat g = cv::gapi::sqrt(cv::gapi::mul(gx, gx) + cv::gapi::mul(gy, gy));
cv::GMat out = cv::gapi::convertTo(g, CV_8U);
//! [graph_def]
//! [graph_decl_apply]
//! [graph_cap_full]
cv::GComputation sobelEdge(cv::GIn(in), cv::GOut(out));
//! [graph_cap_full]
sobelEdge.apply(input, output);
//! [graph_decl_apply]
//! [apply_with_param]
cv::gapi::GKernelPackage kernels = cv::gapi::combine
(cv::gapi::core::fluid::kernels(),
cv::gapi::imgproc::fluid::kernels());
sobelEdge.apply(input, output, cv::compile_args(kernels));
//! [apply_with_param]
//! [graph_cap_sub]
cv::GComputation sobelEdgeSub(cv::GIn(gx, gy), cv::GOut(out));
//! [graph_cap_sub]
}
//! [graph_gen]
cv::GComputation sobelEdgeGen([](){
cv::GMat in;
cv::GMat gx = cv::gapi::Sobel(in, CV_32F, 1, 0);
cv::GMat gy = cv::gapi::Sobel(in, CV_32F, 0, 1);
cv::GMat g = cv::gapi::sqrt(cv::gapi::mul(gx, gx) + cv::gapi::mul(gy, gy));
cv::GMat out = cv::gapi::convertTo(g, CV_8U);
return cv::GComputation(in, out);
});
//! [graph_gen]
cv::imwrite(argv[2], output);
//! [kernels_snippet]
cv::gapi::GKernelPackage pkg = cv::gapi::kernels
< CustomAdd
, CustomFilter2D
, CustomRGB2YUV
>();
//! [kernels_snippet]
// Just call typed example with no input/output - avoid warnings about
// unused functions
typed_example();
gscalar_example();
bind_serialization_example();
bind_deserialization_example();
s11n_example();
return 0;
}
-68
View File
@@ -1,68 +0,0 @@
#include <opencv2/gapi.hpp>
#include <opencv2/gapi/core.hpp>
#include <opencv2/gapi/cpu/core.hpp>
int main(int argc, char *argv[])
{
(void) argc;
(void) argv;
bool need_first_conversion = true;
bool need_second_conversion = false;
cv::Size szOut(4, 4);
cv::GComputation cc([&](){
// ! [GIOProtoArgs usage]
auto ins = cv::GIn();
cv::GMat in1;
if (need_first_conversion)
ins += cv::GIn(in1);
cv::GMat in2;
if (need_second_conversion)
ins += cv::GIn(in2);
auto outs = cv::GOut();
cv::GMat out1 = cv::gapi::resize(in1, szOut);
if (need_first_conversion)
outs += cv::GOut(out1);
cv::GMat out2 = cv::gapi::resize(in2, szOut);
if (need_second_conversion)
outs += cv::GOut(out2);
// ! [GIOProtoArgs usage]
return cv::GComputation(std::move(ins), std::move(outs));
});
// ! [GRunArgs usage]
auto in_vector = cv::gin();
cv::Mat in_mat1( 8, 8, CV_8UC3);
cv::Mat in_mat2(16, 16, CV_8UC3);
cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255));
cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255));
if (need_first_conversion)
in_vector += cv::gin(in_mat1);
if (need_second_conversion)
in_vector += cv::gin(in_mat2);
// ! [GRunArgs usage]
// ! [GRunArgsP usage]
auto out_vector = cv::gout();
cv::Mat out_mat1, out_mat2;
if (need_first_conversion)
out_vector += cv::gout(out_mat1);
if (need_second_conversion)
out_vector += cv::gout(out_mat2);
// ! [GRunArgsP usage]
auto stream = cc.compileStreaming(cv::compile_args(cv::gapi::core::cpu::kernels()));
stream.setSource(std::move(in_vector));
stream.start();
stream.pull(std::move(out_vector));
stream.stop();
return 0;
}
+2 -83
View File
@@ -9,6 +9,7 @@
#include <opencv2/gapi/streaming/cap.hpp>
#include <opencv2/gapi/cpu/gcpukernel.hpp>
#include <opencv2/highgui.hpp> // CommandLineParser
#include <opencv2/gapi/infer/parsers.hpp>
const std::string about =
"This is an OpenCV-based version of Gaze Estimation example";
@@ -58,16 +59,6 @@ G_API_OP(Size, <GSize(cv::GMat)>, "custom.gapi.size") {
}
};
G_API_OP(ParseSSD,
<GRects(cv::GMat, GSize, bool)>,
"custom.gaze_estimation.parseSSD") {
static cv::GArrayDesc outMeta( const cv::GMatDesc &
, const cv::GOpaqueDesc &
, bool) {
return cv::empty_array_desc();
}
};
// Left/Right eye per every face
G_API_OP(ParseEyes,
<std::tuple<GRects, GRects>(GMats, GRects, GSize)>,
@@ -91,27 +82,6 @@ G_API_OP(ProcessPoses,
}
};
void adjustBoundingBox(cv::Rect& boundingBox) {
auto w = boundingBox.width;
auto h = boundingBox.height;
boundingBox.x -= static_cast<int>(0.067 * w);
boundingBox.y -= static_cast<int>(0.028 * h);
boundingBox.width += static_cast<int>(0.15 * w);
boundingBox.height += static_cast<int>(0.13 * h);
if (boundingBox.width < boundingBox.height) {
auto dx = (boundingBox.height - boundingBox.width);
boundingBox.x -= dx / 2;
boundingBox.width += dx;
} else {
auto dy = (boundingBox.width - boundingBox.height);
boundingBox.y -= dy / 2;
boundingBox.height += dy;
}
}
void gazeVectorToGazeAngles(const cv::Point3f& gazeVector,
cv::Point2f& gazeAngles) {
auto r = cv::norm(gazeVector);
@@ -130,55 +100,6 @@ GAPI_OCV_KERNEL(OCVSize, Size) {
}
};
GAPI_OCV_KERNEL(OCVParseSSD, ParseSSD) {
static void run(const cv::Mat &in_ssd_result,
const cv::Size &upscale,
const bool filter_out_of_bounds,
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::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];
(void) label;
if (image_id < 0.f) {
break; // marks end-of-detections
}
if (confidence < 0.5f) {
continue; // skip objects with low confidence
}
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;
adjustBoundingBox(rc); // TODO: new option?
const auto clipped_rc = rc & surface; // TODO: new option?
if (filter_out_of_bounds) {
if (clipped_rc.area() != rc.area()) {
continue;
}
}
out_objects.emplace_back(clipped_rc);
}
}
};
cv::Rect eyeBox(const cv::Rect &face_rc,
float p1_x, float p1_y, float p2_x, float p2_y,
float scale = 1.8f) {
@@ -335,11 +256,10 @@ int main(int argc, char *argv[])
cmd.printMessage();
return 0;
}
cv::GMat in;
cv::GMat faces = cv::gapi::infer<custom::Faces>(in);
cv::GOpaque<cv::Size> sz = cv::gapi::streaming::size(in);
cv::GArray<cv::Rect> faces_rc = custom::ParseSSD::on(faces, sz, true);
cv::GArray<cv::Rect> faces_rc = cv::gapi::parseSSD(faces, sz, 0.5f, true, true);
cv::GArray<cv::GMat> angles_y, angles_p, angles_r;
std::tie(angles_y, angles_p, angles_r) = cv::gapi::infer<custom::HeadPose>(faces_rc, in);
cv::GArray<cv::GMat> heads_pos = custom::ProcessPoses::on(angles_y, angles_p, angles_r);
@@ -386,7 +306,6 @@ int main(int argc, char *argv[])
}.cfgInputLayers({"left_eye_image", "right_eye_image", "head_pose_angles"});
auto kernels = cv::gapi::kernels< custom::OCVSize
, custom::OCVParseSSD
, custom::OCVParseEyes
, custom::OCVProcessPoses>();
auto networks = cv::gapi::networks(face_net, head_net, landmarks_net, gaze_net);
@@ -156,7 +156,6 @@ int main(int argc, char *argv[])
auto in_src = cv::gapi::wip::make_src<cv::gapi::wip::GCaptureSource>(input);
pipeline.setSource(cv::gin(in_src));
pipeline.start();
cv::util::optional<cv::Mat> out_frame;
cv::util::optional<std::vector<cv::Rect>> out_faces;
@@ -167,8 +166,13 @@ int main(int argc, char *argv[])
std::vector<cv::Mat> last_emotions;
cv::VideoWriter writer;
cv::TickMeter tm;
std::size_t frames = 0u;
tm.start();
pipeline.start();
while (pipeline.pull(cv::gout(out_frame, out_faces, out_emotions))) {
++frames;
if (out_faces && out_emotions) {
last_faces = *out_faces;
last_emotions = *out_emotions;
@@ -191,5 +195,7 @@ int main(int argc, char *argv[])
cv::waitKey(1);
}
}
tm.stop();
std::cout << "Processed " << frames << " frames" << " (" << frames / tm.getTimeSec() << " FPS)" << std::endl;
return 0;
}
+12 -74
View File
@@ -13,6 +13,7 @@
#include <opencv2/gapi/cpu/gcpukernel.hpp>
#include <opencv2/gapi/streaming/cap.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/gapi/infer/parsers.hpp>
const std::string keys =
"{ h help | | Print this help message }"
@@ -69,36 +70,18 @@ using GRect = cv::GOpaque<cv::Rect>;
using GSize = cv::GOpaque<cv::Size>;
using GPrims = cv::GArray<cv::gapi::wip::draw::Prim>;
G_API_OP(GetSize, <GSize(cv::GMat)>, "sample.custom.get-size") {
static cv::GOpaqueDesc outMeta(const cv::GMatDesc &) {
return cv::empty_gopaque_desc();
}
};
G_API_OP(LocateROI, <GRect(cv::GMat)>, "sample.custom.locate-roi") {
static cv::GOpaqueDesc outMeta(const cv::GMatDesc &) {
return cv::empty_gopaque_desc();
}
};
G_API_OP(ParseSSD, <GDetections(cv::GMat, GRect, GSize)>, "sample.custom.parse-ssd") {
static cv::GArrayDesc outMeta(const cv::GMatDesc &, const cv::GOpaqueDesc &, const cv::GOpaqueDesc &) {
return cv::empty_array_desc();
}
};
G_API_OP(BBoxes, <GPrims(GDetections, GRect)>, "sample.custom.b-boxes") {
static cv::GArrayDesc outMeta(const cv::GArrayDesc &, const cv::GOpaqueDesc &) {
return cv::empty_array_desc();
}
};
GAPI_OCV_KERNEL(OCVGetSize, GetSize) {
static void run(const cv::Mat &in, cv::Size &out) {
out = {in.cols, in.rows};
}
};
GAPI_OCV_KERNEL(OCVLocateROI, LocateROI) {
// This is the place where we can run extra analytics
// on the input image frame and select the ROI (region
@@ -124,55 +107,6 @@ GAPI_OCV_KERNEL(OCVLocateROI, LocateROI) {
}
};
GAPI_OCV_KERNEL(OCVParseSSD, ParseSSD) {
static void run(const cv::Mat &in_ssd_result,
const cv::Rect &in_roi,
const cv::Size &in_parent_size,
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 up_roi = in_roi.size();
const cv::Rect surface({0,0}, in_parent_size);
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];
(void) label; // unused
if (image_id < 0.f) {
break; // marks end-of-detections
}
if (confidence < 0.5f) {
continue; // skip objects with low confidence
}
// map relative coordinates to the original image scale
// taking the ROI into account
cv::Rect rc;
rc.x = static_cast<int>(rc_left * up_roi.width);
rc.y = static_cast<int>(rc_top * up_roi.height);
rc.width = static_cast<int>(rc_right * up_roi.width) - rc.x;
rc.height = static_cast<int>(rc_bottom * up_roi.height) - rc.y;
rc.x += in_roi.x;
rc.y += in_roi.y;
out_objects.emplace_back(rc & surface);
}
}
};
GAPI_OCV_KERNEL(OCVBBoxes, BBoxes) {
// This kernel converts the rectangles into G-API's
// rendering primitives
@@ -211,9 +145,7 @@ int main(int argc, char *argv[])
cmd.get<std::string>("faced"), // device specifier
};
auto kernels = cv::gapi::kernels
< custom::OCVGetSize
, custom::OCVLocateROI
, custom::OCVParseSSD
<custom::OCVLocateROI
, custom::OCVBBoxes>();
auto networks = cv::gapi::networks(face_net);
@@ -222,16 +154,17 @@ int main(int argc, char *argv[])
cv::GStreamingCompiled pipeline;
auto inputs = cv::gin(cv::gapi::wip::make_src<cv::gapi::wip::GCaptureSource>(input));
cv::GMat in;
cv::GOpaque<cv::Size> sz = cv::gapi::streaming::size(in);
if (opt_roi.has_value()) {
// Use the value provided by user
std::cout << "Will run inference for static region "
<< opt_roi.value()
<< " only"
<< std::endl;
cv::GMat in;
cv::GOpaque<cv::Rect> in_roi;
auto blob = cv::gapi::infer<custom::FaceDetector>(in_roi, in);
auto rcs = custom::ParseSSD::on(blob, in_roi, custom::GetSize::on(in));
cv::GArray<cv::Rect> rcs = cv::gapi::parseSSD(blob, sz, 0.5f, true, true);
auto out = cv::gapi::wip::draw::render3ch(in, custom::BBoxes::on(rcs, in_roi));
pipeline = cv::GComputation(cv::GIn(in, in_roi), cv::GOut(out))
.compileStreaming(cv::compile_args(kernels, networks));
@@ -242,10 +175,9 @@ int main(int argc, char *argv[])
// Automatically detect ROI to infer. Make it output parameter
std::cout << "ROI is not set or invalid. Locating it automatically"
<< std::endl;
cv::GMat in;
cv::GOpaque<cv::Rect> roi = custom::LocateROI::on(in);
auto blob = cv::gapi::infer<custom::FaceDetector>(roi, in);
auto rcs = custom::ParseSSD::on(blob, roi, custom::GetSize::on(in));
cv::GArray<cv::Rect> rcs = cv::gapi::parseSSD(blob, sz, 0.5f, true, true);
auto out = cv::gapi::wip::draw::render3ch(in, custom::BBoxes::on(rcs, roi));
pipeline = cv::GComputation(cv::GIn(in), cv::GOut(out))
.compileStreaming(cv::compile_args(kernels, networks));
@@ -256,9 +188,15 @@ int main(int argc, char *argv[])
pipeline.start();
cv::Mat out;
size_t frames = 0u;
cv::TickMeter tm;
tm.start();
while (pipeline.pull(cv::gout(out))) {
cv::imshow("Out", out);
cv::waitKey(1);
++frames;
}
tm.stop();
std::cout << "Processed " << frames << " frames" << " (" << frames / tm.getTimeSec() << " FPS)" << std::endl;
return 0;
}
+12 -66
View File
@@ -14,6 +14,7 @@
#include <opencv2/gapi/cpu/gcpukernel.hpp>
#include <opencv2/gapi/streaming/cap.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/gapi/infer/parsers.hpp>
namespace custom {
@@ -23,71 +24,12 @@ using GDetections = cv::GArray<cv::Rect>;
using GSize = cv::GOpaque<cv::Size>;
using GPrims = cv::GArray<cv::gapi::wip::draw::Prim>;
G_API_OP(GetSize, <GSize(cv::GMat)>, "sample.custom.get-size") {
static cv::GOpaqueDesc outMeta(const cv::GMatDesc &) {
return cv::empty_gopaque_desc();
}
};
G_API_OP(ParseSSD, <GDetections(cv::GMat, GSize)>, "sample.custom.parse-ssd") {
static cv::GArrayDesc outMeta(const cv::GMatDesc &, const cv::GOpaqueDesc &) {
return cv::empty_array_desc();
}
};
G_API_OP(BBoxes, <GPrims(GDetections)>, "sample.custom.b-boxes") {
static cv::GArrayDesc outMeta(const cv::GArrayDesc &) {
return cv::empty_array_desc();
}
};
GAPI_OCV_KERNEL(OCVGetSize, GetSize) {
static void run(const cv::Mat &in, cv::Size &out) {
out = {in.cols, in.rows};
}
};
GAPI_OCV_KERNEL(OCVParseSSD, ParseSSD) {
static void run(const cv::Mat &in_ssd_result,
const cv::Size &in_parent_size,
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::Rect surface({0,0}, in_parent_size);
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];
(void) label; // unused
if (image_id < 0.f) {
break; // marks end-of-detections
}
if (confidence < 0.5f) {
continue; // skip objects with low confidence
}
// map relative coordinates to the original image scale
cv::Rect rc;
rc.x = static_cast<int>(rc_left * in_parent_size.width);
rc.y = static_cast<int>(rc_top * in_parent_size.height);
rc.width = static_cast<int>(rc_right * in_parent_size.width) - rc.x;
rc.height = static_cast<int>(rc_bottom * in_parent_size.height) - rc.y;
out_objects.emplace_back(rc & surface);
}
}
};
GAPI_OCV_KERNEL(OCVBBoxes, BBoxes) {
// This kernel converts the rectangles into G-API's
// rendering primitives
@@ -151,7 +93,6 @@ void remap_ssd_ports(const std::unordered_map<std::string, cv::Mat> &onnx,
}
} // anonymous namespace
const std::string keys =
"{ h help | | Print this help message }"
"{ input | | Path to the input video file }"
@@ -175,15 +116,14 @@ int main(int argc, char *argv[])
auto obj_net = cv::gapi::onnx::Params<custom::ObjDetector>{obj_model_path}
.cfgOutputLayers({"detection_output"})
.cfgPostProc({cv::GMatDesc{CV_32F, {1,1,200,7}}}, remap_ssd_ports);
auto kernels = cv::gapi::kernels< custom::OCVGetSize
, custom::OCVParseSSD
, custom::OCVBBoxes>();
auto kernels = cv::gapi::kernels<custom::OCVBBoxes>();
auto networks = cv::gapi::networks(obj_net);
// Now build the graph
cv::GMat in;
auto blob = cv::gapi::infer<custom::ObjDetector>(in);
auto rcs = custom::ParseSSD::on(blob, custom::GetSize::on(in));
cv::GArray<cv::Rect> rcs =
cv::gapi::parseSSD(blob, cv::gapi::streaming::size(in), 0.5f, true, true);
auto out = cv::gapi::wip::draw::render3ch(in, custom::BBoxes::on(rcs));
cv::GStreamingCompiled pipeline = cv::GComputation(cv::GIn(in), cv::GOut(out))
.compileStreaming(cv::compile_args(kernels, networks));
@@ -192,12 +132,16 @@ int main(int argc, char *argv[])
// The execution part
pipeline.setSource(std::move(inputs));
pipeline.start();
cv::TickMeter tm;
cv::VideoWriter writer;
size_t frames = 0u;
cv::Mat outMat;
tm.start();
pipeline.start();
while (pipeline.pull(cv::gout(outMat))) {
++frames;
cv::imshow("Out", outMat);
cv::waitKey(1);
if (!output.empty()) {
@@ -209,5 +153,7 @@ int main(int argc, char *argv[])
writer << outMat;
}
}
tm.stop();
std::cout << "Processed " << frames << " frames" << " (" << frames / tm.getTimeSec() << " FPS)" << std::endl;
return 0;
}
@@ -1,157 +0,0 @@
// [filter2d_api]
#include <opencv2/gapi.hpp>
G_TYPED_KERNEL(GFilter2D,
<cv::GMat(cv::GMat,int,cv::Mat,cv::Point,double,int,cv::Scalar)>,
"org.opencv.imgproc.filters.filter2D")
{
static cv::GMatDesc // outMeta's return value type
outMeta(cv::GMatDesc in , // descriptor of input GMat
int ddepth , // depth parameter
cv::Mat /* coeffs */, // (unused)
cv::Point /* anchor */, // (unused)
double /* scale */, // (unused)
int /* border */, // (unused)
cv::Scalar /* bvalue */ ) // (unused)
{
return in.withDepth(ddepth);
}
};
// [filter2d_api]
cv::GMat filter2D(cv::GMat ,
int ,
cv::Mat ,
cv::Point ,
double ,
int ,
cv::Scalar);
// [filter2d_wrap]
cv::GMat filter2D(cv::GMat in,
int ddepth,
cv::Mat k,
cv::Point anchor = cv::Point(-1,-1),
double scale = 0.,
int border = cv::BORDER_DEFAULT,
cv::Scalar bval = cv::Scalar(0))
{
return GFilter2D::on(in, ddepth, k, anchor, scale, border, bval);
}
// [filter2d_wrap]
// [compound]
#include <opencv2/gapi/gcompoundkernel.hpp> // GAPI_COMPOUND_KERNEL()
using PointArray2f = cv::GArray<cv::Point2f>;
G_TYPED_KERNEL(HarrisCorners,
<PointArray2f(cv::GMat,int,double,double,int,double)>,
"org.opencv.imgproc.harris_corner")
{
static cv::GArrayDesc outMeta(const cv::GMatDesc &,
int,
double,
double,
int,
double)
{
// No special metadata for arrays in G-API (yet)
return cv::empty_array_desc();
}
};
// Define Fluid-backend-local kernels which form GoodFeatures
G_TYPED_KERNEL(HarrisResponse,
<cv::GMat(cv::GMat,double,int,double)>,
"org.opencv.fluid.harris_response")
{
static cv::GMatDesc outMeta(const cv::GMatDesc &in,
double,
int,
double)
{
return in.withType(CV_32F, 1);
}
};
G_TYPED_KERNEL(ArrayNMS,
<PointArray2f(cv::GMat,int,double)>,
"org.opencv.cpu.nms_array")
{
static cv::GArrayDesc outMeta(const cv::GMatDesc &,
int,
double)
{
return cv::empty_array_desc();
}
};
GAPI_COMPOUND_KERNEL(GFluidHarrisCorners, HarrisCorners)
{
static PointArray2f
expand(cv::GMat in,
int maxCorners,
double quality,
double minDist,
int blockSize,
double k)
{
cv::GMat response = HarrisResponse::on(in, quality, blockSize, k);
return ArrayNMS::on(response, maxCorners, minDist);
}
};
// Then implement HarrisResponse as Fluid kernel and NMSresponse
// as a generic (OpenCV) kernel
// [compound]
// [filter2d_ocv]
#include <opencv2/gapi/cpu/gcpukernel.hpp> // GAPI_OCV_KERNEL()
#include <opencv2/imgproc.hpp> // cv::filter2D()
GAPI_OCV_KERNEL(GCPUFilter2D, GFilter2D)
{
static void
run(const cv::Mat &in, // in - derived from GMat
const int ddepth, // opaque (passed as-is)
const cv::Mat &k, // opaque (passed as-is)
const cv::Point &anchor, // opaque (passed as-is)
const double delta, // opaque (passed as-is)
const int border, // opaque (passed as-is)
const cv::Scalar &, // opaque (passed as-is)
cv::Mat &out) // out - derived from GMat (retval)
{
cv::filter2D(in, out, ddepth, k, anchor, delta, border);
}
};
// [filter2d_ocv]
int main(int, char *[])
{
std::cout << "This sample is non-complete. It is used as code snippents in documentation." << std::endl;
cv::Mat conv_kernel_mat;
{
// [filter2d_on]
cv::GMat in;
cv::GMat out = GFilter2D::on(/* GMat */ in,
/* int */ -1,
/* Mat */ conv_kernel_mat,
/* Point */ cv::Point(-1,-1),
/* double */ 0.,
/* int */ cv::BORDER_DEFAULT,
/* Scalar */ cv::Scalar(0));
// [filter2d_on]
}
{
// [filter2d_wrap_call]
cv::GMat in;
cv::GMat out = filter2D(in, -1, conv_kernel_mat);
// [filter2d_wrap_call]
}
return 0;
}
+183 -74
View File
@@ -2,6 +2,7 @@
#include <fstream>
#include <iostream>
#include <cctype>
#include <tuple>
#include <opencv2/imgproc.hpp>
#include <opencv2/gapi.hpp>
@@ -10,16 +11,41 @@
#include <opencv2/gapi/infer/ie.hpp>
#include <opencv2/gapi/render.hpp>
#include <opencv2/gapi/streaming/onevpl/source.hpp>
#include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
#include <opencv2/highgui.hpp> // CommandLineParser
#include <opencv2/gapi/infer/parsers.hpp>
#ifdef HAVE_INF_ENGINE
#include <inference_engine.hpp> // ParamMap
#ifdef HAVE_DIRECTX
#ifdef HAVE_D3D11
#pragma comment(lib,"d3d11.lib")
// get rid of generate macro max/min/etc from DX side
#define D3D11_NO_HELPERS
#define NOMINMAX
#include <cldnn/cldnn_config.hpp>
#include <d3d11.h>
#pragma comment(lib, "dxgi")
#undef NOMINMAX
#undef D3D11_NO_HELPERS
#endif // HAVE_D3D11
#endif // HAVE_DIRECTX
#endif // HAVE_INF_ENGINE
const std::string about =
"This is an OpenCV-based version of oneVPLSource decoder example";
const std::string keys =
"{ h help | | Print this help message }"
"{ input | | Path to the input demultiplexed video file }"
"{ output | | Path to the output RAW video file. Use .avi extension }"
"{ facem | face-detection-adas-0001.xml | Path to OpenVINO IE face detection model (.xml) }"
"{ cfg_params | <prop name>:<value>;<prop name>:<value> | Semicolon separated list of oneVPL mfxVariants which is used for configuring source (see `MFXSetConfigFilterProperty` by https://spec.oneapi.io/versions/latest/elements/oneVPL/source/index.html) }";
"{ h help | | Print this help message }"
"{ input | | Path to the input demultiplexed video file }"
"{ output | | Path to the output RAW video file. Use .avi extension }"
"{ facem | face-detection-adas-0001.xml | Path to OpenVINO IE face detection model (.xml) }"
"{ faced | AUTO | Target device for face detection model (e.g. AUTO, GPU, VPU, ...) }"
"{ cfg_params | <prop name>:<value>;<prop name>:<value> | Semicolon separated list of oneVPL mfxVariants which is used for configuring source (see `MFXSetConfigFilterProperty` by https://spec.oneapi.io/versions/latest/elements/oneVPL/source/index.html) }"
"{ streaming_queue_capacity | 1 | Streaming executor queue capacity. Calculated automaticaly if 0 }"
"{ frames_pool_size | 0 | OneVPL source applies this parameter as preallocated frames pool size}";
namespace {
@@ -35,6 +61,58 @@ std::string get_weights_path(const std::string &model_path) {
CV_Assert(ext == ".xml");
return model_path.substr(0u, sz - EXT_LEN) + ".bin";
}
#ifdef HAVE_INF_ENGINE
#ifdef HAVE_DIRECTX
#ifdef HAVE_D3D11
// Since ATL headers might not be available on specific MSVS Build Tools
// we use simple `CComPtr` implementation like as `ComPtrGuard`
// which is not supposed to be the full functional replacement of `CComPtr`
// and it uses as RAII to make sure utilization is correct
template <typename COMNonManageableType>
void release(COMNonManageableType *ptr) {
if (ptr) {
ptr->Release();
}
}
template <typename COMNonManageableType>
using ComPtrGuard = std::unique_ptr<COMNonManageableType, decltype(&release<COMNonManageableType>)>;
template <typename COMNonManageableType>
ComPtrGuard<COMNonManageableType> createCOMPtrGuard(COMNonManageableType *ptr = nullptr) {
return ComPtrGuard<COMNonManageableType> {ptr, &release<COMNonManageableType>};
}
using AccelParamsType = std::tuple<ComPtrGuard<ID3D11Device>, ComPtrGuard<ID3D11DeviceContext>>;
AccelParamsType create_device_with_ctx(IDXGIAdapter* adapter) {
UINT flags = 0;
D3D_FEATURE_LEVEL feature_levels[] = { D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
};
D3D_FEATURE_LEVEL featureLevel;
ID3D11Device* ret_device_ptr = nullptr;
ID3D11DeviceContext* ret_ctx_ptr = nullptr;
HRESULT err = D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN,
nullptr, flags,
feature_levels,
ARRAYSIZE(feature_levels),
D3D11_SDK_VERSION, &ret_device_ptr,
&featureLevel, &ret_ctx_ptr);
if (FAILED(err)) {
throw std::runtime_error("Cannot create D3D11CreateDevice, error: " +
std::to_string(HRESULT_CODE(err)));
}
return std::make_tuple(createCOMPtrGuard(ret_device_ptr),
createCOMPtrGuard(ret_ctx_ptr));
}
#endif // HAVE_D3D11
#endif // HAVE_DIRECTX
#endif // HAVE_INF_ENGINE
} // anonymous namespace
namespace custom {
@@ -51,12 +129,6 @@ G_API_OP(LocateROI, <GRect(GSize)>, "sample.custom.locate-roi") {
}
};
G_API_OP(ParseSSD, <GDetections(cv::GMat, GRect, GSize)>, "sample.custom.parse-ssd") {
static cv::GArrayDesc outMeta(const cv::GMatDesc &, const cv::GOpaqueDesc &, const cv::GOpaqueDesc &) {
return cv::empty_array_desc();
}
};
G_API_OP(BBoxes, <GPrims(GDetections, GRect)>, "sample.custom.b-boxes") {
static cv::GArrayDesc outMeta(const cv::GArrayDesc &, const cv::GOpaqueDesc &) {
return cv::empty_array_desc();
@@ -88,55 +160,6 @@ GAPI_OCV_KERNEL(OCVLocateROI, LocateROI) {
}
};
GAPI_OCV_KERNEL(OCVParseSSD, ParseSSD) {
static void run(const cv::Mat &in_ssd_result,
const cv::Rect &in_roi,
const cv::Size &in_parent_size,
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 up_roi = in_roi.size();
const cv::Rect surface({0,0}, in_parent_size);
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];
(void) label; // unused
if (image_id < 0.f) {
break; // marks end-of-detections
}
if (confidence < 0.5f) {
continue; // skip objects with low confidence
}
// map relative coordinates to the original image scale
// taking the ROI into account
cv::Rect rc;
rc.x = static_cast<int>(rc_left * up_roi.width);
rc.y = static_cast<int>(rc_top * up_roi.height);
rc.width = static_cast<int>(rc_right * up_roi.width) - rc.x;
rc.height = static_cast<int>(rc_bottom * up_roi.height) - rc.y;
rc.x += in_roi.x;
rc.y += in_roi.y;
out_objects.emplace_back(rc & surface);
}
}
};
GAPI_OCV_KERNEL(OCVBBoxes, BBoxes) {
// This kernel converts the rectangles into G-API's
// rendering primitives
@@ -173,6 +196,8 @@ int main(int argc, char *argv[]) {
std::string file_path = cmd.get<std::string>("input");
const std::string output = cmd.get<std::string>("output");
const auto face_model_path = cmd.get<std::string>("facem");
const auto streaming_queue_capacity = cmd.get<uint32_t>("streaming_queue_capacity");
const auto source_queue_capacity = cmd.get<uint32_t>("frames_pool_size");
// check ouput file extension
if (!output.empty()) {
@@ -196,20 +221,107 @@ int main(int argc, char *argv[]) {
return -1;
}
if (source_queue_capacity != 0) {
source_cfgs.push_back(cv::gapi::wip::onevpl::CfgParam::create_frames_pool_size(source_queue_capacity));
}
const std::string& device_id = cmd.get<std::string>("faced");
auto face_net = cv::gapi::ie::Params<custom::FaceDetector> {
face_model_path, // path to topology IR
get_weights_path(face_model_path) // path to weights
get_weights_path(face_model_path), // path to weights
device_id
};
// Create device_ptr & context_ptr using graphic API
// InferenceEngine requires such device & context to create its own
// remote shared context through InferenceEngine::ParamMap in
// GAPI InferenceEngine backend to provide interoperability with onevpl::GSource
// So GAPI InferenceEngine backend and onevpl::GSource MUST share the same
// device and context
void* accel_device_ptr = nullptr;
void* accel_ctx_ptr = nullptr;
#ifdef HAVE_INF_ENGINE
#ifdef HAVE_DIRECTX
#ifdef HAVE_D3D11
auto dx11_dev = createCOMPtrGuard<ID3D11Device>();
auto dx11_ctx = createCOMPtrGuard<ID3D11DeviceContext>();
if (device_id.find("GPU") != std::string::npos) {
auto adapter_factory = createCOMPtrGuard<IDXGIFactory>();
{
IDXGIFactory* out_factory = nullptr;
HRESULT err = CreateDXGIFactory(__uuidof(IDXGIFactory),
reinterpret_cast<void**>(&out_factory));
if (FAILED(err)) {
std::cerr << "Cannot create CreateDXGIFactory, error: " << HRESULT_CODE(err) << std::endl;
return -1;
}
adapter_factory = createCOMPtrGuard(out_factory);
}
auto intel_adapter = createCOMPtrGuard<IDXGIAdapter>();
UINT adapter_index = 0;
const unsigned int refIntelVendorID = 0x8086;
IDXGIAdapter* out_adapter = nullptr;
while (adapter_factory->EnumAdapters(adapter_index, &out_adapter) != DXGI_ERROR_NOT_FOUND) {
DXGI_ADAPTER_DESC desc{};
out_adapter->GetDesc(&desc);
if (desc.VendorId == refIntelVendorID) {
intel_adapter = createCOMPtrGuard(out_adapter);
break;
}
++adapter_index;
}
if (!intel_adapter) {
std::cerr << "No Intel GPU adapter on aboard. Exit" << std::endl;
return -1;
}
std::tie(dx11_dev, dx11_ctx) = create_device_with_ctx(intel_adapter.get());
accel_device_ptr = reinterpret_cast<void*>(dx11_dev.get());
accel_ctx_ptr = reinterpret_cast<void*>(dx11_ctx.get());
// put accel type description for VPL source
source_cfgs.push_back(cfg::create_from_string(
"mfxImplDescription.AccelerationMode"
":"
"MFX_ACCEL_MODE_VIA_D3D11"));
}
#endif // HAVE_D3D11
#endif // HAVE_DIRECTX
// set ctx_config for GPU device only - no need in case of CPU device type
if (device_id.find("GPU") != std::string::npos) {
InferenceEngine::ParamMap ctx_config({{"CONTEXT_TYPE", "VA_SHARED"},
{"VA_DEVICE", accel_device_ptr} });
face_net.cfgContextParams(ctx_config);
}
#endif // HAVE_INF_ENGINE
auto kernels = cv::gapi::kernels
< custom::OCVLocateROI
, custom::OCVParseSSD
, custom::OCVBBoxes>();
auto networks = cv::gapi::networks(face_net);
auto face_detection_args = cv::compile_args(networks, kernels);
if (streaming_queue_capacity != 0) {
face_detection_args += cv::compile_args(cv::gapi::streaming::queue_capacity{ streaming_queue_capacity });
}
// Create source
cv::Ptr<cv::gapi::wip::IStreamSource> cap;
try {
cap = cv::gapi::wip::make_onevpl_src(file_path, source_cfgs);
if (device_id.find("GPU") != std::string::npos) {
cap = cv::gapi::wip::make_onevpl_src(file_path, source_cfgs,
device_id,
accel_device_ptr,
accel_ctx_ptr);
} else {
cap = cv::gapi::wip::make_onevpl_src(file_path, source_cfgs);
}
std::cout << "oneVPL source desription: " << cap->descr_of() << std::endl;
} catch (const std::exception& ex) {
std::cerr << "Cannot create source: " << ex.what() << std::endl;
@@ -224,14 +336,14 @@ int main(int argc, char *argv[]) {
auto size = cv::gapi::streaming::size(in);
auto roi = custom::LocateROI::on(size);
auto blob = cv::gapi::infer<custom::FaceDetector>(roi, in);
auto rcs = custom::ParseSSD::on(blob, roi, size);
cv::GArray<cv::Rect> rcs = cv::gapi::parseSSD(blob, size, 0.5f, true, true);
auto out_frame = cv::gapi::wip::draw::renderFrame(in, custom::BBoxes::on(rcs, roi));
auto out = cv::gapi::streaming::BGR(out_frame);
cv::GStreamingCompiled pipeline;
try {
pipeline = cv::GComputation(cv::GIn(in), cv::GOut(out))
.compileStreaming(cv::compile_args(kernels, networks));
.compileStreaming(std::move(face_detection_args));
} catch (const std::exception& ex) {
std::cerr << "Exception occured during pipeline construction: " << ex.what() << std::endl;
return -1;
@@ -243,8 +355,8 @@ int main(int argc, char *argv[]) {
pipeline.setSource(std::move(cap));
pipeline.start();
int framesCount = 0;
cv::TickMeter t;
size_t frames = 0u;
cv::TickMeter tm;
cv::VideoWriter writer;
if (!output.empty() && !writer.isOpened()) {
const auto sz = cv::Size{frame_descr.size.width, frame_descr.size.height};
@@ -253,20 +365,17 @@ int main(int argc, char *argv[]) {
}
cv::Mat outMat;
t.start();
tm.start();
while (pipeline.pull(cv::gout(outMat))) {
cv::imshow("Out", outMat);
cv::waitKey(1);
if (!output.empty()) {
writer << outMat;
}
framesCount++;
++frames;
}
t.stop();
std::cout << "Elapsed time: " << t.getTimeSec() << std::endl;
std::cout << "FPS: " << framesCount / t.getTimeSec() << std::endl;
std::cout << "framesCount: " << framesCount << std::endl;
tm.stop();
std::cout << "Processed " << frames << " frames" << " (" << frames / tm.getTimeSec() << " FPS)" << std::endl;
return 0;
}
@@ -13,6 +13,7 @@
#include <opencv2/gapi/cpu/gcpukernel.hpp>
#include <opencv2/gapi/streaming/cap.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/gapi/infer/parsers.hpp>
const std::string about =
"This is an OpenCV-based version of Privacy Masking Camera example";
@@ -49,12 +50,6 @@ 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") {
@@ -63,53 +58,6 @@ G_API_OP(ToMosaic, <GPrims(GDetections, GDetections)>, "custom.privacy_masking.t
}
};
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,
@@ -150,10 +98,13 @@ int main(int argc, char *argv[])
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);
cv::GOpaque<cv::Size> sz = cv::gapi::streaming::size(in);
cv::GArray<cv::Rect> rc_plates, rc_faces;
cv::GArray<int> labels;
std::tie(rc_plates, labels) = cv::gapi::parseSSD(blob_plates, sz, 0.5f, 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);
std::tie(rc_faces, labels) = cv::gapi::parseSSD(blob_faces, sz, 0.5f, -1);
cv::GMat out = cv::gapi::wip::draw::render3ch(in, custom::ToMosaic::on(rc_plates, rc_faces));
cv::GComputation graph(in, out);
@@ -169,7 +120,7 @@ int main(int argc, char *argv[])
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 kernels = cv::gapi::kernels<custom::OCVToMosaic>();
auto networks = cv::gapi::networks(plate_net, face_net);
cv::TickMeter tm;
+13 -5
View File
@@ -2,6 +2,7 @@
#include <opencv2/gapi/infer/ie.hpp>
#include <opencv2/gapi/cpu/gcpukernel.hpp>
#include <opencv2/gapi/streaming/cap.hpp>
#include <opencv2/gapi/operators.hpp>
#include <opencv2/highgui.hpp>
const std::string keys =
@@ -117,10 +118,7 @@ GAPI_OCV_KERNEL(OCVPostProcessing, PostProcessing) {
cv::Mat mask_img;
classesToColors(classes, mask_img);
cv::resize(mask_img, out, in.size());
const float blending = 0.3f;
out = in * blending + out * (1 - blending);
}
};
} // namespace custom
@@ -148,7 +146,10 @@ int main(int argc, char *argv[]) {
// Now build the graph
cv::GMat in;
cv::GMat out_blob = cv::gapi::infer<SemSegmNet>(in);
cv::GMat out = custom::PostProcessing::on(in, out_blob);
cv::GMat post_proc_out = custom::PostProcessing::on(in, out_blob);
cv::GMat blending_in = in * 0.3f;
cv::GMat blending_out = post_proc_out * 0.7f;
cv::GMat out = blending_in + blending_out;
cv::GStreamingCompiled pipeline = cv::GComputation(cv::GIn(in), cv::GOut(out))
.compileStreaming(cv::compile_args(kernels, networks));
@@ -156,11 +157,16 @@ int main(int argc, char *argv[]) {
// The execution part
pipeline.setSource(std::move(inputs));
pipeline.start();
cv::VideoWriter writer;
cv::TickMeter tm;
cv::Mat outMat;
std::size_t frames = 0u;
tm.start();
pipeline.start();
while (pipeline.pull(cv::gout(outMat))) {
++frames;
cv::imshow("Out", outMat);
cv::waitKey(1);
if (!output.empty()) {
@@ -172,5 +178,7 @@ int main(int argc, char *argv[]) {
writer << outMat;
}
}
tm.stop();
std::cout << "Processed " << frames << " frames" << " (" << frames / tm.getTimeSec() << " FPS)" << std::endl;
return 0;
}
+1 -1
View File
@@ -62,7 +62,7 @@ void cv::gapi::GBackend::Priv::addMetaSensitiveBackendPasses(ade::ExecutionEngin
// which are sensitive to metadata
}
cv::gapi::GKernelPackage cv::gapi::GBackend::Priv::auxiliaryKernels() const
cv::GKernelPackage cv::gapi::GBackend::Priv::auxiliaryKernels() const
{
return {};
}
+1 -1
View File
@@ -66,7 +66,7 @@ public:
// they are called when meta information becomes available.
virtual void addMetaSensitiveBackendPasses(ade::ExecutionEngineSetupContext &);
virtual cv::gapi::GKernelPackage auxiliaryKernels() const;
virtual cv::GKernelPackage auxiliaryKernels() const;
// Ask backend if it has a custom control over island fusion process
// This method is quite redundant but there's nothing better fits
+22 -11
View File
@@ -18,7 +18,7 @@
#include "api/gbackend_priv.hpp"
// GKernelPackage public implementation ////////////////////////////////////////
void cv::gapi::GKernelPackage::remove(const cv::gapi::GBackend& backend)
void cv::GKernelPackage::remove(const cv::gapi::GBackend& backend)
{
std::vector<std::string> id_deleted_kernels;
for (const auto& p : m_id_kernels)
@@ -35,27 +35,38 @@ void cv::gapi::GKernelPackage::remove(const cv::gapi::GBackend& backend)
}
}
bool cv::gapi::GKernelPackage::includesAPI(const std::string &id) const
void cv::GKernelPackage::include(const cv::gapi::GFunctor& functor)
{
m_id_kernels[functor.id()] = std::make_pair(functor.backend(), functor.impl());
}
void cv::GKernelPackage::include(const cv::gapi::GBackend& backend, const std::string& kernel_id)
{
removeAPI(kernel_id);
m_id_kernels[kernel_id] = std::make_pair(backend, GKernelImpl{{}, {}});
}
bool cv::GKernelPackage::includesAPI(const std::string &id) const
{
return ade::util::contains(m_id_kernels, id);
}
void cv::gapi::GKernelPackage::removeAPI(const std::string &id)
void cv::GKernelPackage::removeAPI(const std::string &id)
{
m_id_kernels.erase(id);
}
std::size_t cv::gapi::GKernelPackage::size() const
std::size_t cv::GKernelPackage::size() const
{
return m_id_kernels.size();
}
const std::vector<cv::GTransform> &cv::gapi::GKernelPackage::get_transformations() const
const std::vector<cv::GTransform> &cv::GKernelPackage::get_transformations() const
{
return m_transformations;
}
std::vector<std::string> cv::gapi::GKernelPackage::get_kernel_ids() const
std::vector<std::string> cv::GKernelPackage::get_kernel_ids() const
{
std::vector<std::string> ids;
for (auto &&id : m_id_kernels)
@@ -65,13 +76,13 @@ std::vector<std::string> cv::gapi::GKernelPackage::get_kernel_ids() const
return ids;
}
cv::gapi::GKernelPackage cv::gapi::combine(const GKernelPackage &lhs,
const GKernelPackage &rhs)
cv::GKernelPackage cv::gapi::combine(const cv::GKernelPackage &lhs,
const cv::GKernelPackage &rhs)
{
// If there is a collision, prefer RHS to LHS
// since RHS package has a precedense, start with its copy
GKernelPackage result(rhs);
cv::GKernelPackage result(rhs);
// now iterate over LHS package and put kernel if and only
// if there's no such one
for (const auto& kernel : lhs.m_id_kernels)
@@ -88,7 +99,7 @@ cv::gapi::GKernelPackage cv::gapi::combine(const GKernelPackage &lhs,
}
std::pair<cv::gapi::GBackend, cv::GKernelImpl>
cv::gapi::GKernelPackage::lookup(const std::string &id) const
cv::GKernelPackage::lookup(const std::string &id) const
{
auto kernel_it = m_id_kernels.find(id);
if (kernel_it != m_id_kernels.end())
@@ -99,7 +110,7 @@ cv::gapi::GKernelPackage::lookup(const std::string &id) const
util::throw_error(std::logic_error("Kernel " + id + " was not found"));
}
std::vector<cv::gapi::GBackend> cv::gapi::GKernelPackage::backends() const
std::vector<cv::gapi::GBackend> cv::GKernelPackage::backends() const
{
using kernel_type = std::pair<std::string, std::pair<cv::gapi::GBackend, cv::GKernelImpl>>;
std::unordered_set<cv::gapi::GBackend> unique_set;
-10
View File
@@ -301,16 +301,6 @@ GMat merge4(const GMat& src1, const GMat& src2, const GMat& src3, const GMat& sr
return core::GMerge4::on(src1, src2, src3, src4);
}
GMat resize(const GMat& src, const Size& dsize, double fx, double fy, int interpolation)
{
return core::GResize::on(src, dsize, fx, fy, interpolation);
}
GMatP resizeP(const GMatP& src, const Size& dsize, int interpolation)
{
return core::GResizeP::on(src, dsize, interpolation);
}
GMat remap(const GMat& src, const Mat& map1, const Mat& map2,
int interpolation, int borderMode,
const Scalar& borderValue)
+10
View File
@@ -14,6 +14,16 @@
namespace cv { namespace gapi {
GMat resize(const GMat& src, const Size& dsize, double fx, double fy, int interpolation)
{
return imgproc::GResize::on(src, dsize, fx, fy, interpolation);
}
GMatP resizeP(const GMatP& src, const Size& dsize, int interpolation)
{
return imgproc::GResizeP::on(src, dsize, interpolation);
}
GMat sepFilter(const GMat& src, int ddepth, const Mat& kernelX, const Mat& kernelY, const Point& anchor,
const Scalar& delta, int borderType, const Scalar& borderVal)
{
+18 -6
View File
@@ -24,8 +24,17 @@ namespace gimpl {
inline cv::Mat asMat(RMat::View& v) {
#if !defined(GAPI_STANDALONE)
return v.dims().empty() ? cv::Mat(v.rows(), v.cols(), v.type(), v.ptr(), v.step())
: cv::Mat(v.dims(), v.type(), v.ptr(), v.steps().data());
if (v.dims().empty()) {
return cv::Mat(v.rows(), v.cols(), v.type(), v.ptr(), v.step());
} else {
cv::Mat m(v.dims(), v.type(), v.ptr(), v.steps().data());
if (v.dims().size() == 1) {
// FIXME: cv::Mat() constructor will set m.dims to 2;
// To obtain 1D Mat, we have to set m.dims back to 1 manually
m.dims = 1;
}
return m;
}
#else
// FIXME: add a check that steps are default
return v.dims().empty() ? cv::Mat(v.rows(), v.cols(), v.type(), v.ptr(), v.step())
@@ -41,15 +50,18 @@ namespace gimpl {
}
return RMat::View(cv::descr_of(m), m.data, steps, std::move(cb));
#else
return RMat::View(cv::descr_of(m), m.data, m.step, std::move(cb));
return m.dims.empty()
? RMat::View(cv::descr_of(m), m.data, m.step, std::move(cb))
// Own Mat doesn't support n-dimensional steps so default ones are used in this case
: RMat::View(cv::descr_of(m), m.data, RMat::View::stepsT{}, std::move(cb));
#endif
}
class RMatAdapter : public RMat::Adapter {
class RMatOnMat : public RMat::IAdapter {
cv::Mat m_mat;
public:
const void* data() const { return m_mat.data; }
RMatAdapter(cv::Mat m) : m_mat(m) {}
RMatOnMat(cv::Mat m) : m_mat(m) {}
virtual RMat::View access(RMat::Access) override { return asView(m_mat); }
virtual cv::GMatDesc desc() const override { return cv::descr_of(m_mat); }
};
@@ -58,7 +70,7 @@ namespace gimpl {
struct Data;
struct RcDesc;
struct GAPI_EXPORTS RMatMediaFrameAdapter final: public cv::RMat::Adapter
struct GAPI_EXPORTS RMatMediaFrameAdapter final: public cv::RMat::IAdapter
{
using MapDescF = std::function<cv::GMatDesc(const GFrameDesc&)>;
using MapDataF = std::function<cv::Mat(const GFrameDesc&, const cv::MediaFrame::View&)>;
@@ -113,6 +113,6 @@ struct InGraphMetaKernel final: public cv::detail::KernelTag {
} // anonymous namespace
cv::gapi::GKernelPackage cv::gimpl::meta::kernels() {
cv::GKernelPackage cv::gimpl::meta::kernels() {
return cv::gapi::kernels<InGraphMetaKernel>();
}
@@ -7,7 +7,7 @@ namespace cv {
namespace gimpl {
namespace meta {
cv::gapi::GKernelPackage kernels();
cv::GKernelPackage kernels();
} // namespace meta
} // namespace gimpl
@@ -928,7 +928,7 @@ IIStream& ByteMemoryInStream::operator>> (std::string& str) {
if (sz == 0u) {
str.clear();
} else {
str.resize(sz);
str.resize(static_cast<std::size_t>(sz));
for (auto &&i : ade::util::iota(sz)) { *this >> str[i]; }
}
return *this;
+1 -27
View File
@@ -462,30 +462,6 @@ GAPI_OCV_KERNEL(GCPUMerge4, cv::gapi::core::GMerge4)
}
};
GAPI_OCV_KERNEL(GCPUResize, cv::gapi::core::GResize)
{
static void run(const cv::Mat& in, cv::Size sz, double fx, double fy, int interp, cv::Mat &out)
{
cv::resize(in, out, sz, fx, fy, interp);
}
};
GAPI_OCV_KERNEL(GCPUResizeP, cv::gapi::core::GResizeP)
{
static void run(const cv::Mat& in, cv::Size out_sz, int interp, cv::Mat& out)
{
int inH = in.rows / 3;
int inW = in.cols;
int outH = out.rows / 3;
int outW = out.cols;
for (int i = 0; i < 3; i++) {
auto in_plane = in(cv::Rect(0, i*inH, inW, inH));
auto out_plane = out(cv::Rect(0, i*outH, outW, outH));
cv::resize(in_plane, out_plane, out_sz, 0, 0, interp);
}
}
};
GAPI_OCV_KERNEL(GCPURemap, cv::gapi::core::GRemap)
{
static void run(const cv::Mat& in, const cv::Mat& x, const cv::Mat& y, int a, int b, cv::Scalar s, cv::Mat& out)
@@ -720,7 +696,7 @@ GAPI_OCV_KERNEL(GCPUSizeMF, cv::gapi::streaming::GSizeMF)
}
};
cv::gapi::GKernelPackage cv::gapi::core::cpu::kernels()
cv::GKernelPackage cv::gapi::core::cpu::kernels()
{
static auto pkg = cv::gapi::kernels
< GCPUAdd
@@ -775,8 +751,6 @@ cv::gapi::GKernelPackage cv::gapi::core::cpu::kernels()
, GCPUInRange
, GCPUSplit3
, GCPUSplit4
, GCPUResize
, GCPUResizeP
, GCPUMerge3
, GCPUMerge4
, GCPURemap
+27 -1
View File
@@ -28,6 +28,30 @@ namespace {
}
}
GAPI_OCV_KERNEL(GCPUResize, cv::gapi::imgproc::GResize)
{
static void run(const cv::Mat& in, cv::Size sz, double fx, double fy, int interp, cv::Mat &out)
{
cv::resize(in, out, sz, fx, fy, interp);
}
};
GAPI_OCV_KERNEL(GCPUResizeP, cv::gapi::imgproc::GResizeP)
{
static void run(const cv::Mat& in, cv::Size out_sz, int interp, cv::Mat& out)
{
int inH = in.rows / 3;
int inW = in.cols;
int outH = out.rows / 3;
int outW = out.cols;
for (int i = 0; i < 3; i++) {
auto in_plane = in(cv::Rect(0, i*inH, inW, inH));
auto out_plane = out(cv::Rect(0, i*outH, outW, outH));
cv::resize(in_plane, out_plane, out_sz, 0, 0, interp);
}
}
};
GAPI_OCV_KERNEL(GCPUSepFilter, cv::gapi::imgproc::GSepFilter)
{
static void run(const cv::Mat& in, int ddepth, const cv::Mat& kernX, const cv::Mat& kernY, const cv::Point& anchor, const cv::Scalar& delta,
@@ -613,10 +637,12 @@ GAPI_OCV_KERNEL(GCPUNV12toBGRp, cv::gapi::imgproc::GNV12toBGRp)
}
};
cv::gapi::GKernelPackage cv::gapi::imgproc::cpu::kernels()
cv::GKernelPackage cv::gapi::imgproc::cpu::kernels()
{
static auto pkg = cv::gapi::kernels
< GCPUFilter2D
, GCPUResize
, GCPUResizeP
, GCPUSepFilter
, GCPUBoxFilter
, GCPUBlur
+2 -2
View File
@@ -70,14 +70,14 @@ GAPI_OCV_KERNEL_ST(GCPUStereo, cv::gapi::calib3d::GStereo, StereoSetup)
}
};
cv::gapi::GKernelPackage cv::gapi::calib3d::cpu::kernels() {
cv::GKernelPackage cv::gapi::calib3d::cpu::kernels() {
static auto pkg = cv::gapi::kernels<GCPUStereo>();
return pkg;
}
#else
cv::gapi::GKernelPackage cv::gapi::calib3d::cpu::kernels()
cv::GKernelPackage cv::gapi::calib3d::cpu::kernels()
{
return GKernelPackage();
}
+2 -2
View File
@@ -174,7 +174,7 @@ GAPI_OCV_KERNEL_ST(GCPUKalmanFilterNoControl, cv::gapi::video::GKalmanFilterNoCo
}
};
cv::gapi::GKernelPackage cv::gapi::video::cpu::kernels()
cv::GKernelPackage cv::gapi::video::cpu::kernels()
{
static auto pkg = cv::gapi::kernels
< GCPUBuildOptFlowPyramid
@@ -189,7 +189,7 @@ cv::gapi::GKernelPackage cv::gapi::video::cpu::kernels()
#else
cv::gapi::GKernelPackage cv::gapi::video::cpu::kernels()
cv::GKernelPackage cv::gapi::video::cpu::kernels()
{
return GKernelPackage();
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,214 @@
// 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) 2021 Intel Corporation
#if !defined(GAPI_STANDALONE)
#include "gfluidcore_func.hpp"
#include "gfluidcore_func.simd.hpp"
#include "backends/fluid/gfluidcore_func.simd_declarations.hpp"
#include "gfluidutils.hpp"
#include <opencv2/core/cvdef.h>
#include <opencv2/core/hal/intrin.hpp>
#include <cmath>
#include <cstdlib>
#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstrict-overflow"
#endif
namespace cv {
namespace gapi {
namespace fluid {
#define DIV_SIMD(SRC, DST) \
int div_simd(const SRC in1[], const SRC in2[], DST out[], \
const int length, double _scale) \
{ \
CV_CPU_DISPATCH(div_simd, (in1, in2, out, length, _scale), \
CV_CPU_DISPATCH_MODES_ALL); \
}
DIV_SIMD(uchar, uchar)
DIV_SIMD(ushort, uchar)
DIV_SIMD(short, uchar)
DIV_SIMD(float, uchar)
DIV_SIMD(short, short)
DIV_SIMD(ushort, short)
DIV_SIMD(uchar, short)
DIV_SIMD(float, short)
DIV_SIMD(ushort, ushort)
DIV_SIMD(uchar, ushort)
DIV_SIMD(short, ushort)
DIV_SIMD(float, ushort)
DIV_SIMD(uchar, float)
DIV_SIMD(ushort, float)
DIV_SIMD(short, float)
DIV_SIMD(float, float)
#undef DIV_SIMD
#define MUL_SIMD(SRC, DST) \
int mul_simd(const SRC in1[], const SRC in2[], DST out[], \
const int length, double _scale) \
{ \
CV_CPU_DISPATCH(mul_simd, (in1, in2, out, length, _scale), \
CV_CPU_DISPATCH_MODES_ALL); \
}
MUL_SIMD(uchar, uchar)
MUL_SIMD(ushort, uchar)
MUL_SIMD(short, uchar)
MUL_SIMD(float, uchar)
MUL_SIMD(short, short)
MUL_SIMD(ushort, short)
MUL_SIMD(uchar, short)
MUL_SIMD(float, short)
MUL_SIMD(ushort, ushort)
MUL_SIMD(uchar, ushort)
MUL_SIMD(short, ushort)
MUL_SIMD(float, ushort)
MUL_SIMD(uchar, float)
MUL_SIMD(ushort, float)
MUL_SIMD(short, float)
MUL_SIMD(float, float)
#undef MUL_SIMD
#define ADDC_SIMD(SRC, DST) \
int addc_simd(const SRC in[], const float scalar[], DST out[], \
const int length, const int chan) \
{ \
CV_CPU_DISPATCH(addc_simd, (in, scalar, out, length, chan), \
CV_CPU_DISPATCH_MODES_ALL); \
}
ADDC_SIMD(uchar, uchar)
ADDC_SIMD(ushort, uchar)
ADDC_SIMD(short, uchar)
ADDC_SIMD(float, uchar)
ADDC_SIMD(short, short)
ADDC_SIMD(ushort, short)
ADDC_SIMD(uchar, short)
ADDC_SIMD(float, short)
ADDC_SIMD(ushort, ushort)
ADDC_SIMD(uchar, ushort)
ADDC_SIMD(short, ushort)
ADDC_SIMD(float, ushort)
ADDC_SIMD(uchar, float)
ADDC_SIMD(ushort, float)
ADDC_SIMD(short, float)
ADDC_SIMD(float, float)
#undef ADDC_SIMD
#define SUBC_SIMD(SRC, DST) \
int subc_simd(const SRC in[], const float scalar[], DST out[], \
const int length, const int chan) \
{ \
CV_CPU_DISPATCH(subc_simd, (in, scalar, out, length, chan), \
CV_CPU_DISPATCH_MODES_ALL); \
}
SUBC_SIMD(uchar, uchar)
SUBC_SIMD(ushort, uchar)
SUBC_SIMD(short, uchar)
SUBC_SIMD(float, uchar)
SUBC_SIMD(short, short)
SUBC_SIMD(ushort, short)
SUBC_SIMD(uchar, short)
SUBC_SIMD(float, short)
SUBC_SIMD(ushort, ushort)
SUBC_SIMD(uchar, ushort)
SUBC_SIMD(short, ushort)
SUBC_SIMD(float, ushort)
SUBC_SIMD(uchar, float)
SUBC_SIMD(ushort, float)
SUBC_SIMD(short, float)
SUBC_SIMD(float, float)
#undef SUBC_SIMD
#define SUBRC_SIMD(SRC, DST) \
int subrc_simd(const float scalar[], const SRC in[], DST out[], \
const int length, const int chan) \
{ \
CV_CPU_DISPATCH(subrc_simd, (scalar, in, out, length, chan), \
CV_CPU_DISPATCH_MODES_ALL); \
}
SUBRC_SIMD(uchar, uchar)
SUBRC_SIMD(ushort, uchar)
SUBRC_SIMD(short, uchar)
SUBRC_SIMD(float, uchar)
SUBRC_SIMD(short, short)
SUBRC_SIMD(ushort, short)
SUBRC_SIMD(uchar, short)
SUBRC_SIMD(float, short)
SUBRC_SIMD(ushort, ushort)
SUBRC_SIMD(uchar, ushort)
SUBRC_SIMD(short, ushort)
SUBRC_SIMD(float, ushort)
SUBRC_SIMD(uchar, float)
SUBRC_SIMD(ushort, float)
SUBRC_SIMD(short, float)
SUBRC_SIMD(float, float)
#undef SUBRC_SIMD
#define MULC_SIMD(SRC, DST) \
int mulc_simd(const SRC in[], const float scalar[], DST out[], \
const int length, const int chan, const float scale) \
{ \
CV_CPU_DISPATCH(mulc_simd, (in, scalar, out, length, chan, scale), \
CV_CPU_DISPATCH_MODES_ALL); \
}
MULC_SIMD(uchar, uchar)
MULC_SIMD(ushort, uchar)
MULC_SIMD(short, uchar)
MULC_SIMD(float, uchar)
MULC_SIMD(short, short)
MULC_SIMD(ushort, short)
MULC_SIMD(uchar, short)
MULC_SIMD(float, short)
MULC_SIMD(ushort, ushort)
MULC_SIMD(uchar, ushort)
MULC_SIMD(short, ushort)
MULC_SIMD(float, ushort)
MULC_SIMD(uchar, float)
MULC_SIMD(ushort, float)
MULC_SIMD(short, float)
MULC_SIMD(float, float)
#undef MULC_SIMD
#define ABSDIFFC_SIMD(SRC) \
int absdiffc_simd(const SRC in[], const float scalar[], SRC out[], \
const int length, const int chan) \
{ \
CV_CPU_DISPATCH(absdiffc_simd, (in, scalar, out, length, chan), \
CV_CPU_DISPATCH_MODES_ALL); \
}
ABSDIFFC_SIMD(uchar)
ABSDIFFC_SIMD(short)
ABSDIFFC_SIMD(ushort)
ABSDIFFC_SIMD(float)
#undef ABSDIFFC_SIMD
} // namespace fluid
} // namespace gapi
} // namespace cv
#endif // !defined(GAPI_STANDALONE)
@@ -0,0 +1,170 @@
// 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) 2021 Intel Corporation
#pragma once
#if !defined(GAPI_STANDALONE)
#include <opencv2/core.hpp>
namespace cv {
namespace gapi {
namespace fluid {
#define DIV_SIMD(SRC, DST) \
int div_simd(const SRC in1[], const SRC in2[], DST out[], \
const int length, double _scale);
DIV_SIMD(uchar, uchar)
DIV_SIMD(ushort, uchar)
DIV_SIMD(short, uchar)
DIV_SIMD(float, uchar)
DIV_SIMD(short, short)
DIV_SIMD(ushort, short)
DIV_SIMD(uchar, short)
DIV_SIMD(float, short)
DIV_SIMD(ushort, ushort)
DIV_SIMD(uchar, ushort)
DIV_SIMD(short, ushort)
DIV_SIMD(float, ushort)
DIV_SIMD(uchar, float)
DIV_SIMD(ushort, float)
DIV_SIMD(short, float)
DIV_SIMD(float, float)
#undef DIV_SIMD
#define MUL_SIMD(SRC, DST) \
int mul_simd(const SRC in1[], const SRC in2[], DST out[], \
const int length, double _scale);
MUL_SIMD(uchar, uchar)
MUL_SIMD(ushort, uchar)
MUL_SIMD(short, uchar)
MUL_SIMD(float, uchar)
MUL_SIMD(short, short)
MUL_SIMD(ushort, short)
MUL_SIMD(uchar, short)
MUL_SIMD(float, short)
MUL_SIMD(ushort, ushort)
MUL_SIMD(uchar, ushort)
MUL_SIMD(short, ushort)
MUL_SIMD(float, ushort)
MUL_SIMD(uchar, float)
MUL_SIMD(ushort, float)
MUL_SIMD(short, float)
MUL_SIMD(float, float)
#undef MUL_SIMD
#define ADDC_SIMD(SRC, DST) \
int addc_simd(const SRC in[], const float scalar[], DST out[], \
const int length, const int chan);
ADDC_SIMD(uchar, uchar)
ADDC_SIMD(ushort, uchar)
ADDC_SIMD(short, uchar)
ADDC_SIMD(float, uchar)
ADDC_SIMD(short, short)
ADDC_SIMD(ushort, short)
ADDC_SIMD(uchar, short)
ADDC_SIMD(float, short)
ADDC_SIMD(ushort, ushort)
ADDC_SIMD(uchar, ushort)
ADDC_SIMD(short, ushort)
ADDC_SIMD(float, ushort)
ADDC_SIMD(uchar, float)
ADDC_SIMD(ushort, float)
ADDC_SIMD(short, float)
ADDC_SIMD(float, float)
#undef ADDC_SIMD
#define SUBC_SIMD(SRC, DST) \
int subc_simd(const SRC in[], const float scalar[], DST out[], \
const int length, const int chan);
SUBC_SIMD(uchar, uchar)
SUBC_SIMD(ushort, uchar)
SUBC_SIMD(short, uchar)
SUBC_SIMD(float, uchar)
SUBC_SIMD(short, short)
SUBC_SIMD(ushort, short)
SUBC_SIMD(uchar, short)
SUBC_SIMD(float, short)
SUBC_SIMD(ushort, ushort)
SUBC_SIMD(uchar, ushort)
SUBC_SIMD(short, ushort)
SUBC_SIMD(float, ushort)
SUBC_SIMD(uchar, float)
SUBC_SIMD(ushort, float)
SUBC_SIMD(short, float)
SUBC_SIMD(float, float)
#undef SUBC_SIMD
#define SUBRC_SIMD(SRC, DST) \
int subrc_simd(const float scalar[], const SRC in[], DST out[], \
const int length, const int chan);
SUBRC_SIMD(uchar, uchar)
SUBRC_SIMD(ushort, uchar)
SUBRC_SIMD(short, uchar)
SUBRC_SIMD(float, uchar)
SUBRC_SIMD(short, short)
SUBRC_SIMD(ushort, short)
SUBRC_SIMD(uchar, short)
SUBRC_SIMD(float, short)
SUBRC_SIMD(ushort, ushort)
SUBRC_SIMD(uchar, ushort)
SUBRC_SIMD(short, ushort)
SUBRC_SIMD(float, ushort)
SUBRC_SIMD(uchar, float)
SUBRC_SIMD(ushort, float)
SUBRC_SIMD(short, float)
SUBRC_SIMD(float, float)
#undef SUBRC_SIMD
#define MULC_SIMD(SRC, DST) \
int mulc_simd(const SRC in[], const float scalar[], DST out[], \
const int length, const int chan, const float scale);
MULC_SIMD(uchar, uchar)
MULC_SIMD(ushort, uchar)
MULC_SIMD(short, uchar)
MULC_SIMD(float, uchar)
MULC_SIMD(short, short)
MULC_SIMD(ushort, short)
MULC_SIMD(uchar, short)
MULC_SIMD(float, short)
MULC_SIMD(ushort, ushort)
MULC_SIMD(uchar, ushort)
MULC_SIMD(short, ushort)
MULC_SIMD(float, ushort)
MULC_SIMD(uchar, float)
MULC_SIMD(ushort, float)
MULC_SIMD(short, float)
MULC_SIMD(float, float)
#undef MULC_SIMD
#define ABSDIFFC_SIMD(T) \
int absdiffc_simd(const T in[], const float scalar[], T out[], \
const int length, const int chan);
ABSDIFFC_SIMD(uchar)
ABSDIFFC_SIMD(short)
ABSDIFFC_SIMD(ushort)
ABSDIFFC_SIMD(float)
#undef ABSDIFFC_SIMD
} // namespace fluid
} // namespace gapi
} // namespace cv
#endif // !defined(GAPI_STANDALONE)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,733 @@
// 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) 2021 Intel Corporation
#if !defined(GAPI_STANDALONE)
#include "opencv2/gapi/own/saturate.hpp"
#include <smmintrin.h>
#include "opencv2/core.hpp"
#include <opencv2/core/hal/intrin.hpp>
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <limits>
#include <vector>
#if defined __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstrict-overflow"
#endif
namespace cv {
namespace gapi {
namespace fluid {
namespace sse42 {
CV_ALWAYS_INLINE void v_gather_pixel_map(v_uint8x16& vec, const uchar src[], const short* index, const int pos)
{
const int chanNum = 4;
// pixel_1 (rgbx)
vec.val = _mm_insert_epi32(vec.val, *reinterpret_cast<const int*>(&src[chanNum * (*index + pos)]), 0);
// pixel_2 (rgbx)
vec.val = _mm_insert_epi32(vec.val, *reinterpret_cast<const int*>(&src[chanNum * (*(index + 1) + pos)]), 1);
// pixel_3
vec.val = _mm_insert_epi32(vec.val, *reinterpret_cast<const int*>(&src[chanNum * (*(index + 2) + pos)]), 2);
// pixel_4
vec.val = _mm_insert_epi32(vec.val, *reinterpret_cast<const int*>(&src[chanNum * (*(index + 3) + pos)]), 3);
}
CV_ALWAYS_INLINE void resize_vertical_anyLPI(const uchar* src0, const uchar* src1,
uchar* dst, const int inLength,
const short beta) {
constexpr int nlanes = 16;
__m128i zero = _mm_setzero_si128();
__m128i b = _mm_set1_epi16(beta);
for (int w = 0; inLength >= nlanes;)
{
for (; w <= inLength - nlanes; w += nlanes)
{
__m128i s0 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&src0[w]));
__m128i s1 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&src1[w]));
__m128i a1 = _mm_unpacklo_epi8(s0, zero);
__m128i b1 = _mm_unpacklo_epi8(s1, zero);
__m128i a2 = _mm_unpackhi_epi8(s0, zero);
__m128i b2 = _mm_unpackhi_epi8(s1, zero);
__m128i r1 = _mm_mulhrs_epi16(_mm_sub_epi16(a1, b1), b);
__m128i r2 = _mm_mulhrs_epi16(_mm_sub_epi16(a2, b2), b);
__m128i res1 = _mm_add_epi16(r1, b1);
__m128i res2 = _mm_add_epi16(r2, b2);
_mm_storeu_si128(reinterpret_cast<__m128i*>(dst + w), _mm_packus_epi16(res1, res2));
}
if (w < inLength) {
w = inLength - nlanes;
continue;
}
break;
}
}
CV_ALWAYS_INLINE void resize_horizontal_anyLPI(uint8_t* dst,
const uchar* src, const short mapsx[],
const short alpha[], const int width)
{
constexpr int nlanes = 16;
constexpr int chanNum = 3;
__m128i zero = _mm_setzero_si128();
for (int x = 0; width >= nlanes;)
{
for (; x <= width - nlanes; x += nlanes)
{
__m128i a012 = _mm_setr_epi16(alpha[x], alpha[x], alpha[x], alpha[x + 1],
alpha[x + 1], alpha[x + 1], alpha[x + 2], alpha[x + 2]);
__m128i a2345 = _mm_setr_epi16(alpha[x + 2], alpha[x + 3], alpha[x + 3], alpha[x + 3],
alpha[x + 4], alpha[x + 4], alpha[x + 4], alpha[x + 5]);
__m128i a567 = _mm_setr_epi16(alpha[x + 5], alpha[x + 5], alpha[x + 6], alpha[x + 6],
alpha[x + 6], alpha[x + 7], alpha[x + 7], alpha[x + 7]);
__m128i a8910 = _mm_setr_epi16(alpha[x + 8], alpha[x + 8], alpha[x + 8], alpha[x + 9],
alpha[x + 9], alpha[x + 9], alpha[x + 10], alpha[x + 10]);
__m128i a10111213 = _mm_setr_epi16(alpha[x + 10], alpha[x + 11], alpha[x + 11], alpha[x + 11],
alpha[x + 12], alpha[x + 12], alpha[x + 12], alpha[x + 13]);
__m128i a131415 = _mm_setr_epi16(alpha[x + 13], alpha[x + 13], alpha[x + 14], alpha[x + 14],
alpha[x + 14], alpha[x + 15], alpha[x + 15], alpha[x + 15]);
__m128i a1 = _mm_setr_epi8(src[chanNum * (mapsx[x] + 0)], src[chanNum * (mapsx[x] + 0) + 1], src[chanNum * (mapsx[x] + 0) + 2],
src[chanNum * (mapsx[x + 1] + 0)], src[chanNum * (mapsx[x + 1] + 0) + 1], src[chanNum * (mapsx[x + 1] + 0) + 2],
src[chanNum * (mapsx[x + 2] + 0)], src[chanNum * (mapsx[x + 2] + 0) + 1], src[chanNum * (mapsx[x + 2] + 0) + 2],
src[chanNum * (mapsx[x + 3] + 0)], src[chanNum * (mapsx[x + 3] + 0) + 1], src[chanNum * (mapsx[x + 3] + 0) + 2],
src[chanNum * (mapsx[x + 4] + 0)], src[chanNum * (mapsx[x + 4] + 0) + 1], src[chanNum * (mapsx[x + 4] + 0) + 2],
src[chanNum * (mapsx[x + 5] + 0)]);
__m128i b1 = _mm_setr_epi8(src[chanNum * (mapsx[x] + 1)], src[chanNum * (mapsx[x] + 1) + 1], src[chanNum * (mapsx[x] + 1) + 2],
src[chanNum * (mapsx[x + 1] + 1)], src[chanNum * (mapsx[x + 1] + 1) + 1], src[chanNum * (mapsx[x + 1] + 1) + 2],
src[chanNum * (mapsx[x + 2] + 1)], src[chanNum * (mapsx[x + 2] + 1) + 1], src[chanNum * (mapsx[x + 2] + 1) + 2],
src[chanNum * (mapsx[x + 3] + 1)], src[chanNum * (mapsx[x + 3] + 1) + 1], src[chanNum * (mapsx[x + 3] + 1) + 2],
src[chanNum * (mapsx[x + 4] + 1)], src[chanNum * (mapsx[x + 4] + 1) + 1], src[chanNum * (mapsx[x + 4] + 1) + 2],
src[chanNum * (mapsx[x + 5] + 1)]);
__m128i a2 = _mm_setr_epi8(src[chanNum * (mapsx[x + 5] + 0) + 1], src[chanNum * (mapsx[x + 5] + 0) + 2], src[chanNum * (mapsx[x + 6] + 0)],
src[chanNum * (mapsx[x + 6] + 0) + 1], src[chanNum * (mapsx[x + 6] + 0) + 2], src[chanNum * (mapsx[x + 7] + 0)],
src[chanNum * (mapsx[x + 7] + 0) + 1], src[chanNum * (mapsx[x + 7] + 0) + 2], src[chanNum * (mapsx[x + 8] + 0)],
src[chanNum * (mapsx[x + 8] + 0) + 1], src[chanNum * (mapsx[x + 8] + 0) + 2], src[chanNum * (mapsx[x + 9] + 0)],
src[chanNum * (mapsx[x + 9] + 0) + 1], src[chanNum * (mapsx[x + 9] + 0) + 2], src[chanNum * (mapsx[x + 10] + 0)],
src[chanNum * (mapsx[x + 10] + 0) + 1]);
__m128i b2 = _mm_setr_epi8(src[chanNum * (mapsx[x + 5] + 1) + 1], src[chanNum * (mapsx[x + 5] + 1) + 2], src[chanNum * (mapsx[x + 6] + 1)],
src[chanNum * (mapsx[x + 6] + 1) + 1], src[chanNum * (mapsx[x + 6] + 1) + 2], src[chanNum * (mapsx[x + 7] + 1)],
src[chanNum * (mapsx[x + 7] + 1) + 1], src[chanNum * (mapsx[x + 7] + 1) + 2], src[chanNum * (mapsx[x + 8] + 1)],
src[chanNum * (mapsx[x + 8] + 1) + 1], src[chanNum * (mapsx[x + 8] + 1) + 2], src[chanNum * (mapsx[x + 9] + 1)],
src[chanNum * (mapsx[x + 9] + 1) + 1], src[chanNum * (mapsx[x + 9] + 1) + 2], src[chanNum * (mapsx[x + 10] + 1)],
src[chanNum * (mapsx[x + 10] + 1) + 1]);
__m128i a3 = _mm_setr_epi8(src[chanNum * (mapsx[x + 10] + 0) + 2], src[chanNum * (mapsx[x + 11] + 0)], src[chanNum * (mapsx[x + 11] + 0) + 1],
src[chanNum * (mapsx[x + 11] + 0) + 2], src[chanNum * (mapsx[x + 12] + 0)], src[chanNum * (mapsx[x + 12] + 0) + 1],
src[chanNum * (mapsx[x + 12] + 0) + 2], src[chanNum * (mapsx[x + 13] + 0)], src[chanNum * (mapsx[x + 13] + 0) + 1],
src[chanNum * (mapsx[x + 13] + 0) + 2], src[chanNum * (mapsx[x + 14] + 0)], src[chanNum * (mapsx[x + 14] + 0) + 1],
src[chanNum * (mapsx[x + 14] + 0) + 2], src[chanNum * (mapsx[x + 15] + 0)], src[chanNum * (mapsx[x + 15] + 0) + 1],
src[chanNum * (mapsx[x + 15] + 0) + 2]);
__m128i b3 = _mm_setr_epi8(src[chanNum * (mapsx[x + 10] + 1) + 2], src[chanNum * (mapsx[x + 11] + 1)], src[chanNum * (mapsx[x + 11] + 1) + 1],
src[chanNum * (mapsx[x + 11] + 1) + 2], src[chanNum * (mapsx[x + 12] + 1)], src[chanNum * (mapsx[x + 12] + 1) + 1],
src[chanNum * (mapsx[x + 12] + 1) + 2], src[chanNum * (mapsx[x + 13] + 1)], src[chanNum * (mapsx[x + 13] + 1) + 1],
src[chanNum * (mapsx[x + 13] + 1) + 2], src[chanNum * (mapsx[x + 14] + 1)], src[chanNum * (mapsx[x + 14] + 1) + 1],
src[chanNum * (mapsx[x + 14] + 1) + 2], src[chanNum * (mapsx[x + 15] + 1)], src[chanNum * (mapsx[x + 15] + 1) + 1],
src[chanNum * (mapsx[x + 15] + 1) + 2]);
__m128i a11 = _mm_unpacklo_epi8(a1, zero);
__m128i a12 = _mm_unpackhi_epi8(a1, zero);
__m128i a21 = _mm_unpacklo_epi8(a2, zero);
__m128i a22 = _mm_unpackhi_epi8(a2, zero);
__m128i a31 = _mm_unpacklo_epi8(a3, zero);
__m128i a32 = _mm_unpackhi_epi8(a3, zero);
__m128i b11 = _mm_unpacklo_epi8(b1, zero);
__m128i b12 = _mm_unpackhi_epi8(b1, zero);
__m128i b21 = _mm_unpacklo_epi8(b2, zero);
__m128i b22 = _mm_unpackhi_epi8(b2, zero);
__m128i b31 = _mm_unpacklo_epi8(b3, zero);
__m128i b32 = _mm_unpackhi_epi8(b3, zero);
__m128i r1 = _mm_mulhrs_epi16(_mm_sub_epi16(a11, b11), a012);
__m128i r2 = _mm_mulhrs_epi16(_mm_sub_epi16(a12, b12), a2345);
__m128i r3 = _mm_mulhrs_epi16(_mm_sub_epi16(a21, b21), a567);
__m128i r4 = _mm_mulhrs_epi16(_mm_sub_epi16(a22, b22), a8910);
__m128i r5 = _mm_mulhrs_epi16(_mm_sub_epi16(a31, b31), a10111213);
__m128i r6 = _mm_mulhrs_epi16(_mm_sub_epi16(a32, b32), a131415);
__m128i r_1 = _mm_add_epi16(b11, r1);
__m128i r_2 = _mm_add_epi16(b12, r2);
__m128i r_3 = _mm_add_epi16(b21, r3);
__m128i r_4 = _mm_add_epi16(b22, r4);
__m128i r_5 = _mm_add_epi16(b31, r5);
__m128i r_6 = _mm_add_epi16(b32, r6);
__m128i res1 = _mm_packus_epi16(r_1, r_2);
__m128i res2 = _mm_packus_epi16(r_3, r_4);
__m128i res3 = _mm_packus_epi16(r_5, r_6);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[chanNum * x]), res1);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[chanNum * x + 16]), res2);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[chanNum * x + 32]), res3);
}
if (x < width) {
x = width - nlanes;
continue;
}
break;
}
}
template<int chanNum>
CV_ALWAYS_INLINE void calcRowLinear_8UC_Impl_(uint8_t**,
const uint8_t**,
const uint8_t**,
const short* ,
const short* ,
const short*,
const short* ,
uint8_t*,
const Size& ,
const Size& ,
const int )
{
static_assert(chanNum != 3, "Unsupported number of channel");
}
template<>
CV_ALWAYS_INLINE void calcRowLinear_8UC_Impl_<3>(uint8_t* dst[],
const uint8_t* src0[],
const uint8_t* src1[],
const short alpha[],
const short* clone, // 4 clones of alpha
const short mapsx[],
const short beta[],
uint8_t tmp[],
const Size& inSz,
const Size& outSz,
const int lpi) {
bool xRatioEq = inSz.width == outSz.width;
bool yRatioEq = inSz.height == outSz.height;
constexpr int nlanes = 16;
constexpr int half_nlanes = 16 / 2;
constexpr int chanNum = 3;
if (!xRatioEq && !yRatioEq) {
int inLength = inSz.width * chanNum;
if (lpi == 4)
{
// vertical pass
__m128i b0 = _mm_set1_epi16(beta[0]);
__m128i b1 = _mm_set1_epi16(beta[1]);
__m128i b2 = _mm_set1_epi16(beta[2]);
__m128i b3 = _mm_set1_epi16(beta[3]);
__m128i zero = _mm_setzero_si128();
__m128i vertical_shuf_mask = _mm_setr_epi8(0, 8, 4, 12, 1, 9, 5, 13, 2, 10, 6, 14, 3, 11, 7, 15);
for (int w = 0; w < inSz.width * chanNum; ) {
for (; w <= inSz.width * chanNum - half_nlanes && w >= 0; w += half_nlanes) {
#ifdef __i386__
__m128i val0lo = _mm_castpd_si128(_mm_loadh_pd(
_mm_load_sd(reinterpret_cast<const double*>(&src0[0][w])),
reinterpret_cast<const double*>(&src0[1][w])));
__m128i val0hi = _mm_castpd_si128(_mm_loadh_pd(
_mm_load_sd(reinterpret_cast<const double*>(&src0[2][w])),
reinterpret_cast<const double*>(&src0[3][w])));
__m128i val1lo = _mm_castpd_si128(_mm_loadh_pd(
_mm_load_sd(reinterpret_cast<const double*>(&src1[0][w])),
reinterpret_cast<const double*>(&src1[1][w])));
__m128i val1hi = _mm_castpd_si128(_mm_loadh_pd(
_mm_load_sd(reinterpret_cast<const double*>(&src1[2][w])),
reinterpret_cast<const double*>(&src1[3][w])));
#else
__m128i val0lo = _mm_insert_epi64(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(&src0[0][w])),
*reinterpret_cast<const int64_t*>(&src0[1][w]), 1);
__m128i val0hi = _mm_insert_epi64(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(&src0[2][w])),
*reinterpret_cast<const int64_t*>(&src0[3][w]), 1);
__m128i val1lo = _mm_insert_epi64(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(&src1[0][w])),
*reinterpret_cast<const int64_t*>(&src1[1][w]), 1);
__m128i val1hi = _mm_insert_epi64(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(&src1[2][w])),
*reinterpret_cast<const int64_t*>(&src1[3][w]), 1);
#endif
__m128i val0_0 = _mm_cvtepu8_epi16(val0lo);
__m128i val0_2 = _mm_cvtepu8_epi16(val0hi);
__m128i val1_0 = _mm_cvtepu8_epi16(val1lo);
__m128i val1_2 = _mm_cvtepu8_epi16(val1hi);
__m128i val0_1 = _mm_unpackhi_epi8(val0lo, zero);
__m128i val0_3 = _mm_unpackhi_epi8(val0hi, zero);
__m128i val1_1 = _mm_unpackhi_epi8(val1lo, zero);
__m128i val1_3 = _mm_unpackhi_epi8(val1hi, zero);
__m128i t0 = _mm_mulhrs_epi16(_mm_sub_epi16(val0_0, val1_0), b0);
__m128i t1 = _mm_mulhrs_epi16(_mm_sub_epi16(val0_1, val1_1), b1);
__m128i t2 = _mm_mulhrs_epi16(_mm_sub_epi16(val0_2, val1_2), b2);
__m128i t3 = _mm_mulhrs_epi16(_mm_sub_epi16(val0_3, val1_3), b3);
__m128i r0 = _mm_add_epi16(val1_0, t0);
__m128i r1 = _mm_add_epi16(val1_1, t1);
__m128i r2 = _mm_add_epi16(val1_2, t2);
__m128i r3 = _mm_add_epi16(val1_3, t3);
__m128i q0 = _mm_packus_epi16(r0, r1);
__m128i q1 = _mm_packus_epi16(r2, r3);
__m128i q2 = _mm_blend_epi16(q0, _mm_slli_si128(q1, 4), 0xCC /*0b11001100*/);
__m128i q3 = _mm_blend_epi16(_mm_srli_si128(q0, 4), q1, 0xCC /*0b11001100*/);
__m128i q4 = _mm_shuffle_epi8(q2, vertical_shuf_mask);
__m128i q5 = _mm_shuffle_epi8(q3, vertical_shuf_mask);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&tmp[4 * w + 0]), q4);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&tmp[4 * w + 16]), q5);
}
if (w < inSz.width * chanNum) {
w = inSz.width * chanNum - half_nlanes;
}
}
// horizontal pass
__m128i horizontal_shuf_mask = _mm_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15);
for (int x = 0; outSz.width >= nlanes; )
{
for (; x <= outSz.width - nlanes; x += nlanes)
{
#ifdef _WIN64
__m128i a00 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * x]), *reinterpret_cast<const int64_t*>(&clone[4 * x]));
__m128i a01 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * x]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 1)]));
__m128i a11 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 1)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 1)]));
__m128i a22 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 2)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 2)]));
__m128i a23 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 2)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 3)]));
__m128i a33 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 3)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 3)]));
__m128i a44 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 4)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 4)]));
__m128i a45 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 4)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 5)]));
__m128i a55 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 5)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 5)]));
__m128i a66 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 6)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 6)]));
__m128i a67 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 6)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 7)]));
__m128i a77 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 7)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 7)]));
__m128i a88 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 8)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 8)]));
__m128i a89 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 8)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 9)]));
__m128i a99 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 9)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 9)]));
__m128i a1010 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 10)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 10)]));
__m128i a1011 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 10)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 11)]));
__m128i a1111 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 11)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 11)]));
__m128i a1212 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 12)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 12)]));
__m128i a1213 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 12)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 13)]));
__m128i a1313 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 13)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 13)]));
__m128i a1414 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 14)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 14)]));
__m128i a1415 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 14)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 15)]));
__m128i a1515 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 15)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 15)]));
#else
__m128i a00 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * x]), *reinterpret_cast<const __m64*>(&clone[4 * x]));
__m128i a01 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * x]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 1)]));
__m128i a11 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 1)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 1)]));
__m128i a22 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 2)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 2)]));
__m128i a23 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 2)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 3)]));
__m128i a33 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 3)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 3)]));
__m128i a44 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 4)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 4)]));
__m128i a45 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 4)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 5)]));
__m128i a55 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 5)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 5)]));
__m128i a66 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 6)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 6)]));
__m128i a67 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 6)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 7)]));
__m128i a77 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 7)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 7)]));
__m128i a88 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 8)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 8)]));
__m128i a89 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 8)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 9)]));
__m128i a99 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 9)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 9)]));
__m128i a1010 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 10)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 10)]));
__m128i a1011 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 10)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 11)]));
__m128i a1111 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 11)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 11)]));
__m128i a1212 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 12)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 12)]));
__m128i a1213 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 12)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 13)]));
__m128i a1313 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 13)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 13)]));
__m128i a1414 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 14)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 14)]));
__m128i a1415 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 14)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 15)]));
__m128i a1515 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 15)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 15)]));
#endif
// load 3 channels of first pixel from first pair of 4-couple scope
__m128i pix1 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x])]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix1 = _mm_insert_epi32(pix1, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 1])]), 3);
// load 3 channels of neighbor pixel from first pair of 4-couple scope
__m128i pix2 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x] + 1))]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix2 = _mm_insert_epi32(pix2, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 1] + 1))]), 3);
// expand 8-bit data to 16-bit
__m128i val_0 = _mm_unpacklo_epi8(pix1, zero);
__m128i val_1 = _mm_unpacklo_epi8(pix2, zero);
// expand 8-bit data to 16-bit
__m128i val_2 = _mm_unpackhi_epi8(pix1, zero);
__m128i val_3 = _mm_unpackhi_epi8(pix2, zero);
// the main calculations
__m128i t0_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a00);
__m128i t1_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a01);
__m128i r0_0 = _mm_add_epi16(val_1, t0_0);
__m128i r1_0 = _mm_add_epi16(val_3, t1_0);
// pack 16-bit data to 8-bit
__m128i q0_0 = _mm_packus_epi16(r0_0, r1_0);
// gather data from the same lines together
__m128i res1 = _mm_shuffle_epi8(q0_0, horizontal_shuf_mask);
val_0 = _mm_unpacklo_epi8(_mm_insert_epi64(val_0, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 1] + 1)]), 0), zero);
val_1 = _mm_unpacklo_epi8(_mm_insert_epi64(val_1, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 1] + 1) + 1)]), 0), zero);
val_2 = _mm_insert_epi64(val_2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 2])]), 0);
val_3 = _mm_insert_epi64(val_3, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 2] + 1))]), 0);
val_2 = _mm_unpacklo_epi8(val_2, zero);
val_3 = _mm_unpacklo_epi8(val_3, zero);
__m128i t0_1 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a11);
__m128i t1_1 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a22);
__m128i r0_1 = _mm_add_epi16(val_1, t0_1);
__m128i r1_1 = _mm_add_epi16(val_3, t1_1);
__m128i q0_1 = _mm_packus_epi16(r0_1, r1_1);
__m128i res2 = _mm_shuffle_epi8(q0_1, horizontal_shuf_mask);
__m128i pix7 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 3] - 1) + 2)]));
pix7 = _mm_insert_epi32(pix7, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 2] + 2)]), 0);
__m128i pix8 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 3] + 2)]));
pix8 = _mm_insert_epi32(pix8, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 2] + 1) + 2)]), 0);
val_0 = _mm_unpacklo_epi8(pix7, zero);
val_1 = _mm_unpacklo_epi8(pix8, zero);
val_2 = _mm_unpackhi_epi8(pix7, zero);
val_3 = _mm_unpackhi_epi8(pix8, zero);
// the main calculations
__m128i t0_2 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a23);
__m128i t1_2 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a33);
__m128i r0_2 = _mm_add_epi16(val_1, t0_2);
__m128i r1_2 = _mm_add_epi16(val_3, t1_2);
// pack 16-bit data to 8-bit
__m128i q0_2 = _mm_packus_epi16(r0_2, r1_2);
__m128i res3 = _mm_shuffle_epi8(q0_2, horizontal_shuf_mask);
__m128i pix9 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 4])]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix9 = _mm_insert_epi32(pix9, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 5])]), 3);
// load 3 channels of neighbor pixel from first pair of 4-couple scope
__m128i pix10 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 4] + 1))]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix10 = _mm_insert_epi32(pix10, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 5] + 1))]), 3);
// expand 8-bit data to 16-bit
val_0 = _mm_unpacklo_epi8(pix9, zero);
val_1 = _mm_unpacklo_epi8(pix10, zero);
// expand 8-bit data to 16-bit
val_2 = _mm_unpackhi_epi8(pix9, zero);
val_3 = _mm_unpackhi_epi8(pix10, zero);
// the main calculations
__m128i t0_3 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a44);
__m128i t1_3 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a45);
__m128i r0_3 = _mm_add_epi16(val_1, t0_3);
__m128i r1_3 = _mm_add_epi16(val_3, t1_3);
// pack 16-bit data to 8-bit
__m128i q0_3 = _mm_packus_epi16(r0_3, r1_3);
// gather data from the same lines together
__m128i res4 = _mm_shuffle_epi8(q0_3, horizontal_shuf_mask);
val_0 = _mm_unpacklo_epi8(_mm_insert_epi64(val_0, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 5] + 1)]), 0), zero);
val_1 = _mm_unpacklo_epi8(_mm_insert_epi64(val_1, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 5] + 1) + 1)]), 0), zero);
val_2 = _mm_insert_epi64(val_2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 6])]), 0);
val_3 = _mm_insert_epi64(val_3, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 6] + 1))]), 0);
val_2 = _mm_unpacklo_epi8(val_2, zero);
val_3 = _mm_unpacklo_epi8(val_3, zero);
__m128i t0_4 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a55);
__m128i t1_4 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a66);
__m128i r0_4 = _mm_add_epi16(val_1, t0_4);
__m128i r1_4 = _mm_add_epi16(val_3, t1_4);
__m128i q0_4 = _mm_packus_epi16(r0_4, r1_4);
__m128i res5 = _mm_shuffle_epi8(q0_4, horizontal_shuf_mask);
__m128i pix15 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 7] - 1) + 2)]));
pix15 = _mm_insert_epi32(pix15, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 6] + 2)]), 0);
__m128i pix16 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 7] + 2)]));
pix16 = _mm_insert_epi32(pix16, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 6] + 1) + 2)]), 0);
val_0 = _mm_unpacklo_epi8(pix15, zero);
val_1 = _mm_unpacklo_epi8(pix16, zero);
val_2 = _mm_unpackhi_epi8(pix15, zero);
val_3 = _mm_unpackhi_epi8(pix16, zero);
// the main calculations
__m128i t0_5 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a67);
__m128i t1_5 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a77);
__m128i r0_5 = _mm_add_epi16(val_1, t0_5);
__m128i r1_5 = _mm_add_epi16(val_3, t1_5);
// pack 16-bit data to 8-bit
__m128i q0_5 = _mm_packus_epi16(r0_5, r1_5);
__m128i res6 = _mm_shuffle_epi8(q0_5, horizontal_shuf_mask);
__m128i bl1 = _mm_blend_epi16(res1, _mm_slli_si128(res2, 4), 0xCC /*0b11001100*/);
__m128i bl2 = _mm_blend_epi16(_mm_srli_si128(res1, 4), res2, 0xCC /*0b11001100*/);
__m128i bl3 = _mm_blend_epi16(res3, _mm_slli_si128(res4, 4), 0xCC /*0b11001100*/);
__m128i bl4 = _mm_blend_epi16(_mm_srli_si128(res3, 4), res4, 0xCC /*0b11001100*/);
__m128i bl5 = _mm_blend_epi16(res5, _mm_slli_si128(res6, 4), 0xCC /*0b11001100*/);
__m128i bl6 = _mm_blend_epi16(_mm_srli_si128(res5, 4), res6, 0xCC /*0b11001100*/);
__m128i bl13 = _mm_blend_epi16(bl1, _mm_slli_si128(bl3, 8), 0xF0 /*0b11110000*/);
__m128i bl31 = _mm_blend_epi16(_mm_srli_si128(bl1, 8), bl3, 0xF0 /*0b11110000*/);
__m128i bl24 = _mm_blend_epi16(bl2, _mm_slli_si128(bl4, 8), 0xF0 /*0b11110000*/);
__m128i bl42 = _mm_blend_epi16(_mm_srli_si128(bl2, 8), bl4, 0xF0 /*0b11110000*/);
// load 3 channels of first pixel from first pair of 4-couple scope
__m128i pix17 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 8])]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix17 = _mm_insert_epi32(pix17, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 9])]), 3);
// load 3 channels of neighbor pixel from first pair of 4-couple scope
__m128i pix18 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 8] + 1))]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix18 = _mm_insert_epi32(pix18, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 9] + 1))]), 3);
// expand 8-bit data to 16-bit
val_0 = _mm_unpacklo_epi8(pix17, zero);
val_1 = _mm_unpacklo_epi8(pix18, zero);
// expand 8-bit data to 16-bit
val_2 = _mm_unpackhi_epi8(pix17, zero);
val_3 = _mm_unpackhi_epi8(pix18, zero);
// the main calculations
__m128i t0_6 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a88);
__m128i t1_6 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a89);
__m128i r0_6 = _mm_add_epi16(val_1, t0_6);
__m128i r1_6 = _mm_add_epi16(val_3, t1_6);
// pack 16-bit data to 8-bit
__m128i q0_6 = _mm_packus_epi16(r0_6, r1_6);
// gather data from the same lines together
__m128i res7 = _mm_shuffle_epi8(q0_6, horizontal_shuf_mask);
val_0 = _mm_unpacklo_epi8(_mm_insert_epi64(val_0, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 9] + 1)]), 0), zero);
val_1 = _mm_unpacklo_epi8(_mm_insert_epi64(val_1, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 9] + 1) + 1)]), 0), zero);
val_2 = _mm_insert_epi64(val_2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 10])]), 0);
val_3 = _mm_insert_epi64(val_3, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 10] + 1))]), 0);
val_2 = _mm_unpacklo_epi8(val_2, zero);
val_3 = _mm_unpacklo_epi8(val_3, zero);
__m128i t0_7 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a99);
__m128i t1_7 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1010);
__m128i r0_7 = _mm_add_epi16(val_1, t0_7);
__m128i r1_7 = _mm_add_epi16(val_3, t1_7);
__m128i q0_7 = _mm_packus_epi16(r0_7, r1_7);
__m128i res8 = _mm_shuffle_epi8(q0_7, horizontal_shuf_mask);
__m128i pix21 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 11] - 1) + 2)]));
pix21 = _mm_insert_epi32(pix21, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 10] + 2)]), 0);
__m128i pix22 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 11] + 2)]));
pix22 = _mm_insert_epi32(pix22, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 10] + 1) + 2)]), 0);
val_0 = _mm_unpacklo_epi8(pix21, zero);
val_1 = _mm_unpacklo_epi8(pix22, zero);
val_2 = _mm_unpackhi_epi8(pix21, zero);
val_3 = _mm_unpackhi_epi8(pix22, zero);
// the main calculations
__m128i t0_8 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a1011);
__m128i t1_8 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1111);
__m128i r0_8 = _mm_add_epi16(val_1, t0_8);
__m128i r1_8 = _mm_add_epi16(val_3, t1_8);
// pack 16-bit data to 8-bit
__m128i q0_8 = _mm_packus_epi16(r0_8, r1_8);
__m128i res9 = _mm_shuffle_epi8(q0_8, horizontal_shuf_mask);
__m128i pix23 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 12])]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix23 = _mm_insert_epi32(pix23, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 13])]), 3);
// load 3 channels of neighbor pixel from first pair of 4-couple scope
__m128i pix24 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 12] + 1))]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix24 = _mm_insert_epi32(pix24, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 13] + 1))]), 3);
// expand 8-bit data to 16-bit
val_0 = _mm_unpacklo_epi8(pix23, zero);
val_1 = _mm_unpacklo_epi8(pix24, zero);
// expand 8-bit data to 16-bit
val_2 = _mm_unpackhi_epi8(pix23, zero);
val_3 = _mm_unpackhi_epi8(pix24, zero);
// the main calculations
__m128i t0_9 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a1212);
__m128i t1_9 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1213);
__m128i r0_9 = _mm_add_epi16(val_1, t0_9);
__m128i r1_9 = _mm_add_epi16(val_3, t1_9);
// pack 16-bit data to 8-bit
__m128i q0_9 = _mm_packus_epi16(r0_9, r1_9);
// gather data from the same lines together
__m128i res10 = _mm_shuffle_epi8(q0_9, horizontal_shuf_mask);
val_0 = _mm_unpacklo_epi8(_mm_insert_epi64(val_0, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 13] + 1)]), 0), zero);
val_1 = _mm_unpacklo_epi8(_mm_insert_epi64(val_1, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 13] + 1) + 1)]), 0), zero);
val_2 = _mm_insert_epi64(val_2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 14])]), 0);
val_3 = _mm_insert_epi64(val_3, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 14] + 1))]), 0);
val_2 = _mm_unpacklo_epi8(val_2, zero);
val_3 = _mm_unpacklo_epi8(val_3, zero);
__m128i t0_10 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a1313);
__m128i t1_10 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1414);
__m128i r0_10 = _mm_add_epi16(val_1, t0_10);
__m128i r1_10 = _mm_add_epi16(val_3, t1_10);
__m128i q0_10 = _mm_packus_epi16(r0_10, r1_10);
__m128i res11 = _mm_shuffle_epi8(q0_10, horizontal_shuf_mask);
__m128i pix27 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 15] - 1) + 2)]));
pix27 = _mm_insert_epi32(pix27, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 14] + 2)]), 0);
__m128i pix28 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 15] + 2)]));
pix28 = _mm_insert_epi32(pix28, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 14] + 1) + 2)]), 0);
val_0 = _mm_unpacklo_epi8(pix27, zero);
val_1 = _mm_unpacklo_epi8(pix28, zero);
val_2 = _mm_unpackhi_epi8(pix27, zero);
val_3 = _mm_unpackhi_epi8(pix28, zero);
// the main calculations
__m128i t0_11 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a1415);
__m128i t1_11 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1515);
__m128i r0_11 = _mm_add_epi16(val_1, t0_11);
__m128i r1_11 = _mm_add_epi16(val_3, t1_11);
// pack 16-bit data to 8-bit
__m128i q0_11 = _mm_packus_epi16(r0_11, r1_11);
__m128i res12 = _mm_shuffle_epi8(q0_11, horizontal_shuf_mask);
__m128i bl7 = _mm_blend_epi16(res7, _mm_slli_si128(res8, 4), 0xCC /*0b11001100*/);
__m128i bl8 = _mm_blend_epi16(_mm_srli_si128(res7, 4), res8, 0xCC /*0b11001100*/);
__m128i bl9 = _mm_blend_epi16(res9, _mm_slli_si128(res10, 4), 0xCC /*0b11001100*/);
__m128i bl10 = _mm_blend_epi16(_mm_srli_si128(res9, 4), res10, 0xCC /*0b11001100*/);
__m128i bl11 = _mm_blend_epi16(res11, _mm_slli_si128(res12, 4), 0xCC /*0b11001100*/);
__m128i bl12 = _mm_blend_epi16(_mm_srli_si128(res11, 4), res12, 0xCC /*0b11001100*/);
__m128i bl57 = _mm_blend_epi16(bl5, _mm_slli_si128(bl7, 8), 0xF0 /*0b11110000*/);
__m128i bl75 = _mm_blend_epi16(_mm_srli_si128(bl5, 8), bl7, 0xF0 /*0b11110000*/);
__m128i bl68 = _mm_blend_epi16(bl6, _mm_slli_si128(bl8, 8), 0xF0 /*0b11110000*/);
__m128i bl86 = _mm_blend_epi16(_mm_srli_si128(bl6, 8), bl8, 0xF0 /*0b11110000*/);
__m128i bl911 = _mm_blend_epi16(bl9, _mm_slli_si128(bl11, 8), 0xF0 /*0b11110000*/);
__m128i bl119 = _mm_blend_epi16(_mm_srli_si128(bl9, 8), bl11, 0xF0 /*0b11110000*/);
__m128i bl1012 = _mm_blend_epi16(bl10, _mm_slli_si128(bl12, 8), 0xF0 /*0b11110000*/);
__m128i bl1210 = _mm_blend_epi16(_mm_srli_si128(bl10, 8), bl12, 0xF0 /*0b11110000*/);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[0][3 * x]), bl13);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[1][3 * x]), bl24);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[2][3 * x]), bl31);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[3][3 * x]), bl42);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[0][3 * x + 16]), bl57);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[1][3 * x + 16]), bl68);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[2][3 * x + 16]), bl75);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[3][3 * x + 16]), bl86);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[0][3 * x + 32]), bl911);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[1][3 * x + 32]), bl1012);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[2][3 * x + 32]), bl119);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[3][3 * x + 32]), bl1210);
}
if (x < outSz.width) {
x = outSz.width - nlanes;
continue;
}
break;
}
}
else
{ // if any lpi
for (int l = 0; l < lpi; ++l) {
short beta0 = beta[l];
const uchar* s0 = src0[l];
const uchar* s1 = src1[l];
// vertical pass
resize_vertical_anyLPI(s0, s1, tmp, inLength, beta0);
// horizontal pass
resize_horizontal_anyLPI(dst[l], tmp, mapsx, alpha, outSz.width);
}
}
} else if (!xRatioEq) {
GAPI_DbgAssert(yRatioEq);
for (int l = 0; l < lpi; ++l) {
const uchar* src = src0[l];
// horizontal pass
resize_horizontal_anyLPI(dst[l], src, mapsx, alpha, outSz.width);
}
} else if (!yRatioEq) {
GAPI_DbgAssert(xRatioEq);
int inLength = inSz.width*chanNum; // == outSz.width
for (int l = 0; l < lpi; ++l) {
short beta0 = beta[l];
const uchar* s0 = src0[l];
const uchar* s1 = src1[l];
// vertical pass
resize_vertical_anyLPI(s0, s1, dst[l], inLength, beta0);
}
} else {
GAPI_DbgAssert(xRatioEq && yRatioEq);
int length = inSz.width *chanNum;
for (int l = 0; l < lpi; ++l) {
memcpy(dst[l], src0[l], length);
}
}
}
} // namespace sse42
} // namespace fliud
} // namespace gapi
} // namespace cv
#endif // !defined(GAPI_STANDALONE)
@@ -25,6 +25,10 @@
#include "gfluidimgproc_func.hpp"
#if CV_SSE4_1
#include "gfluidcore_simd_sse41.hpp"
#endif
#include <opencv2/imgproc/hal/hal.hpp>
#include <opencv2/core/hal/intrin.hpp>
@@ -1821,16 +1825,312 @@ GAPI_FLUID_KERNEL(GFluidBayerGR2RGB, cv::gapi::imgproc::GBayerGR2RGB, false)
}
};
template<typename T, typename Mapper, int chanNum>
struct LinearScratchDesc {
using alpha_t = typename Mapper::alpha_type;
using index_t = typename Mapper::index_type;
alpha_t* alpha;
alpha_t* clone;
index_t* mapsx;
alpha_t* beta;
index_t* mapsy;
T* tmp;
LinearScratchDesc(int /*inW*/, int /*inH*/, int outW, int outH, void* data) {
alpha = reinterpret_cast<alpha_t*>(data);
clone = reinterpret_cast<alpha_t*>(alpha + outW);
mapsx = reinterpret_cast<index_t*>(clone + outW*4);
beta = reinterpret_cast<alpha_t*>(mapsx + outW);
mapsy = reinterpret_cast<index_t*>(beta + outH);
tmp = reinterpret_cast<T*> (mapsy + outH*2);
}
static int bufSize(int inW, int /*inH*/, int outW, int outH, int lpi) {
auto size = outW * sizeof(alpha_t) +
outW * sizeof(alpha_t) * 4 + // alpha clones
outW * sizeof(index_t) +
outH * sizeof(alpha_t) +
outH * sizeof(index_t) * 2 +
inW * sizeof(T) * lpi * chanNum;
return static_cast<int>(size);
}
};
static inline double invRatio(int inSz, int outSz) {
return static_cast<double>(outSz) / inSz;
}
static inline double ratio(int inSz, int outSz) {
return 1 / invRatio(inSz, outSz);
}
template<typename T, typename Mapper, int chanNum = 1>
static inline void initScratchLinear(const cv::GMatDesc& in,
const Size& outSz,
cv::gapi::fluid::Buffer& scratch,
int lpi) {
using alpha_type = typename Mapper::alpha_type;
static const auto unity = Mapper::unity;
auto inSz = in.size;
auto sbufsize = LinearScratchDesc<T, Mapper, chanNum>::bufSize(inSz.width, inSz.height, outSz.width, outSz.height, lpi);
Size scratch_size{sbufsize, 1};
cv::GMatDesc desc;
desc.chan = 1;
desc.depth = CV_8UC1;
desc.size = scratch_size;
cv::gapi::fluid::Buffer buffer(desc);
scratch = std::move(buffer);
double hRatio = ratio(in.size.width, outSz.width);
double vRatio = ratio(in.size.height, outSz.height);
LinearScratchDesc<T, Mapper, chanNum> scr(inSz.width, inSz.height, outSz.width, outSz.height, scratch.OutLineB());
auto *alpha = scr.alpha;
auto *clone = scr.clone;
auto *index = scr.mapsx;
for (int x = 0; x < outSz.width; x++) {
auto map = Mapper::map(hRatio, 0, in.size.width, x);
auto alpha0 = map.alpha0;
auto index0 = map.index0;
// TRICK:
// Algorithm takes pair of input pixels, sx0'th and sx1'th,
// and compute result as alpha0*src[sx0] + alpha1*src[sx1].
// By definition: sx1 == sx0 + 1 either sx1 == sx0, and
// alpha0 + alpha1 == unity (scaled appropriately).
// Here we modify formulas for alpha0 and sx1: by assuming
// that sx1 == sx0 + 1 always, and patching alpha0 so that
// result remains intact.
// Note that we need in.size.width >= 2, for both sx0 and
// sx0+1 were indexing pixels inside the input's width.
if (map.index1 != map.index0 + 1) {
GAPI_DbgAssert(map.index1 == map.index0);
GAPI_DbgAssert(in.size.width >= 2);
if (map.index0 < in.size.width-1) {
// sx1=sx0+1 fits inside row,
// make sure alpha0=unity and alpha1=0,
// so that result equals src[sx0]*unity
alpha0 = saturate_cast<alpha_type>(unity);
} else {
// shift sx0 to left by 1 pixel,
// and make sure that alpha0=0 and alpha1==1,
// so that result equals to src[sx0+1]*unity
alpha0 = 0;
index0--;
}
}
alpha[x] = alpha0;
index[x] = index0;
for (int l = 0; l < 4; l++) {
clone[4*x + l] = alpha0;
}
}
auto *beta = scr.beta;
auto *index_y = scr.mapsy;
for (int y = 0; y < outSz.height; y++) {
auto mapY = Mapper::map(vRatio, 0, in.size.height, y);
beta[y] = mapY.alpha0;
index_y[y] = mapY.index0;
index_y[outSz.height + y] = mapY.index1;
}
}
template<typename F, typename I>
struct MapperUnit {
F alpha0, alpha1;
I index0, index1;
};
inline static uint8_t calc(short alpha0, uint8_t src0, short alpha1, uint8_t src1) {
constexpr static const int half = 1 << 14;
return (src0 * alpha0 + src1 * alpha1 + half) >> 15;
}
struct Mapper {
constexpr static const int ONE = 1 << 15;
typedef short alpha_type;
typedef short index_type;
constexpr static const int unity = ONE;
typedef MapperUnit<short, short> Unit;
static inline Unit map(double ratio, int start, int max, int outCoord) {
float f = static_cast<float>((outCoord + 0.5) * ratio - 0.5);
int s = cvFloor(f);
f -= s;
Unit u;
u.index0 = static_cast<short>(std::max(s - start, 0));
u.index1 = static_cast<short>(((f == 0.0) || s + 1 >= max) ? s - start : s - start + 1);
u.alpha0 = saturate_cast<short>(ONE * (1.0f - f));
u.alpha1 = saturate_cast<short>(ONE * f);
return u;
}
};
template<typename T, class Mapper, int numChan>
static void calcRowLinearC(const cv::gapi::fluid::View & in,
cv::gapi::fluid::Buffer& out,
cv::gapi::fluid::Buffer& scratch) {
using alpha_type = typename Mapper::alpha_type;
auto inSz = in.meta().size;
auto outSz = out.meta().size;
auto inY = in.y();
int outY = out.y();
int lpi = out.lpi();
GAPI_DbgAssert(outY + lpi <= outSz.height);
GAPI_DbgAssert(lpi <= 4);
LinearScratchDesc<T, Mapper, numChan> scr(inSz.width, inSz.height, outSz.width, outSz.height, scratch.OutLineB());
const auto *alpha = scr.alpha;
const auto *mapsx = scr.mapsx;
const auto *beta_0 = scr.beta;
const auto *mapsy = scr.mapsy;
const auto *beta = beta_0 + outY;
const T *src0[4];
const T *src1[4];
T* dst[4];
for (int l = 0; l < lpi; l++) {
auto index0 = mapsy[outY + l] - inY;
auto index1 = mapsy[outSz.height + outY + l] - inY;
src0[l] = in.InLine<const T>(index0);
src1[l] = in.InLine<const T>(index1);
dst[l] = out.OutLine<T>(l);
}
#if 0 // Disabling SSE4.1 path due to Valgrind issues: https://github.com/opencv/opencv/issues/21097
#if CV_SSE4_1
const auto* clone = scr.clone;
auto* tmp = scr.tmp;
if (inSz.width >= 16 && outSz.width >= 16)
{
sse42::calcRowLinear_8UC_Impl_<numChan>(reinterpret_cast<uint8_t**>(dst),
reinterpret_cast<const uint8_t**>(src0),
reinterpret_cast<const uint8_t**>(src1),
reinterpret_cast<const short*>(alpha),
reinterpret_cast<const short*>(clone),
reinterpret_cast<const short*>(mapsx),
reinterpret_cast<const short*>(beta),
reinterpret_cast<uint8_t*>(tmp),
inSz, outSz, lpi);
return;
}
#endif // CV_SSE4_1
#endif
int length = out.length();
for (int l = 0; l < lpi; l++) {
constexpr static const auto unity = Mapper::unity;
auto beta0 = beta[l];
auto beta1 = saturate_cast<alpha_type>(unity - beta[l]);
for (int x = 0; x < length; x++) {
auto alpha0 = alpha[x];
auto alpha1 = saturate_cast<alpha_type>(unity - alpha[x]);
auto sx0 = mapsx[x];
auto sx1 = sx0 + 1;
for (int c = 0; c < numChan; c++) {
auto idx0 = numChan*sx0 + c;
auto idx1 = numChan*sx1 + c;
T tmp0 = calc(beta0, src0[l][idx0], beta1, src1[l][idx0]);
T tmp1 = calc(beta0, src0[l][idx1], beta1, src1[l][idx1]);
dst[l][numChan * x + c] = calc(alpha0, tmp0, alpha1, tmp1);
}
}
}
}
GAPI_FLUID_KERNEL(GFluidResize, cv::gapi::imgproc::GResize, true)
{
static const int Window = 1;
static const int LPI = 4;
static const auto Kind = GFluidKernel::Kind::Resize;
constexpr static const int INTER_RESIZE_COEF_BITS = 11;
constexpr static const int INTER_RESIZE_COEF_SCALE = 1 << INTER_RESIZE_COEF_BITS;
constexpr static const short ONE = INTER_RESIZE_COEF_SCALE;
static void initScratch(const cv::GMatDesc& in,
cv::Size outSz, double fx, double fy, int /*interp*/,
cv::gapi::fluid::Buffer &scratch)
{
int outSz_w;
int outSz_h;
if (outSz.width == 0 || outSz.height == 0)
{
outSz_w = static_cast<int>(round(in.size.width * fx));
outSz_h = static_cast<int>(round(in.size.height * fy));
}
else
{
outSz_w = outSz.width;
outSz_h = outSz.height;
}
cv::Size outSize(outSz_w, outSz_h);
if (in.chan == 3)
{
initScratchLinear<uchar, Mapper, 3>(in, outSize, scratch, LPI);
}
else if (in.chan == 4)
{
initScratchLinear<uchar, Mapper, 4>(in, outSize, scratch, LPI);
}
}
static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/)
{}
static void run(const cv::gapi::fluid::View& in, cv::Size /*sz*/, double /*fx*/, double /*fy*/, int interp,
cv::gapi::fluid::Buffer& out,
cv::gapi::fluid::Buffer& scratch) {
const int channels = in.meta().chan;
GAPI_Assert((channels == 3 || channels == 4) && (interp == cv::INTER_LINEAR));
if (channels == 3)
{
calcRowLinearC<uint8_t, Mapper, 3>(in, out, scratch);
}
else if (channels == 4)
{
calcRowLinearC<uint8_t, Mapper, 4>(in, out, scratch);
}
}
};
} // namespace fluid
} // namespace gapi
} // namespace cv
cv::gapi::GKernelPackage cv::gapi::imgproc::fluid::kernels()
cv::GKernelPackage cv::gapi::imgproc::fluid::kernels()
{
using namespace cv::gapi::fluid;
return cv::gapi::kernels
< GFluidBGR2Gray
, GFluidResize
, GFluidRGB2Gray
, GFluidRGB2GrayCustom
, GFluidRGB2YUV
@@ -49,3 +49,9 @@ cv::gapi::ie::PyParams& cv::gapi::ie::PyParams::cfgNumRequests(size_t nireq) {
m_priv->cfgNumRequests(nireq);
return *this;
}
cv::gapi::ie::PyParams&
cv::gapi::ie::PyParams::cfgBatchSize(const size_t size) {
m_priv->cfgBatchSize(size);
return *this;
}
+151 -70
View File
@@ -127,7 +127,6 @@ inline int toCV(IE::Precision prec) {
inline IE::TensorDesc toIE(const cv::Mat &mat, cv::gapi::ie::TraitAs hint) {
const auto &sz = mat.size;
// NB: For some reason RGB image is 2D image
// (since channel component is not counted here).
// Note: regular 2D vectors also fall into this category
@@ -148,7 +147,6 @@ inline IE::TensorDesc toIE(const cv::Mat &mat, cv::gapi::ie::TraitAs hint) {
return IE::TensorDesc(toIE(mat.depth()),
IE::SizeVector{1, channels, height, width}, bdesc);
}
return IE::TensorDesc(toIE(mat.depth()), toIE(sz), toIELayout(sz.dims()));
}
@@ -218,14 +216,18 @@ struct IEUnit {
cv::gapi::ie::detail::ParamDesc params;
IE::CNNNetwork net;
IE::InputsDataMap inputs;
IE::OutputsDataMap outputs;
IE::ExecutableNetwork this_network;
cv::gimpl::ie::wrap::Plugin this_plugin;
InferenceEngine::RemoteContext::Ptr rctx = nullptr;
// FIXME: Unlike loadNetwork case, importNetwork requires that preprocessing
// should be passed as ExecutableNetwork::SetBlob method, so need to collect
// and store this information at the graph compilation stage (outMeta) and use in runtime.
using PreProcMap = std::unordered_map<std::string, IE::PreProcessInfo>;
PreProcMap preproc_map;
explicit IEUnit(const cv::gapi::ie::detail::ParamDesc &pp)
: params(pp) {
InferenceEngine::ParamMap* ctx_params =
@@ -237,11 +239,12 @@ struct IEUnit {
if (params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
net = cv::gimpl::ie::wrap::readNetwork(params);
inputs = net.getInputsInfo();
outputs = net.getOutputsInfo();
// NB: Set batch size only if user asked. (don't set by default)
if (params.batch_size.has_value()) {
net.setBatchSize(params.batch_size.value());
}
} else if (params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import) {
this_plugin = cv::gimpl::ie::wrap::getPlugin(params);
this_plugin.SetConfig(params.config);
this_network = cv::gimpl::ie::wrap::importNetwork(this_plugin, params, rctx);
if (!params.reshape_table.empty() || !params.layer_names_to_reshape.empty()) {
GAPI_LOG_WARNING(NULL, "Reshape isn't supported for imported network");
@@ -267,14 +270,14 @@ struct IEUnit {
}
if (params.num_in == 1u && params.input_names.empty()) {
if (params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
params.input_names = { inputs.begin()->first };
params.input_names = { net.getInputsInfo().begin()->first };
} else {
params.input_names = { this_network.GetInputsInfo().begin()->first };
}
}
if (params.num_out == 1u && params.output_names.empty()) {
if (params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
params.output_names = { outputs.begin()->first };
params.output_names = { net.getOutputsInfo().begin()->first };
} else {
params.output_names = { this_network.GetOutputsInfo().begin()->first };
}
@@ -289,11 +292,11 @@ struct IEUnit {
// This method is [supposed to be] called at Island compilation stage
cv::gimpl::ie::IECompiled compile() const {
IEUnit* non_const_this = const_cast<IEUnit*>(this);
// FIXME: LoadNetwork must be called only after all necessary model
// inputs information is set, since it's done in outMeta and compile called after that,
// this place seems to be suitable, but consider another place not to break const agreements.
if (params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
// FIXME: In case importNetwork for fill inputs/outputs need to obtain ExecutableNetwork, but
// for loadNetwork they can be obtained by using readNetwork
non_const_this->this_plugin = cv::gimpl::ie::wrap::getPlugin(params);
non_const_this->this_plugin.SetConfig(params.config);
non_const_this->this_network = cv::gimpl::ie::wrap::loadNetwork(non_const_this->this_plugin,
net, params, rctx);
}
@@ -518,7 +521,9 @@ inline IE::Blob::Ptr extractRemoteBlob(IECallContext& ctx, std::size_t i) {
blob_params->second);
}
inline IE::Blob::Ptr extractBlob(IECallContext& ctx, std::size_t i) {
inline IE::Blob::Ptr extractBlob(IECallContext& ctx,
std::size_t i,
cv::gapi::ie::TraitAs hint) {
if (ctx.uu.rctx != nullptr) {
return extractRemoteBlob(ctx, i);
}
@@ -530,7 +535,7 @@ inline IE::Blob::Ptr extractBlob(IECallContext& ctx, std::size_t i) {
return wrapIE(*(ctx.views.back()), frame.desc());
}
case cv::GShape::GMAT: {
return wrapIE(ctx.inMat(i), cv::gapi::ie::TraitAs::IMAGE);
return wrapIE(ctx.inMat(i), hint);
}
default:
GAPI_Assert("Unsupported input shape for IE backend");
@@ -539,19 +544,19 @@ inline IE::Blob::Ptr extractBlob(IECallContext& ctx, std::size_t i) {
}
static void setBlob(InferenceEngine::InferRequest& req,
cv::gapi::ie::detail::ParamDesc::Kind kind,
const std::string& layer_name,
IE::Blob::Ptr blob) {
// NB: In case importNetwork preprocessing must be
// passed as SetBlob argument.
if (kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
static void setBlob(InferenceEngine::InferRequest& req,
const std::string& layer_name,
const IE::Blob::Ptr& blob,
const IECallContext& ctx) {
// TODO: Ideally we shouldn't do SetBlob() but GetBlob() instead,
// and redirect our data producers to this memory
// (A memory dialog comes to the picture again)
using namespace cv::gapi::ie::detail;
if (ctx.uu.params.kind == ParamDesc::Kind::Load) {
req.SetBlob(layer_name, blob);
} else {
GAPI_Assert(kind == cv::gapi::ie::detail::ParamDesc::Kind::Import);
IE::PreProcessInfo info;
info.setResizeAlgorithm(IE::RESIZE_BILINEAR);
req.SetBlob(layer_name, blob, info);
GAPI_Assert(ctx.uu.params.kind == ParamDesc::Kind::Import);
req.SetBlob(layer_name, blob, ctx.uu.preproc_map.at(layer_name));
}
}
@@ -821,6 +826,23 @@ static void configureInputInfo(const IE::InputInfo::Ptr& ii, const cv::GMetaArg
}
}
static IE::PreProcessInfo configurePreProcInfo(const IE::InputInfo::CPtr& ii,
const cv::GMetaArg& mm) {
IE::PreProcessInfo info;
if (cv::util::holds_alternative<cv::GFrameDesc>(mm)) {
auto desc = cv::util::get<cv::GFrameDesc>(mm);
if (desc.fmt == cv::MediaFormat::NV12) {
info.setColorFormat(IE::ColorFormat::NV12);
}
}
const auto layout = ii->getTensorDesc().getLayout();
if (layout == IE::Layout::NCHW ||
layout == IE::Layout::NHWC) {
info.setResizeAlgorithm(IE::RESIZE_BILINEAR);
}
return info;
}
// NB: This is a callback used by async infer
// to post outputs blobs (cv::GMat's).
static void PostOutputs(InferenceEngine::InferRequest &request,
@@ -920,11 +942,13 @@ struct Infer: public cv::detail::KernelTag {
// NB: Configuring input precision and network reshape must be done
// only in the loadNetwork case.
if (uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
using namespace cv::gapi::ie::detail;
if (uu.params.kind == ParamDesc::Kind::Load) {
auto inputs = uu.net.getInputsInfo();
for (auto &&it : ade::util::zip(ade::util::toRange(uu.params.input_names),
ade::util::toRange(in_metas))) {
const auto &input_name = std::get<0>(it);
auto &&ii = uu.inputs.at(input_name);
auto ii = inputs.at(input_name);
const auto & mm = std::get<1>(it);
configureInputInfo(ii, mm);
@@ -932,7 +956,14 @@ struct Infer: public cv::detail::KernelTag {
uu.params.layer_names_to_reshape.end()) {
configureInputReshapeByImage(ii, mm, input_reshape_table);
}
ii->getPreProcess().setResizeAlgorithm(IE::RESIZE_BILINEAR);
// NB: Configure resize only for NCHW/NHWC layout,
// since it isn't supposed to work with others.
auto layout = ii->getTensorDesc().getLayout();
if (layout == IE::Layout::NCHW ||
layout == IE::Layout::NHWC) {
ii->getPreProcess().setResizeAlgorithm(IE::RESIZE_BILINEAR);
}
}
// FIXME: This isn't the best place to call reshape function.
@@ -941,6 +972,18 @@ struct Infer: public cv::detail::KernelTag {
if (!input_reshape_table.empty()) {
const_cast<IE::CNNNetwork *>(&uu.net)->reshape(input_reshape_table);
}
} else {
GAPI_Assert(uu.params.kind == ParamDesc::Kind::Import);
auto inputs = uu.this_network.GetInputsInfo();
// FIXME: This isn't the best place to collect PreProcMap.
auto* non_const_prepm = const_cast<IEUnit::PreProcMap*>(&uu.preproc_map);
for (auto &&it : ade::util::zip(ade::util::toRange(uu.params.input_names),
ade::util::toRange(in_metas))) {
const auto &input_name = std::get<0>(it);
auto ii = inputs.at(input_name);
const auto & mm = std::get<1>(it);
non_const_prepm->emplace(input_name, configurePreProcInfo(ii, mm));
}
}
// FIXME: It would be nice here to have an exact number of network's
@@ -949,11 +992,13 @@ struct Infer: public cv::detail::KernelTag {
for (const auto &out_name : uu.params.output_names) {
// NOTE: our output_names vector follows the API order
// of this operation's outputs
const IE::DataPtr& ie_out = uu.outputs.at(out_name);
const IE::SizeVector dims = ie_out->getTensorDesc().getDims();
const auto& desc =
uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load
? uu.net.getOutputsInfo().at(out_name)->getTensorDesc()
: uu.this_network.GetOutputsInfo().at(out_name)->getTensorDesc();
cv::GMatDesc outm(toCV(ie_out->getPrecision()),
toCV(ie_out->getTensorDesc().getDims()));
cv::GMatDesc outm(toCV(desc.getPrecision()),
toCV(desc.getDims()));
result.emplace_back(outm);
}
return result;
@@ -968,14 +1013,16 @@ struct Infer: public cv::detail::KernelTag {
// non-generic version for now:
// - assumes all inputs/outputs are always Mats
for (auto i : ade::util::iota(ctx->uu.params.num_in)) {
// TODO: Ideally we shouldn't do SetBlob() but GetBlob() instead,
// and redirect our data producers to this memory
// (A memory dialog comes to the picture again)
IE::Blob::Ptr this_blob = extractBlob(*ctx, i);
setBlob(req,
ctx->uu.params.kind,
ctx->uu.params.input_names[i],
this_blob);
const auto& layer_name = ctx->uu.params.input_names[i];
auto layout =
ctx->uu.this_network.GetInputsInfo().
at(layer_name)->getTensorDesc().getLayout();
auto hint =
(layout == IE::Layout::NCHW || layout == IE::Layout::NHWC)
? cv::gapi::ie::TraitAs::IMAGE : cv::gapi::ie::TraitAs::TENSOR;
IE::Blob::Ptr this_blob = extractBlob(*ctx, i, hint);
setBlob(req, layer_name, this_blob, *ctx);
}
// FIXME: Should it be done by kernel ?
// What about to do that in RequestPool ?
@@ -1007,13 +1054,13 @@ struct InferROI: public cv::detail::KernelTag {
GAPI_Assert(1u == uu.params.input_names.size());
GAPI_Assert(2u == in_metas.size());
const auto &input_name = uu.params.input_names.at(0);
auto &&mm = in_metas.at(1u);
// NB: Configuring input precision and network reshape must be done
// only in the loadNetwork case.
if (uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
// 0th is ROI, 1st is input image
const auto &input_name = uu.params.input_names.at(0);
auto &&ii = uu.inputs.at(input_name);
auto &&mm = in_metas.at(1u);
auto ii = uu.net.getInputsInfo().at(input_name);
configureInputInfo(ii, mm);
if (uu.params.layer_names_to_reshape.find(input_name) !=
uu.params.layer_names_to_reshape.end()) {
@@ -1027,6 +1074,13 @@ struct InferROI: public cv::detail::KernelTag {
if (!input_reshape_table.empty()) {
const_cast<IE::CNNNetwork *>(&uu.net)->reshape(input_reshape_table);
}
} else {
GAPI_Assert(uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import);
auto inputs = uu.this_network.GetInputsInfo();
// FIXME: This isn't the best place to collect PreProcMap.
auto* non_const_prepm = const_cast<IEUnit::PreProcMap*>(&uu.preproc_map);
auto ii = inputs.at(input_name);
non_const_prepm->emplace(input_name, configurePreProcInfo(ii, mm));
}
// FIXME: It would be nice here to have an exact number of network's
@@ -1035,11 +1089,13 @@ struct InferROI: public cv::detail::KernelTag {
for (const auto &out_name : uu.params.output_names) {
// NOTE: our output_names vector follows the API order
// of this operation's outputs
const IE::DataPtr& ie_out = uu.outputs.at(out_name);
const IE::SizeVector dims = ie_out->getTensorDesc().getDims();
const auto& desc =
uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load
? uu.net.getOutputsInfo().at(out_name)->getTensorDesc()
: uu.this_network.GetOutputsInfo().at(out_name)->getTensorDesc();
cv::GMatDesc outm(toCV(ie_out->getPrecision()),
toCV(ie_out->getTensorDesc().getDims()));
cv::GMatDesc outm(toCV(desc.getPrecision()),
toCV(desc.getDims()));
result.emplace_back(outm);
}
return result;
@@ -1054,12 +1110,14 @@ struct InferROI: public cv::detail::KernelTag {
GAPI_Assert(ctx->uu.params.num_in == 1);
auto&& this_roi = ctx->inArg<cv::detail::OpaqueRef>(0).rref<cv::Rect>();
IE::Blob::Ptr this_blob = extractBlob(*ctx, 1);
// NB: This blob will be used to make roi from its, so
// it should be treated as image
IE::Blob::Ptr this_blob =
extractBlob(*ctx, 1, cv::gapi::ie::TraitAs::IMAGE);
setBlob(req,
ctx->uu.params.kind,
*(ctx->uu.params.input_names.begin()),
IE::make_shared_blob(this_blob,
toIE(this_roi)));
IE::make_shared_blob(this_blob, toIE(this_roi)),
*ctx);
// FIXME: Should it be done by kernel ?
// What about to do that in RequestPool ?
req.StartAsync();
@@ -1098,8 +1156,9 @@ struct InferList: public cv::detail::KernelTag {
// only in the loadNetwork case.
if (uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
std::size_t idx = 1u;
auto inputs = uu.net.getInputsInfo();
for (auto &&input_name : uu.params.input_names) {
auto &&ii = uu.inputs.at(input_name);
auto ii = inputs.at(input_name);
const auto & mm = in_metas[idx++];
configureInputInfo(ii, mm);
if (uu.params.layer_names_to_reshape.find(input_name) !=
@@ -1115,6 +1174,16 @@ struct InferList: public cv::detail::KernelTag {
if (!input_reshape_table.empty()) {
const_cast<IE::CNNNetwork *>(&uu.net)->reshape(input_reshape_table);
}
} else {
GAPI_Assert(uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import);
std::size_t idx = 1u;
auto inputs = uu.this_network.GetInputsInfo();
auto* non_const_prepm = const_cast<IEUnit::PreProcMap*>(&uu.preproc_map);
for (auto &&input_name : uu.params.input_names) {
auto ii = inputs.at(input_name);
const auto & mm = in_metas[idx++];
non_const_prepm->emplace(input_name, configurePreProcInfo(ii, mm));
}
}
// roi-list version is much easier at the moment.
@@ -1139,12 +1208,18 @@ struct InferList: public cv::detail::KernelTag {
return;
}
IE::Blob::Ptr this_blob = extractBlob(*ctx, 1);
// NB: This blob will be used to make roi from its, so
// it should be treated as image
IE::Blob::Ptr this_blob = extractBlob(*ctx, 1, cv::gapi::ie::TraitAs::IMAGE);
std::vector<std::vector<int>> cached_dims(ctx->uu.params.num_out);
for (auto i : ade::util::iota(ctx->uu.params.num_out)) {
const IE::DataPtr& ie_out = ctx->uu.outputs.at(ctx->uu.params.output_names[i]);
cached_dims[i] = toCV(ie_out->getTensorDesc().getDims());
const auto& out_name = ctx->uu.params.output_names[i];
const auto& desc =
ctx->uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load
? ctx->uu.net.getOutputsInfo().at(out_name)->getTensorDesc()
: ctx->uu.this_network.GetOutputsInfo().at(out_name)->getTensorDesc();
cached_dims[i] = toCV(desc.getDims());
// FIXME: Isn't this should be done automatically
// by some resetInternalData(), etc? (Probably at the GExecutor level)
auto& out_vec = ctx->outVecR<cv::Mat>(i);
@@ -1160,10 +1235,7 @@ struct InferList: public cv::detail::KernelTag {
cv::gimpl::ie::RequestPool::Task {
[ctx, rc, this_blob](InferenceEngine::InferRequest &req) {
IE::Blob::Ptr roi_blob = IE::make_shared_blob(this_blob, toIE(rc));
setBlob(req,
ctx->uu.params.kind,
ctx->uu.params.input_names[0u],
roi_blob);
setBlob(req, ctx->uu.params.input_names[0u], roi_blob, *ctx);
req.StartAsync();
},
std::bind(callback, std::placeholders::_1, pos)
@@ -1231,7 +1303,6 @@ struct InferList2: public cv::detail::KernelTag {
std::size_t idx = 1u;
for (auto &&input_name : uu.params.input_names) {
auto &ii = uu.inputs.at(input_name);
const auto &mm = in_metas[idx];
GAPI_Assert(util::holds_alternative<cv::GArrayDesc>(mm)
&& "Non-array inputs are not supported");
@@ -1241,6 +1312,7 @@ struct InferList2: public cv::detail::KernelTag {
// only in the loadNetwork case.
if (uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load) {
// This is a cv::Rect -- configure the IE preprocessing
auto ii = uu.net.getInputsInfo().at(input_name);
configureInputInfo(ii, mm_0);
if (uu.params.layer_names_to_reshape.find(input_name) !=
uu.params.layer_names_to_reshape.end()) {
@@ -1254,6 +1326,12 @@ struct InferList2: public cv::detail::KernelTag {
if (!input_reshape_table.empty()) {
const_cast<IE::CNNNetwork *>(&uu.net)->reshape(input_reshape_table);
}
} else {
GAPI_Assert(uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import);
auto inputs = uu.this_network.GetInputsInfo();
auto* non_const_prepm = const_cast<IEUnit::PreProcMap*>(&uu.preproc_map);
auto ii = inputs.at(input_name);
non_const_prepm->emplace(input_name, configurePreProcInfo(ii, mm_0));
}
} else {
// This is a cv::GMat (equals to: cv::Mat)
@@ -1276,7 +1354,9 @@ struct InferList2: public cv::detail::KernelTag {
cv::gimpl::ie::RequestPool &reqPool) {
GAPI_Assert(ctx->inArgs().size() > 1u
&& "This operation must have at least two arguments");
IE::Blob::Ptr blob_0 = extractBlob(*ctx, 0);
// NB: This blob will be used to make roi from its, so
// it should be treated as image
IE::Blob::Ptr blob_0 = extractBlob(*ctx, 0, cv::gapi::ie::TraitAs::IMAGE);
const auto list_size = ctx->inArg<cv::detail::VectorRef>(1u).size();
if (list_size == 0u) {
for (auto i : ade::util::iota(ctx->uu.params.num_out)) {
@@ -1289,8 +1369,12 @@ struct InferList2: public cv::detail::KernelTag {
// FIXME: This could be done ONCE at graph compile stage!
std::vector< std::vector<int> > cached_dims(ctx->uu.params.num_out);
for (auto i : ade::util::iota(ctx->uu.params.num_out)) {
const IE::DataPtr& ie_out = ctx->uu.outputs.at(ctx->uu.params.output_names[i]);
cached_dims[i] = toCV(ie_out->getTensorDesc().getDims());
const auto& out_name = ctx->uu.params.output_names[i];
const auto& desc =
ctx->uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load
? ctx->uu.net.getOutputsInfo().at(out_name)->getTensorDesc()
: ctx->uu.this_network.GetOutputsInfo().at(out_name)->getTensorDesc();
cached_dims[i] = toCV(desc.getDims());
// FIXME: Isn't this should be done automatically
// by some resetInternalData(), etc? (Probably at the GExecutor level)
auto& out_vec = ctx->outVecR<cv::Mat>(i);
@@ -1318,10 +1402,7 @@ struct InferList2: public cv::detail::KernelTag {
GAPI_Assert(false &&
"Only Rect and Mat types are supported for infer list 2!");
}
setBlob(req,
ctx->uu.params.kind,
ctx->uu.params.input_names[in_idx],
this_blob);
setBlob(req, ctx->uu.params.input_names[in_idx], this_blob, *ctx);
}
req.StartAsync();
},
@@ -1375,7 +1456,7 @@ namespace {
return EPtr{new cv::gimpl::ie::GIEExecutable(graph, nodes)};
}
virtual cv::gapi::GKernelPackage auxiliaryKernels() const override {
virtual cv::GKernelPackage auxiliaryKernels() const override {
return cv::gapi::kernels< cv::gimpl::ie::Infer
, cv::gimpl::ie::InferROI
, cv::gimpl::ie::InferList
@@ -1412,11 +1493,11 @@ std::vector<int> cv::gapi::ie::util::to_ocv(const IE::SizeVector &dims) {
return toCV(dims);
}
IE::Blob::Ptr cv::gapi::ie::util::to_ie(cv::Mat &blob) {
IE::Blob::Ptr cv::gapi::ie::util::to_ie(const cv::Mat &blob) {
return wrapIE(blob, cv::gapi::ie::TraitAs::IMAGE);
}
IE::Blob::Ptr cv::gapi::ie::util::to_ie(cv::Mat &y_plane, cv::Mat &uv_plane) {
IE::Blob::Ptr cv::gapi::ie::util::to_ie(const cv::Mat &y_plane, const cv::Mat &uv_plane) {
auto y_blob = wrapIE(y_plane, cv::gapi::ie::TraitAs::IMAGE);
auto uv_blob = wrapIE(uv_plane, cv::gapi::ie::TraitAs::IMAGE);
#if INF_ENGINE_RELEASE >= 2021010000
@@ -18,6 +18,8 @@
#include <opencv2/core/utility.hpp>
#include <opencv2/core/utils/logger.hpp>
#include <opencv2/core/utils/configuration.private.hpp>
namespace IE = InferenceEngine;
namespace giewrap = cv::gimpl::ie::wrap;
using GIEParam = cv::gapi::ie::detail::ParamDesc;
@@ -93,11 +95,38 @@ IE::InferencePlugin giewrap::getPlugin(const GIEParam& params) {
return plugin;
}
#else // >= 2019.R2
IE::Core giewrap::getCore() {
// NB: Some of IE plugins fail during IE::Core destroying in specific cases.
// Solution is allocate IE::Core in heap and doesn't destroy it, which cause
// leak, but fixes tests on CI. This behaviour is configurable by using
// OPENCV_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND=0
static IE::Core create_IE_Core_pointer() {
// NB: 'delete' is never called
static IE::Core* core = new IE::Core();
return *core;
}
static IE::Core create_IE_Core_instance() {
static IE::Core core;
return core;
}
IE::Core giewrap::getCore() {
// NB: to make happy memory leak tools use:
// - OPENCV_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND=0
static bool param_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND =
utils::getConfigurationParameterBool(
"OPENCV_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND",
#if defined(_WIN32) || defined(__APPLE__)
true
#else
false
#endif
);
return param_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND
? create_IE_Core_pointer() : create_IE_Core_instance();
}
IE::Core giewrap::getPlugin(const GIEParam& params) {
auto plugin = giewrap::getCore();
if (params.device_id == "CPU" || params.device_id == "FPGA")
@@ -34,13 +34,12 @@ using Plugin = IE::InferencePlugin;
GAPI_EXPORTS IE::InferencePlugin getPlugin(const GIEParam& params);
GAPI_EXPORTS inline IE::ExecutableNetwork loadNetwork( IE::InferencePlugin& plugin,
const IE::CNNNetwork& net,
const GIEParam&) {
return plugin.LoadNetwork(net, {}); // FIXME: 2nd parameter to be
// configurable via the API
const GIEParam& params) {
return plugin.LoadNetwork(net, params.config);
}
GAPI_EXPORTS inline IE::ExecutableNetwork importNetwork( IE::CNNNetwork& plugin,
const GIEParam& param) {
return plugin.ImportNetwork(param.model_path, param.device_id, {});
const GIEParam& params) {
return plugin.ImportNetwork(param.model_path, param.device_id, params.config);
}
#else // >= 2019.R2
using Plugin = IE::Core;
@@ -51,9 +50,9 @@ GAPI_EXPORTS inline IE::ExecutableNetwork loadNetwork( IE::Core& core
const GIEParam& params,
IE::RemoteContext::Ptr rctx = nullptr) {
if (rctx != nullptr) {
return core.LoadNetwork(net, rctx);
return core.LoadNetwork(net, rctx, params.config);
} else {
return core.LoadNetwork(net, params.device_id);
return core.LoadNetwork(net, params.device_id, params.config);
}
}
GAPI_EXPORTS inline IE::ExecutableNetwork importNetwork( IE::Core& core,
@@ -67,9 +66,9 @@ GAPI_EXPORTS inline IE::ExecutableNetwork importNetwork( IE::Core& core,
throw std::runtime_error("Could not open file");
}
std::istream graphBlob(&blobFile);
return core.ImportNetwork(graphBlob, rctx);
return core.ImportNetwork(graphBlob, rctx, params.config);
} else {
return core.ImportNetwork(params.model_path, params.device_id, {});
return core.ImportNetwork(params.model_path, params.device_id, params.config);
}
}
#endif // INF_ENGINE_RELEASE < 2019020000
+2 -2
View File
@@ -27,8 +27,8 @@ namespace util {
// test suite only.
GAPI_EXPORTS std::vector<int> to_ocv(const InferenceEngine::SizeVector &dims);
GAPI_EXPORTS cv::Mat to_ocv(InferenceEngine::Blob::Ptr blob);
GAPI_EXPORTS InferenceEngine::Blob::Ptr to_ie(cv::Mat &blob);
GAPI_EXPORTS InferenceEngine::Blob::Ptr to_ie(cv::Mat &y_plane, cv::Mat &uv_plane);
GAPI_EXPORTS InferenceEngine::Blob::Ptr to_ie(const cv::Mat &blob);
GAPI_EXPORTS InferenceEngine::Blob::Ptr to_ie(const cv::Mat &y_plane, const cv::Mat &uv_plane);
}}}}
+1 -10
View File
@@ -458,14 +458,6 @@ GAPI_OCL_KERNEL(GOCLMerge4, cv::gapi::core::GMerge4)
}
};
GAPI_OCL_KERNEL(GOCLResize, cv::gapi::core::GResize)
{
static void run(const cv::UMat& in, cv::Size sz, double fx, double fy, int interp, cv::UMat &out)
{
cv::resize(in, out, sz, fx, fy, interp);
}
};
GAPI_OCL_KERNEL(GOCLRemap, cv::gapi::core::GRemap)
{
static void run(const cv::UMat& in, const cv::Mat& x, const cv::Mat& y, int a, int b, cv::Scalar s, cv::UMat& out)
@@ -531,7 +523,7 @@ GAPI_OCL_KERNEL(GOCLTranspose, cv::gapi::core::GTranspose)
}
};
cv::gapi::GKernelPackage cv::gapi::core::ocl::kernels()
cv::GKernelPackage cv::gapi::core::ocl::kernels()
{
static auto pkg = cv::gapi::kernels
< GOCLAdd
@@ -585,7 +577,6 @@ cv::gapi::GKernelPackage cv::gapi::core::ocl::kernels()
, GOCLInRange
, GOCLSplit3
, GOCLSplit4
, GOCLResize
, GOCLMerge3
, GOCLMerge4
, GOCLRemap
@@ -11,6 +11,13 @@
#include <opencv2/gapi/ocl/imgproc.hpp>
#include "backends/ocl/goclimgproc.hpp"
GAPI_OCL_KERNEL(GOCLResize, cv::gapi::imgproc::GResize)
{
static void run(const cv::UMat& in, cv::Size sz, double fx, double fy, int interp, cv::UMat &out)
{
cv::resize(in, out, sz, fx, fy, interp);
}
};
GAPI_OCL_KERNEL(GOCLSepFilter, cv::gapi::imgproc::GSepFilter)
{
@@ -266,10 +273,11 @@ GAPI_OCL_KERNEL(GOCLRGB2GrayCustom, cv::gapi::imgproc::GRGB2GrayCustom)
};
cv::gapi::GKernelPackage cv::gapi::imgproc::ocl::kernels()
cv::GKernelPackage cv::gapi::imgproc::ocl::kernels()
{
static auto pkg = cv::gapi::kernels
< GOCLFilter2D
, GOCLResize
, GOCLSepFilter
, GOCLBoxFilter
, GOCLBlur
@@ -1147,7 +1147,7 @@ namespace {
return EPtr{new cv::gimpl::onnx::GONNXExecutable(graph, nodes)};
}
virtual cv::gapi::GKernelPackage auxiliaryKernels() const override {
virtual cv::GKernelPackage auxiliaryKernels() const override {
return cv::gapi::kernels< cv::gimpl::onnx::Infer
, cv::gimpl::onnx::InferROI
, cv::gimpl::onnx::InferList
@@ -47,7 +47,7 @@ GAPI_PLAIDML_LOGICAL_OP(GPlaidMLOr , cv::gapi::core::GOr , |)
GAPI_PLAIDML_ARITHMETIC_OP(GPlaidMLAdd, cv::gapi::core::GAdd, +);
GAPI_PLAIDML_ARITHMETIC_OP(GPlaidMLSub, cv::gapi::core::GSub, -);
cv::gapi::GKernelPackage cv::gapi::core::plaidml::kernels()
cv::GKernelPackage cv::gapi::core::plaidml::kernels()
{
static auto pkg = cv::gapi::kernels<GPlaidMLAdd, GPlaidMLSub, GPlaidMLAnd, GPlaidMLXor, GPlaidMLOr>();
return pkg;
@@ -55,7 +55,7 @@ cv::gapi::GKernelPackage cv::gapi::core::plaidml::kernels()
#else // HAVE_PLAIDML
cv::gapi::GKernelPackage cv::gapi::core::plaidml::kernels()
cv::GKernelPackage cv::gapi::core::plaidml::kernels()
{
// Still provide this symbol to avoid linking issues
util::throw_error(std::runtime_error("G-API has been compiled without PlaidML2 support"));
@@ -128,7 +128,7 @@ static void writeBack(cv::GRunArg& arg, cv::GRunArgP& out)
case cv::GRunArg::index_of<cv::Mat>():
{
auto& rmat = *cv::util::get<cv::RMat*>(out);
rmat = cv::make_rmat<cv::gimpl::RMatAdapter>(cv::util::get<cv::Mat>(arg));
rmat = cv::make_rmat<cv::gimpl::RMatOnMat>(cv::util::get<cv::Mat>(arg));
break;
}
case cv::GRunArg::index_of<cv::Scalar>():
+22 -18
View File
@@ -128,15 +128,12 @@ GAPI_OCV_KERNEL_ST(RenderFrameOCVImpl, cv::gapi::wip::draw::GRenderFrame, Render
out = in;
auto desc = out.desc();
auto w_out = out.access(cv::MediaFrame::Access::W);
cv::Mat upsample_uv, yuv;
{
auto r_in = in.access(cv::MediaFrame::Access::R);
auto out_y = cv::Mat(desc.size, CV_8UC1, w_out.ptr[0], w_out.stride[0]);
auto out_uv = cv::Mat(desc.size / 2, CV_8UC2, w_out.ptr[1], w_out.stride[1]);
auto r_in = in.access(cv::MediaFrame::Access::R);
auto in_y = cv::Mat(desc.size, CV_8UC1, r_in.ptr[0], r_in.stride[0]);
auto in_uv = cv::Mat(desc.size / 2, CV_8UC2, r_in.ptr[1], r_in.stride[1]);
auto in_y = cv::Mat(desc.size, CV_8UC1, r_in.ptr[0], r_in.stride[0]);
auto in_uv = cv::Mat(desc.size / 2, CV_8UC2, r_in.ptr[1], r_in.stride[1]);
/* FIXME How to render correctly on NV12 format ?
*
@@ -157,19 +154,26 @@ GAPI_OCV_KERNEL_ST(RenderFrameOCVImpl, cv::gapi::wip::draw::GRenderFrame, Render
*
*/
// NV12 -> YUV
cv::Mat upsample_uv, yuv;
cv::resize(in_uv, upsample_uv, in_uv.size() * 2, cv::INTER_LINEAR);
cv::merge(std::vector<cv::Mat>{in_y, upsample_uv}, yuv);
// NV12 -> YUV
cv::resize(in_uv, upsample_uv, in_uv.size() * 2, cv::INTER_LINEAR);
cv::merge(std::vector<cv::Mat>{in_y, upsample_uv}, yuv);
}
cv::gapi::wip::draw::drawPrimitivesOCVYUV(yuv, prims, state.ftpr);
// YUV -> NV12
cv::Mat out_u, out_v, uv_plane;
std::vector<cv::Mat> chs = { out_y, out_u, out_v };
cv::split(yuv, chs);
cv::merge(std::vector<cv::Mat>{chs[1], chs[2]}, uv_plane);
cv::resize(uv_plane, out_uv, uv_plane.size() / 2, cv::INTER_LINEAR);
{
auto w_out = out.access(cv::MediaFrame::Access::W);
auto out_y = cv::Mat(desc.size, CV_8UC1, w_out.ptr[0], w_out.stride[0]);
auto out_uv = cv::Mat(desc.size / 2, CV_8UC2, w_out.ptr[1], w_out.stride[1]);
cv::Mat out_u, out_v, uv_plane;
std::vector<cv::Mat> chs = { out_y, out_u, out_v };
cv::split(yuv, chs);
cv::merge(std::vector<cv::Mat>{chs[1], chs[2]}, uv_plane);
cv::resize(uv_plane, out_uv, uv_plane.size() / 2, cv::INTER_LINEAR);
}
}
static void setup(const cv::GFrameDesc& /* in_nv12 */,
@@ -189,7 +193,7 @@ GAPI_OCV_KERNEL_ST(RenderFrameOCVImpl, cv::gapi::wip::draw::GRenderFrame, Render
};
cv::gapi::GKernelPackage cv::gapi::render::ocv::kernels()
cv::GKernelPackage cv::gapi::render::ocv::kernels()
{
const static auto pkg = cv::gapi::kernels<RenderBGROCVImpl, RenderNV12OCVImpl, RenderFrameOCVImpl>();
return pkg;
@@ -193,7 +193,7 @@ void Copy::Actor::run(cv::gimpl::GIslandExecutable::IInput &in,
out.post(std::move(out_arg));
}
cv::gapi::GKernelPackage cv::gimpl::streaming::kernels()
cv::GKernelPackage cv::gimpl::streaming::kernels()
{
return cv::gapi::kernels<Copy>();
}
@@ -279,7 +279,7 @@ void GOCVBGR::Actor::extractRMat(const cv::MediaFrame& frame, cv::RMat& rmat)
cv::Mat y_plane (desc.size, CV_8UC1, view.ptr[0], view.stride[0]);
cv::Mat uv_plane(desc.size / 2, CV_8UC2, view.ptr[1], view.stride[1]);
cv::cvtColorTwoPlane(y_plane, uv_plane, bgr, cv::COLOR_YUV2BGR_NV12);
rmat = cv::make_rmat<cv::gimpl::RMatAdapter>(bgr);
rmat = cv::make_rmat<cv::gimpl::RMatOnMat>(bgr);
break;
}
default:
@@ -327,7 +327,7 @@ void GOCVY::Actor::extractRMat(const cv::MediaFrame& frame, cv::RMat& rmat)
cv::Mat tmp_bgr(desc.size, CV_8UC3, view.ptr[0], view.stride[0]);
cv::Mat yuv;
cvtColor(tmp_bgr, yuv, cv::COLOR_BGR2YUV_I420);
rmat = cv::make_rmat<cv::gimpl::RMatAdapter>(yuv.rowRange(0, desc.size.height));
rmat = cv::make_rmat<cv::gimpl::RMatOnMat>(yuv.rowRange(0, desc.size.height));
break;
}
case cv::MediaFormat::NV12:
@@ -396,7 +396,7 @@ void GOCVUV::Actor::extractRMat(const cv::MediaFrame& frame, cv::RMat& rmat)
yuv.rowRange(start + range_h, start + range_h * 2).reshape(0, dims)
};
cv::merge(uv_planes, uv);
rmat = cv::make_rmat<cv::gimpl::RMatAdapter>(uv);
rmat = cv::make_rmat<cv::gimpl::RMatOnMat>(uv);
break;
}
case cv::MediaFormat::NV12:
@@ -414,14 +414,14 @@ void GOCVUV::Actor::extractRMat(const cv::MediaFrame& frame, cv::RMat& rmat)
}
}
cv::gapi::GKernelPackage cv::gapi::streaming::kernels()
cv::GKernelPackage cv::gapi::streaming::kernels()
{
return cv::gapi::kernels<GOCVBGR, GOCVY, GOCVUV>();
}
#else
cv::gapi::GKernelPackage cv::gapi::streaming::kernels()
cv::GKernelPackage cv::gapi::streaming::kernels()
{
// Still provide this symbol to avoid linking issues
util::throw_error(std::runtime_error("cv::gapi::streaming::kernels() isn't supported in standalone"));
@@ -15,7 +15,7 @@ namespace cv {
namespace gimpl {
namespace streaming {
cv::gapi::GKernelPackage kernels();
cv::GKernelPackage kernels();
struct GCopy final : public cv::detail::NoTag
{
+21 -21
View File
@@ -53,18 +53,18 @@
namespace
{
cv::gapi::GKernelPackage getKernelPackage(cv::GCompileArgs &args)
cv::GKernelPackage getKernelPackage(cv::GCompileArgs &args)
{
auto withAuxKernels = [](const cv::gapi::GKernelPackage& pkg) {
cv::gapi::GKernelPackage aux_pkg;
auto withAuxKernels = [](const cv::GKernelPackage& pkg) {
cv::GKernelPackage aux_pkg;
for (const auto &b : pkg.backends()) {
aux_pkg = combine(aux_pkg, b.priv().auxiliaryKernels());
aux_pkg = cv::gapi::combine(aux_pkg, b.priv().auxiliaryKernels());
}
// Always include built-in meta<> and copy implementation
return combine(pkg,
aux_pkg,
cv::gimpl::meta::kernels(),
cv::gimpl::streaming::kernels());
return cv::gapi::combine(pkg,
aux_pkg,
cv::gimpl::meta::kernels(),
cv::gimpl::streaming::kernels());
};
auto has_use_only = cv::gapi::getCompileArg<cv::gapi::use_only>(args);
@@ -73,18 +73,18 @@ namespace
static auto ocv_pkg =
#if !defined(GAPI_STANDALONE)
combine(cv::gapi::core::cpu::kernels(),
cv::gapi::imgproc::cpu::kernels(),
cv::gapi::video::cpu::kernels(),
cv::gapi::render::ocv::kernels(),
cv::gapi::streaming::kernels());
cv::gapi::combine(cv::gapi::core::cpu::kernels(),
cv::gapi::imgproc::cpu::kernels(),
cv::gapi::video::cpu::kernels(),
cv::gapi::render::ocv::kernels(),
cv::gapi::streaming::kernels());
#else
cv::gapi::GKernelPackage();
cv::GKernelPackage();
#endif // !defined(GAPI_STANDALONE)
auto user_pkg = cv::gapi::getCompileArg<cv::gapi::GKernelPackage>(args);
auto user_pkg_with_aux = withAuxKernels(user_pkg.value_or(cv::gapi::GKernelPackage{}));
return combine(ocv_pkg, user_pkg_with_aux);
auto user_pkg = cv::gapi::getCompileArg<cv::GKernelPackage>(args);
auto user_pkg_with_aux = withAuxKernels(user_pkg.value_or(cv::GKernelPackage{}));
return cv::gapi::combine(ocv_pkg, user_pkg_with_aux);
}
cv::gapi::GNetPackage getNetworkPackage(cv::GCompileArgs &args)
@@ -110,8 +110,8 @@ namespace
}
template<typename C>
cv::gapi::GKernelPackage auxKernelsFrom(const C& c) {
cv::gapi::GKernelPackage result;
cv::GKernelPackage auxKernelsFrom(const C& c) {
cv::GKernelPackage result;
for (const auto &b : c) {
result = cv::gapi::combine(result, b.priv().auxiliaryKernels());
}
@@ -121,7 +121,7 @@ namespace
using adeGraphs = std::vector<std::unique_ptr<ade::Graph>>;
// Creates ADE graphs (patterns and substitutes) from pkg's transformations
void makeTransformationGraphs(const cv::gapi::GKernelPackage& pkg,
void makeTransformationGraphs(const cv::GKernelPackage& pkg,
adeGraphs& patterns,
adeGraphs& substitutes) {
const auto& transforms = pkg.get_transformations();
@@ -142,7 +142,7 @@ namespace
}
}
void checkTransformations(const cv::gapi::GKernelPackage& pkg,
void checkTransformations(const cv::GKernelPackage& pkg,
const adeGraphs& patterns,
const adeGraphs& substitutes) {
const auto& transforms = pkg.get_transformations();
+1 -1
View File
@@ -26,7 +26,7 @@ class GAPI_EXPORTS GCompiler
GCompileArgs m_args;
ade::ExecutionEngine m_e;
cv::gapi::GKernelPackage m_all_kernels;
cv::GKernelPackage m_all_kernels;
cv::gapi::GNetPackage m_all_networks;
// Patterns built from transformations
+1 -1
View File
@@ -140,7 +140,7 @@ public:
// FIXME: This thing will likely break stuff once we introduce
// "multi-source streaming", a better design needs to be proposed
// at that stage.
virtual void handleNewStream() {}; // do nothing here by default
virtual void handleNewStream() {} // do nothing here by default
// This method is called for every IslandExecutable when
// the stream-based execution is stopped.
+2 -2
View File
@@ -157,7 +157,7 @@ void cv::gimpl::passes::bindNetParams(ade::passes::PassContext &ctx,
// kernels, but if not, they are handled by the framework itself in
// its optimization/execution passes.
void cv::gimpl::passes::resolveKernels(ade::passes::PassContext &ctx,
const gapi::GKernelPackage &kernels)
const GKernelPackage &kernels)
{
std::unordered_set<cv::gapi::GBackend> active_backends;
@@ -220,7 +220,7 @@ void cv::gimpl::passes::resolveKernels(ade::passes::PassContext &ctx,
gr.metadata().set(ActiveBackends{active_backends});
}
void cv::gimpl::passes::expandKernels(ade::passes::PassContext &ctx, const gapi::GKernelPackage &kernels)
void cv::gimpl::passes::expandKernels(ade::passes::PassContext &ctx, const GKernelPackage &kernels)
{
GModel::Graph gr(ctx.graph);
+6 -6
View File
@@ -23,11 +23,11 @@ namespace ade {
}
}
namespace cv {
// Forward declarations - internal
namespace gapi {
namespace cv {
class GKernelPackage;
namespace gapi {
struct GNetPackage;
} // namespace gapi
@@ -52,20 +52,20 @@ void inferMeta(ade::passes::PassContext &ctx, bool meta_is_initialized);
void storeResultingMeta(ade::passes::PassContext &ctx);
void expandKernels(ade::passes::PassContext &ctx,
const gapi::GKernelPackage& kernels);
const GKernelPackage& kernels);
void bindNetParams(ade::passes::PassContext &ctx,
const gapi::GNetPackage &networks);
void resolveKernels(ade::passes::PassContext &ctx,
const gapi::GKernelPackage &kernels);
const GKernelPackage &kernels);
void fuseIslands(ade::passes::PassContext &ctx);
void syncIslandTags(ade::passes::PassContext &ctx);
void topoSortIslands(ade::passes::PassContext &ctx);
void applyTransformations(ade::passes::PassContext &ctx,
const gapi::GKernelPackage &pkg,
const GKernelPackage &pkg,
const std::vector<std::unique_ptr<ade::Graph>> &preGeneratedPatterns);
void addStreaming(ade::passes::PassContext &ctx);
@@ -99,7 +99,7 @@ bool tryToSubstitute(ade::Graph& main,
} // anonymous namespace
void applyTransformations(ade::passes::PassContext& ctx,
const gapi::GKernelPackage& pkg,
const GKernelPackage& pkg,
const std::vector<std::unique_ptr<ade::Graph>>& patterns)
{
const auto& transforms = pkg.get_transformations();

Some files were not shown because too many files have changed in this diff Show More