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:
+30
-19
@@ -41,6 +41,9 @@ if(MSVC)
|
||||
# and IE deprecated code warning C4996
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4503 /wd4996)
|
||||
endif()
|
||||
if(MSVC_VERSION LESS 1920) # MSVS 2015/2017
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702) # 'unreachable code'
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(GLOB gapi_ext_hdrs
|
||||
@@ -113,6 +116,8 @@ set(gapi_srcs
|
||||
src/compiler/passes/intrin.cpp
|
||||
|
||||
# Executor
|
||||
src/executor/gabstractexecutor.cpp
|
||||
src/executor/gabstractstreamingexecutor.cpp
|
||||
src/executor/gexecutor.cpp
|
||||
src/executor/gtbbexecutor.cpp
|
||||
src/executor/gstreamingexecutor.cpp
|
||||
@@ -176,6 +181,7 @@ set(gapi_srcs
|
||||
|
||||
# Python bridge
|
||||
src/backends/ie/bindings_ie.cpp
|
||||
src/backends/onnx/bindings_onnx.cpp
|
||||
src/backends/python/gpythonbackend.cpp
|
||||
|
||||
# OpenVPL Streaming source
|
||||
@@ -185,6 +191,7 @@ set(gapi_srcs
|
||||
src/streaming/onevpl/cfg_params.cpp
|
||||
src/streaming/onevpl/cfg_params_parser.cpp
|
||||
src/streaming/onevpl/utils.cpp
|
||||
src/streaming/onevpl/default.cpp
|
||||
src/streaming/onevpl/data_provider_interface_exception.cpp
|
||||
src/streaming/onevpl/accelerators/surface/base_frame_adapter.cpp
|
||||
src/streaming/onevpl/accelerators/surface/cpu_frame_adapter.cpp
|
||||
@@ -315,22 +322,23 @@ if(HAVE_GAPI_ONEVPL)
|
||||
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_ONEVPL)
|
||||
ocv_target_link_libraries(${the_module} PRIVATE ${VPL_IMPORTED_TARGETS})
|
||||
|
||||
if(HAVE_DIRECTX AND HAVE_D3D11)
|
||||
ocv_target_link_libraries(${the_module} PRIVATE d3d11 dxgi)
|
||||
endif()
|
||||
if(WIN32)
|
||||
ocv_target_link_libraries(${the_module} PRIVATE mf mfuuid mfplat shlwapi mfreadwrite)
|
||||
endif()
|
||||
if(HAVE_D3D11 AND HAVE_OPENCL)
|
||||
ocv_target_include_directories(${the_module} SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
if(WITH_VA)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindVA.cmake")
|
||||
if(VA_INCLUDE_DIR)
|
||||
ocv_target_include_directories(${the_module} SYSTEM PRIVATE ${VA_INCLUDE_DIR})
|
||||
ocv_target_include_directories(opencv_test_gapi SYSTEM PRIVATE ${VA_INCLUDE_DIR})
|
||||
ocv_target_link_libraries(${the_module} PRIVATE ${VA_LIBRARIES})
|
||||
ocv_target_link_libraries(opencv_test_gapi PRIVATE ${VA_LIBRARIES})
|
||||
endif()
|
||||
else(WITH_VA)
|
||||
message(FATAL_ERROR "libva not found: building HAVE_GAPI_ONEVPL without libVA support is impossible on UNIX systems")
|
||||
endif(WITH_VA)
|
||||
if(UNIX AND HAVE_VA)
|
||||
ocv_target_include_directories(${the_module} SYSTEM PRIVATE ${VA_INCLUDE_DIR})
|
||||
ocv_target_link_libraries(${the_module} PRIVATE ${VA_LIBRARIES})
|
||||
if(TARGET opencv_test_gapi)
|
||||
ocv_target_include_directories(opencv_test_gapi SYSTEM PRIVATE ${VA_INCLUDE_DIR})
|
||||
ocv_target_link_libraries(opencv_test_gapi PRIVATE ${VA_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -363,17 +371,20 @@ ocv_add_samples()
|
||||
|
||||
|
||||
# Required for sample with inference on host
|
||||
if(TARGET example_gapi_onevpl_infer_single_roi)
|
||||
if(TARGET example_gapi_onevpl_infer_with_advanced_device_selection)
|
||||
if(TARGET ocv.3rdparty.openvino AND OPENCV_GAPI_WITH_OPENVINO)
|
||||
ocv_target_link_libraries(example_gapi_onevpl_infer_single_roi PRIVATE ocv.3rdparty.openvino)
|
||||
ocv_target_link_libraries(example_gapi_onevpl_infer_with_advanced_device_selection PRIVATE ocv.3rdparty.openvino)
|
||||
endif()
|
||||
if(HAVE_DIRECTX AND HAVE_D3D11)
|
||||
ocv_target_link_libraries(example_gapi_onevpl_infer_with_advanced_device_selection PRIVATE d3d11 dxgi)
|
||||
endif()
|
||||
if(HAVE_D3D11 AND HAVE_OPENCL)
|
||||
ocv_target_include_directories(example_gapi_onevpl_infer_single_roi SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
|
||||
ocv_target_include_directories(example_gapi_onevpl_infer_with_advanced_device_selection SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
|
||||
endif()
|
||||
if(WITH_VA AND UNIX)
|
||||
message ("GAPI VPL samples with VAAPI")
|
||||
ocv_target_include_directories(example_gapi_onevpl_infer_single_roi SYSTEM PRIVATE ${VA_INCLUDE_DIR})
|
||||
ocv_target_link_libraries(example_gapi_onevpl_infer_single_roi PRIVATE ${VA_LIBRARIES})
|
||||
if(UNIX AND HAVE_VA)
|
||||
message(STATUS "GAPI VPL samples with VAAPI")
|
||||
ocv_target_include_directories(example_gapi_onevpl_infer_with_advanced_device_selection SYSTEM PRIVATE ${VA_INCLUDE_DIR})
|
||||
ocv_target_link_libraries(example_gapi_onevpl_infer_with_advanced_device_selection PRIVATE ${VA_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
set(ade_src_dir "${OpenCV_BINARY_DIR}/3rdparty/ade")
|
||||
set(ade_filename "v0.1.2.zip")
|
||||
set(ade_subdir "ade-0.1.2")
|
||||
set(ade_md5 "561c1e28ccf27ad0557a18e251c22226")
|
||||
set(ade_filename "v0.1.2a.zip")
|
||||
set(ade_subdir "ade-0.1.2a")
|
||||
set(ade_md5 "fa4b3e25167319cb0fa9432ef8281945")
|
||||
ocv_download(FILENAME ${ade_filename}
|
||||
HASH ${ade_md5}
|
||||
URL
|
||||
|
||||
@@ -635,7 +635,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
*/
|
||||
GAPI_EXPORTS_W GMat addC(const GMat& src1, const GScalar& c, int ddepth = -1);
|
||||
//! @overload
|
||||
GAPI_EXPORTS GMat addC(const GScalar& c, const GMat& src1, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat addC(const GScalar& c, const GMat& src1, int ddepth = -1);
|
||||
|
||||
/** @brief Calculates the per-element difference between two matrices.
|
||||
|
||||
@@ -660,7 +660,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param ddepth optional depth of the output matrix.
|
||||
@sa add, addC
|
||||
*/
|
||||
GAPI_EXPORTS GMat sub(const GMat& src1, const GMat& src2, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat sub(const GMat& src1, const GMat& src2, int ddepth = -1);
|
||||
|
||||
/** @brief Calculates the per-element difference between matrix and given scalar.
|
||||
|
||||
@@ -679,7 +679,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param ddepth optional depth of the output matrix.
|
||||
@sa add, addC, subRC
|
||||
*/
|
||||
GAPI_EXPORTS GMat subC(const GMat& src, const GScalar& c, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat subC(const GMat& src, const GScalar& c, int ddepth = -1);
|
||||
|
||||
/** @brief Calculates the per-element difference between given scalar and the matrix.
|
||||
|
||||
@@ -698,7 +698,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param ddepth optional depth of the output matrix.
|
||||
@sa add, addC, subC
|
||||
*/
|
||||
GAPI_EXPORTS GMat subRC(const GScalar& c, const GMat& src, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat subRC(const GScalar& c, const GMat& src, int ddepth = -1);
|
||||
|
||||
/** @brief Calculates the per-element scaled product of two matrices.
|
||||
|
||||
@@ -719,7 +719,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param ddepth optional depth of the output matrix.
|
||||
@sa add, sub, div, addWeighted
|
||||
*/
|
||||
GAPI_EXPORTS GMat mul(const GMat& src1, const GMat& src2, double scale = 1.0, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat mul(const GMat& src1, const GMat& src2, double scale = 1.0, int ddepth = -1);
|
||||
|
||||
/** @brief Multiplies matrix by scalar.
|
||||
|
||||
@@ -737,11 +737,11 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth.
|
||||
@sa add, sub, div, addWeighted
|
||||
*/
|
||||
GAPI_EXPORTS GMat mulC(const GMat& src, double multiplier, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat mulC(const GMat& src, double multiplier, int ddepth = -1);
|
||||
//! @overload
|
||||
GAPI_EXPORTS GMat mulC(const GMat& src, const GScalar& multiplier, int ddepth = -1); // FIXME: merge with mulc
|
||||
GAPI_EXPORTS_W GMat mulC(const GMat& src, const GScalar& multiplier, int ddepth = -1); // FIXME: merge with mulc
|
||||
//! @overload
|
||||
GAPI_EXPORTS GMat mulC(const GScalar& multiplier, const GMat& src, int ddepth = -1); // FIXME: merge with mulc
|
||||
GAPI_EXPORTS_W GMat mulC(const GScalar& multiplier, const GMat& src, int ddepth = -1); // FIXME: merge with mulc
|
||||
|
||||
/** @brief Performs per-element division of two matrices.
|
||||
|
||||
@@ -764,7 +764,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param ddepth optional depth of the output matrix; you can only pass -1 when src1.depth() == src2.depth().
|
||||
@sa mul, add, sub
|
||||
*/
|
||||
GAPI_EXPORTS GMat div(const GMat& src1, const GMat& src2, double scale, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat div(const GMat& src1, const GMat& src2, double scale, int ddepth = -1);
|
||||
|
||||
/** @brief Divides matrix by scalar.
|
||||
|
||||
@@ -785,7 +785,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param scale scale factor.
|
||||
@sa add, sub, div, addWeighted
|
||||
*/
|
||||
GAPI_EXPORTS GMat divC(const GMat& src, const GScalar& divisor, double scale, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat divC(const GMat& src, const GScalar& divisor, double scale, int ddepth = -1);
|
||||
|
||||
/** @brief Divides scalar by matrix.
|
||||
|
||||
@@ -806,7 +806,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param scale scale factor
|
||||
@sa add, sub, div, addWeighted
|
||||
*/
|
||||
GAPI_EXPORTS GMat divRC(const GScalar& divident, const GMat& src, double scale, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat divRC(const GScalar& divident, const GMat& src, double scale, int ddepth = -1);
|
||||
|
||||
/** @brief Applies a mask to a matrix.
|
||||
|
||||
@@ -819,7 +819,7 @@ Supported src matrix data types are @ref CV_8UC1, @ref CV_16SC1, @ref CV_16UC1.
|
||||
@param src input matrix.
|
||||
@param mask input mask matrix.
|
||||
*/
|
||||
GAPI_EXPORTS GMat mask(const GMat& src, const GMat& mask);
|
||||
GAPI_EXPORTS_W GMat mask(const GMat& src, const GMat& mask);
|
||||
|
||||
/** @brief Calculates an average (mean) of matrix elements.
|
||||
|
||||
@@ -854,8 +854,8 @@ Both output must have the same size and depth as input matrices.
|
||||
degrees, otherwise, they are measured in radians.
|
||||
@sa cartToPolar, exp, log, pow, sqrt
|
||||
*/
|
||||
GAPI_EXPORTS std::tuple<GMat, GMat> polarToCart(const GMat& magnitude, const GMat& angle,
|
||||
bool angleInDegrees = false);
|
||||
GAPI_EXPORTS_W std::tuple<GMat, GMat> polarToCart(const GMat& magnitude, const GMat& angle,
|
||||
bool angleInDegrees = false);
|
||||
|
||||
/** @brief Calculates the magnitude and angle of 2D vectors.
|
||||
|
||||
@@ -878,8 +878,8 @@ x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360
|
||||
in radians (which is by default), or in degrees.
|
||||
@sa polarToCart
|
||||
*/
|
||||
GAPI_EXPORTS std::tuple<GMat, GMat> cartToPolar(const GMat& x, const GMat& y,
|
||||
bool angleInDegrees = false);
|
||||
GAPI_EXPORTS_W std::tuple<GMat, GMat> cartToPolar(const GMat& x, const GMat& y,
|
||||
bool angleInDegrees = false);
|
||||
|
||||
/** @brief Calculates the rotation angle of 2D vectors.
|
||||
|
||||
@@ -896,7 +896,7 @@ same size and the same type as x.
|
||||
degrees, otherwise, they are measured in radians.
|
||||
@return array of vector angles; it has the same size and same type as x.
|
||||
*/
|
||||
GAPI_EXPORTS GMat phase(const GMat& x, const GMat &y, bool angleInDegrees = false);
|
||||
GAPI_EXPORTS_W GMat phase(const GMat& x, const GMat &y, bool angleInDegrees = false);
|
||||
|
||||
/** @brief Calculates a square root of array elements.
|
||||
|
||||
@@ -907,7 +907,7 @@ std::sqrt .
|
||||
@param src input floating-point array.
|
||||
@return output array of the same size and type as src.
|
||||
*/
|
||||
GAPI_EXPORTS GMat sqrt(const GMat &src);
|
||||
GAPI_EXPORTS_W GMat sqrt(const GMat &src);
|
||||
|
||||
//! @} gapi_math
|
||||
//!
|
||||
@@ -934,11 +934,11 @@ Supported input matrix data types are @ref CV_8UC1, @ref CV_16UC1, @ref CV_16SC1
|
||||
@param src2 second input matrix/scalar of the same depth as first input matrix.
|
||||
@sa min, max, threshold, cmpLE, cmpGE, cmpLT
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpGT(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat cmpGT(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGTScalar"
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpGT(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat cmpGT(const GMat& src1, const GScalar& src2);
|
||||
|
||||
/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are less than elements in second.
|
||||
|
||||
@@ -960,11 +960,11 @@ Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1,
|
||||
@param src2 second input matrix/scalar of the same depth as first input matrix.
|
||||
@sa min, max, threshold, cmpLE, cmpGE, cmpGT
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpLT(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat cmpLT(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLTScalar"
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpLT(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat cmpLT(const GMat& src1, const GScalar& src2);
|
||||
|
||||
/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are greater or equal compare to elements in second.
|
||||
|
||||
@@ -986,11 +986,11 @@ Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1,
|
||||
@param src2 second input matrix/scalar of the same depth as first input matrix.
|
||||
@sa min, max, threshold, cmpLE, cmpGT, cmpLT
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpGE(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat cmpGE(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLGEcalar"
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpGE(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat cmpGE(const GMat& src1, const GScalar& src2);
|
||||
|
||||
/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are less or equal compare to elements in second.
|
||||
|
||||
@@ -1012,11 +1012,11 @@ Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1,
|
||||
@param src2 second input matrix/scalar of the same depth as first input matrix.
|
||||
@sa min, max, threshold, cmpGT, cmpGE, cmpLT
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpLE(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat cmpLE(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLEScalar"
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpLE(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat cmpLE(const GMat& src1, const GScalar& src2);
|
||||
|
||||
/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are equal to elements in second.
|
||||
|
||||
@@ -1038,11 +1038,11 @@ Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1,
|
||||
@param src2 second input matrix/scalar of the same depth as first input matrix.
|
||||
@sa min, max, threshold, cmpNE
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpEQ(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat cmpEQ(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpEQScalar"
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpEQ(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat cmpEQ(const GMat& src1, const GScalar& src2);
|
||||
|
||||
/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are not equal to elements in second.
|
||||
|
||||
@@ -1064,11 +1064,11 @@ Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1,
|
||||
@param src2 second input matrix/scalar of the same depth as first input matrix.
|
||||
@sa min, max, threshold, cmpEQ
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpNE(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat cmpNE(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpNEScalar"
|
||||
*/
|
||||
GAPI_EXPORTS GMat cmpNE(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat cmpNE(const GMat& src1, const GScalar& src2);
|
||||
|
||||
/** @brief computes bitwise conjunction of the two matrixes (src1 & src2)
|
||||
Calculates the per-element bit-wise logical conjunction of two matrices of the same size.
|
||||
@@ -1086,13 +1086,13 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src1 first input matrix.
|
||||
@param src2 second input matrix.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bitwise_and(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat bitwise_and(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.bitwise_andS"
|
||||
@param src1 first input matrix.
|
||||
@param src2 scalar, which will be per-lemenetly conjuncted with elements of src1.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bitwise_and(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat bitwise_and(const GMat& src1, const GScalar& src2);
|
||||
|
||||
/** @brief computes bitwise disjunction of the two matrixes (src1 | src2)
|
||||
Calculates the per-element bit-wise logical disjunction of two matrices of the same size.
|
||||
@@ -1110,13 +1110,13 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src1 first input matrix.
|
||||
@param src2 second input matrix.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bitwise_or(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat bitwise_or(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.bitwise_orS"
|
||||
@param src1 first input matrix.
|
||||
@param src2 scalar, which will be per-lemenetly disjuncted with elements of src1.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bitwise_or(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat bitwise_or(const GMat& src1, const GScalar& src2);
|
||||
|
||||
|
||||
/** @brief computes bitwise logical "exclusive or" of the two matrixes (src1 ^ src2)
|
||||
@@ -1135,13 +1135,13 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src1 first input matrix.
|
||||
@param src2 second input matrix.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bitwise_xor(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat bitwise_xor(const GMat& src1, const GMat& src2);
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.pixelwise.bitwise_xorS"
|
||||
@param src1 first input matrix.
|
||||
@param src2 scalar, for which per-lemenet "logical or" operation on elements of src1 will be performed.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bitwise_xor(const GMat& src1, const GScalar& src2);
|
||||
GAPI_EXPORTS_W GMat bitwise_xor(const GMat& src1, const GScalar& src2);
|
||||
|
||||
|
||||
/** @brief Inverts every bit of an array.
|
||||
@@ -1162,7 +1162,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
|
||||
@param src input matrix.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bitwise_not(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat bitwise_not(const GMat& src);
|
||||
|
||||
/** @brief Select values from either first or second of input matrices by given mask.
|
||||
The function set to the output matrix either the value from the first input matrix if corresponding value of mask matrix is 255,
|
||||
@@ -1178,7 +1178,7 @@ Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1,
|
||||
@param src2 second input matrix.
|
||||
@param mask mask input matrix.
|
||||
*/
|
||||
GAPI_EXPORTS GMat select(const GMat& src1, const GMat& src2, const GMat& mask);
|
||||
GAPI_EXPORTS_W GMat select(const GMat& src1, const GMat& src2, const GMat& mask);
|
||||
|
||||
//! @} gapi_pixelwise
|
||||
|
||||
@@ -1200,7 +1200,7 @@ Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1,
|
||||
@param src2 second input matrix of the same size and depth as src1.
|
||||
@sa max, cmpEQ, cmpLT, cmpLE
|
||||
*/
|
||||
GAPI_EXPORTS GMat min(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat min(const GMat& src1, const GMat& src2);
|
||||
|
||||
/** @brief Calculates per-element maximum of two matrices.
|
||||
|
||||
@@ -1217,7 +1217,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src2 second input matrix of the same size and depth as src1.
|
||||
@sa min, compare, cmpEQ, cmpGT, cmpGE
|
||||
*/
|
||||
GAPI_EXPORTS GMat max(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat max(const GMat& src1, const GMat& src2);
|
||||
|
||||
/** @brief Calculates the per-element absolute difference between two matrices.
|
||||
|
||||
@@ -1234,7 +1234,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src2 second input matrix.
|
||||
@sa abs
|
||||
*/
|
||||
GAPI_EXPORTS GMat absDiff(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat absDiff(const GMat& src1, const GMat& src2);
|
||||
|
||||
/** @brief Calculates absolute value of matrix elements.
|
||||
|
||||
@@ -1251,7 +1251,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param c scalar to be subtracted.
|
||||
@sa min, max
|
||||
*/
|
||||
GAPI_EXPORTS GMat absDiffC(const GMat& src, const GScalar& c);
|
||||
GAPI_EXPORTS_W GMat absDiffC(const GMat& src, const GScalar& c);
|
||||
|
||||
/** @brief Calculates sum of all matrix elements.
|
||||
|
||||
@@ -1263,7 +1263,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src input matrix.
|
||||
@sa countNonZero, mean, min, max
|
||||
*/
|
||||
GAPI_EXPORTS GScalar sum(const GMat& src);
|
||||
GAPI_EXPORTS_W GScalar sum(const GMat& src);
|
||||
|
||||
/** @brief Counts non-zero array elements.
|
||||
|
||||
@@ -1276,7 +1276,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_16UC1, @ref CV_16SC1, @ref
|
||||
@param src input single-channel matrix.
|
||||
@sa mean, min, max
|
||||
*/
|
||||
GAPI_EXPORTS GOpaque<int> countNonZero(const GMat& src);
|
||||
GAPI_EXPORTS_W GOpaque<int> countNonZero(const GMat& src);
|
||||
|
||||
/** @brief Calculates the weighted sum of two matrices.
|
||||
|
||||
@@ -1299,7 +1299,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param ddepth optional depth of the output matrix.
|
||||
@sa add, sub
|
||||
*/
|
||||
GAPI_EXPORTS GMat addWeighted(const GMat& src1, double alpha, const GMat& src2, double beta, double gamma, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat addWeighted(const GMat& src1, double alpha, const GMat& src2, double beta, double gamma, int ddepth = -1);
|
||||
|
||||
/** @brief Calculates the absolute L1 norm of a matrix.
|
||||
|
||||
@@ -1322,7 +1322,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src input matrix.
|
||||
@sa normL2, normInf
|
||||
*/
|
||||
GAPI_EXPORTS GScalar normL1(const GMat& src);
|
||||
GAPI_EXPORTS_W GScalar normL1(const GMat& src);
|
||||
|
||||
/** @brief Calculates the absolute L2 norm of a matrix.
|
||||
|
||||
@@ -1344,7 +1344,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src input matrix.
|
||||
@sa normL1, normInf
|
||||
*/
|
||||
GAPI_EXPORTS GScalar normL2(const GMat& src);
|
||||
GAPI_EXPORTS_W GScalar normL2(const GMat& src);
|
||||
|
||||
/** @brief Calculates the absolute infinite norm of a matrix.
|
||||
|
||||
@@ -1367,7 +1367,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src input matrix.
|
||||
@sa normL1, normL2
|
||||
*/
|
||||
GAPI_EXPORTS GScalar normInf(const GMat& src);
|
||||
GAPI_EXPORTS_W GScalar normInf(const GMat& src);
|
||||
|
||||
/** @brief Calculates the integral of an image.
|
||||
|
||||
@@ -1387,7 +1387,7 @@ The function return integral image as \f$(W+1)\times (H+1)\f$ , 32-bit integer o
|
||||
CV_64F.
|
||||
@param sqdepth desired depth of the integral image of squared pixel values, CV_32F or CV_64F.
|
||||
*/
|
||||
GAPI_EXPORTS std::tuple<GMat, GMat> integral(const GMat& src, int sdepth = -1, int sqdepth = -1);
|
||||
GAPI_EXPORTS_W std::tuple<GMat, GMat> integral(const GMat& src, int sdepth = -1, int sqdepth = -1);
|
||||
|
||||
/** @brief Applies a fixed-level threshold to each matrix element.
|
||||
|
||||
@@ -1416,7 +1416,7 @@ types.
|
||||
|
||||
@sa min, max, cmpGT, cmpLE, cmpGE, cmpLT
|
||||
*/
|
||||
GAPI_EXPORTS GMat threshold(const GMat& src, const GScalar& thresh, const GScalar& maxval, int type);
|
||||
GAPI_EXPORTS_W GMat threshold(const GMat& src, const GScalar& thresh, const GScalar& maxval, int type);
|
||||
/** @overload
|
||||
This function applicable for all threshold types except cv::THRESH_OTSU and cv::THRESH_TRIANGLE
|
||||
@note Function textual ID is "org.opencv.core.matrixop.thresholdOT"
|
||||
@@ -1438,7 +1438,7 @@ Input and output matrices must be CV_8UC1.
|
||||
|
||||
@sa threshold
|
||||
*/
|
||||
GAPI_EXPORTS GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp);
|
||||
GAPI_EXPORTS_W GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp);
|
||||
|
||||
//! @} gapi_matrixop
|
||||
|
||||
@@ -1462,7 +1462,7 @@ The function split4 does the reverse operation.
|
||||
@param src4 fourth input @ref CV_8UC1 matrix to be merged.
|
||||
@sa merge3, split4, split3
|
||||
*/
|
||||
GAPI_EXPORTS GMat merge4(const GMat& src1, const GMat& src2, const GMat& src3, const GMat& src4);
|
||||
GAPI_EXPORTS_W GMat merge4(const GMat& src1, const GMat& src2, const GMat& src3, const GMat& src4);
|
||||
|
||||
/** @brief Creates one 3-channel matrix out of 3 single-channel ones.
|
||||
|
||||
@@ -1481,7 +1481,7 @@ The function split3 does the reverse operation.
|
||||
@param src3 third input @ref CV_8UC1 matrix to be merged.
|
||||
@sa merge4, split4, split3
|
||||
*/
|
||||
GAPI_EXPORTS GMat merge3(const GMat& src1, const GMat& src2, const GMat& src3);
|
||||
GAPI_EXPORTS_W GMat merge3(const GMat& src1, const GMat& src2, const GMat& src3);
|
||||
|
||||
/** @brief Divides a 4-channel matrix into 4 single-channel matrices.
|
||||
|
||||
@@ -1498,7 +1498,7 @@ The function merge4 does the reverse operation.
|
||||
@param src input @ref CV_8UC4 matrix.
|
||||
@sa split3, merge3, merge4
|
||||
*/
|
||||
GAPI_EXPORTS std::tuple<GMat, GMat, GMat,GMat> split4(const GMat& src);
|
||||
GAPI_EXPORTS_W std::tuple<GMat, GMat, GMat,GMat> split4(const GMat& src);
|
||||
|
||||
/** @brief Divides a 3-channel matrix into 3 single-channel matrices.
|
||||
|
||||
@@ -1548,9 +1548,9 @@ borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image
|
||||
corresponds to the "outliers" in the source image are not modified by the function.
|
||||
@param borderValue Value used in case of a constant border. By default, it is 0.
|
||||
*/
|
||||
GAPI_EXPORTS GMat remap(const GMat& src, const Mat& map1, const Mat& map2,
|
||||
int interpolation, int borderMode = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = Scalar());
|
||||
GAPI_EXPORTS_W GMat remap(const GMat& src, const Mat& map1, const Mat& map2,
|
||||
int interpolation, int borderMode = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = Scalar());
|
||||
|
||||
/** @brief Flips a 2D matrix around vertical, horizontal, or both axes.
|
||||
|
||||
@@ -1587,7 +1587,7 @@ flipping around y-axis. Negative value (for example, -1) means flipping
|
||||
around both axes.
|
||||
@sa remap
|
||||
*/
|
||||
GAPI_EXPORTS GMat flip(const GMat& src, int flipCode);
|
||||
GAPI_EXPORTS_W GMat flip(const GMat& src, int flipCode);
|
||||
|
||||
/** @brief Crops a 2D matrix.
|
||||
|
||||
@@ -1601,7 +1601,7 @@ Output matrix must be of the same depth as input one, size is specified by given
|
||||
@param rect a rect to crop a matrix to
|
||||
@sa resize
|
||||
*/
|
||||
GAPI_EXPORTS GMat crop(const GMat& src, const Rect& rect);
|
||||
GAPI_EXPORTS_W GMat crop(const GMat& src, const Rect& rect);
|
||||
|
||||
/** @brief Applies horizontal concatenation to given matrices.
|
||||
|
||||
@@ -1629,7 +1629,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src2 second input matrix to be considered for horizontal concatenation.
|
||||
@sa concatVert
|
||||
*/
|
||||
GAPI_EXPORTS GMat concatHor(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat concatHor(const GMat& src1, const GMat& src2);
|
||||
|
||||
/** @overload
|
||||
The function horizontally concatenates given number of GMat matrices (with the same number of columns).
|
||||
@@ -1637,7 +1637,7 @@ Output matrix must the same number of columns and depth as the input matrices, a
|
||||
|
||||
@param v vector of input matrices to be concatenated horizontally.
|
||||
*/
|
||||
GAPI_EXPORTS GMat concatHor(const std::vector<GMat> &v);
|
||||
GAPI_EXPORTS_W GMat concatHor(const std::vector<GMat> &v);
|
||||
|
||||
/** @brief Applies vertical concatenation to given matrices.
|
||||
|
||||
@@ -1669,7 +1669,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@param src2 second input matrix to be considered for vertical concatenation.
|
||||
@sa concatHor
|
||||
*/
|
||||
GAPI_EXPORTS GMat concatVert(const GMat& src1, const GMat& src2);
|
||||
GAPI_EXPORTS_W GMat concatVert(const GMat& src1, const GMat& src2);
|
||||
|
||||
/** @overload
|
||||
The function vertically concatenates given number of GMat matrices (with the same number of columns).
|
||||
@@ -1677,7 +1677,7 @@ Output matrix must the same number of columns and depth as the input matrices, a
|
||||
|
||||
@param v vector of input matrices to be concatenated vertically.
|
||||
*/
|
||||
GAPI_EXPORTS GMat concatVert(const std::vector<GMat> &v);
|
||||
GAPI_EXPORTS_W GMat concatVert(const std::vector<GMat> &v);
|
||||
|
||||
|
||||
/** @brief Performs a look-up table transform of a matrix.
|
||||
@@ -1696,7 +1696,7 @@ Output is a matrix of the same size and number of channels as src, and the same
|
||||
either have a single channel (in this case the same table is used for all channels) or the same
|
||||
number of channels as in the input matrix.
|
||||
*/
|
||||
GAPI_EXPORTS GMat LUT(const GMat& src, const Mat& lut);
|
||||
GAPI_EXPORTS_W GMat LUT(const GMat& src, const Mat& lut);
|
||||
|
||||
/** @brief Converts a matrix to another data depth with optional scaling.
|
||||
|
||||
@@ -1713,7 +1713,7 @@ same as the input has; if rdepth is negative, the output matrix will have the sa
|
||||
@param alpha optional scale factor.
|
||||
@param beta optional delta added to the scaled values.
|
||||
*/
|
||||
GAPI_EXPORTS GMat convertTo(const GMat& src, int rdepth, double alpha=1, double beta=0);
|
||||
GAPI_EXPORTS_W GMat convertTo(const GMat& src, int rdepth, double alpha=1, double beta=0);
|
||||
|
||||
/** @brief Normalizes the norm or value range of an array.
|
||||
|
||||
@@ -1735,8 +1735,8 @@ normalization.
|
||||
number of channels as src and the depth =ddepth.
|
||||
@sa norm, Mat::convertTo
|
||||
*/
|
||||
GAPI_EXPORTS GMat normalize(const GMat& src, double alpha, double beta,
|
||||
int norm_type, int ddepth = -1);
|
||||
GAPI_EXPORTS_W GMat normalize(const GMat& src, double alpha, double beta,
|
||||
int norm_type, int ddepth = -1);
|
||||
|
||||
/** @brief Applies a perspective transformation to an image.
|
||||
|
||||
@@ -1759,8 +1759,8 @@ optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation (
|
||||
|
||||
@sa warpAffine, resize, remap, getRectSubPix, perspectiveTransform
|
||||
*/
|
||||
GAPI_EXPORTS GMat warpPerspective(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR,
|
||||
int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar());
|
||||
GAPI_EXPORTS_W GMat warpPerspective(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR,
|
||||
int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar());
|
||||
|
||||
/** @brief Applies an affine transformation to an image.
|
||||
|
||||
@@ -1784,8 +1784,8 @@ borderMode=#BORDER_TRANSPARENT isn't supported
|
||||
|
||||
@sa warpPerspective, resize, remap, getRectSubPix, transform
|
||||
*/
|
||||
GAPI_EXPORTS GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR,
|
||||
int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar());
|
||||
GAPI_EXPORTS_W GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR,
|
||||
int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar());
|
||||
//! @} gapi_transform
|
||||
|
||||
/** @brief Finds centers of clusters and groups input samples around the clusters.
|
||||
@@ -1834,7 +1834,7 @@ compactness value are returned by the function.
|
||||
- Integer array that stores the cluster indices for every sample.
|
||||
- Array of the cluster centers.
|
||||
*/
|
||||
GAPI_EXPORTS std::tuple<GOpaque<double>,GMat,GMat>
|
||||
GAPI_EXPORTS_W std::tuple<GOpaque<double>,GMat,GMat>
|
||||
kmeans(const GMat& data, const int K, const GMat& bestLabels,
|
||||
const TermCriteria& criteria, const int attempts, const KmeansFlags flags);
|
||||
|
||||
@@ -1857,7 +1857,7 @@ kmeans(const GArray<Point2f>& data, const int K, const GArray<int>& bestLabels,
|
||||
/** @overload
|
||||
@note Function textual ID is "org.opencv.core.kmeans3D"
|
||||
*/
|
||||
GAPI_EXPORTS std::tuple<GOpaque<double>,GArray<int>,GArray<Point3f>>
|
||||
GAPI_EXPORTS_W std::tuple<GOpaque<double>,GArray<int>,GArray<Point3f>>
|
||||
kmeans(const GArray<Point3f>& data, const int K, const GArray<int>& bestLabels,
|
||||
const TermCriteria& criteria, const int attempts, const KmeansFlags flags);
|
||||
|
||||
@@ -1873,7 +1873,7 @@ The function transposes the matrix:
|
||||
|
||||
@param src input array.
|
||||
*/
|
||||
GAPI_EXPORTS GMat transpose(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat transpose(const GMat& src);
|
||||
|
||||
|
||||
namespace streaming {
|
||||
@@ -1903,7 +1903,7 @@ GAPI_EXPORTS_W GOpaque<Size> size(const GOpaque<Rect>& r);
|
||||
@param src Input frame
|
||||
@return Size (frame dimensions).
|
||||
*/
|
||||
GAPI_EXPORTS GOpaque<Size> size(const GFrame& src);
|
||||
GAPI_EXPORTS_W GOpaque<Size> size(const GFrame& src);
|
||||
} //namespace streaming
|
||||
} //namespace gapi
|
||||
} //namespace cv
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#ifndef OPENCV_GAPI_GCPUKERNEL_HPP
|
||||
#define OPENCV_GAPI_GCPUKERNEL_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4702) // "Unreachable code"
|
||||
// on postprocess(...) call inside OCVCallHelper
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4702) // "Unreachable code" on postprocess(...) call inside OCVCallHelper
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
@@ -535,4 +535,8 @@ gapi::cpu::GOCVFunctor gapi::cpu::ocv_kernel(const Callable& c)
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // OPENCV_GAPI_GCPUKERNEL_HPP
|
||||
|
||||
@@ -248,11 +248,11 @@ struct scratch_helper<false, Impl, Ins...>
|
||||
const cv::GArgs &,
|
||||
gapi::fluid::Buffer &)
|
||||
{
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
static void help_reset(gapi::fluid::Buffer &)
|
||||
{
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace detail
|
||||
{
|
||||
util::get<rw_own_t>(m_ref).clear();
|
||||
}
|
||||
else GAPI_Assert(false); // shouldn't be called in *EXT modes
|
||||
else GAPI_Error("InternalError"); // shouldn't be called in *EXT modes
|
||||
}
|
||||
|
||||
// Obtain a WRITE reference to underlying object
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace detail
|
||||
CV_STRING, // std::string user G-API data
|
||||
CV_POINT, // cv::Point user G-API data
|
||||
CV_POINT2F, // cv::Point2f user G-API data
|
||||
CV_POINT3F, // cv::Point3f user G-API data
|
||||
CV_SIZE, // cv::Size user G-API data
|
||||
CV_RECT, // cv::Rect user G-API data
|
||||
CV_SCALAR, // cv::Scalar user G-API data
|
||||
@@ -72,16 +73,17 @@ namespace detail
|
||||
template<> struct GOpaqueTraits<cv::Scalar> { static constexpr const OpaqueKind kind = OpaqueKind::CV_SCALAR; };
|
||||
template<> struct GOpaqueTraits<cv::Point> { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT; };
|
||||
template<> struct GOpaqueTraits<cv::Point2f> { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT2F; };
|
||||
template<> struct GOpaqueTraits<cv::Point3f> { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT3F; };
|
||||
template<> struct GOpaqueTraits<cv::Mat> { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; };
|
||||
template<> struct GOpaqueTraits<cv::Rect> { static constexpr const OpaqueKind kind = OpaqueKind::CV_RECT; };
|
||||
template<> struct GOpaqueTraits<cv::GMat> { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; };
|
||||
template<> struct GOpaqueTraits<cv::gapi::wip::draw::Prim>
|
||||
{ static constexpr const OpaqueKind kind = OpaqueKind::CV_DRAW_PRIM; };
|
||||
using GOpaqueTraitsArrayTypes = std::tuple<int, double, float, uint64_t, bool, std::string, cv::Size, cv::Scalar, cv::Point, cv::Point2f,
|
||||
cv::Mat, cv::Rect, cv::gapi::wip::draw::Prim>;
|
||||
cv::Point3f, cv::Mat, cv::Rect, cv::gapi::wip::draw::Prim>;
|
||||
// GOpaque is not supporting cv::Mat and cv::Scalar since there are GScalar and GMat types
|
||||
using GOpaqueTraitsOpaqueTypes = std::tuple<int, double, float, uint64_t, bool, std::string, cv::Size, cv::Point, cv::Point2f, cv::Rect,
|
||||
cv::gapi::wip::draw::Prim>;
|
||||
using GOpaqueTraitsOpaqueTypes = std::tuple<int, double, float, uint64_t, bool, std::string, cv::Size, cv::Point, cv::Point2f, cv::Point3f,
|
||||
cv::Rect, cv::gapi::wip::draw::Prim>;
|
||||
} // namespace detail
|
||||
|
||||
// This definition is here because it is reused by both public(?) and internal
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace detail
|
||||
{
|
||||
util::get<rw_own_t>(m_ref) = {};
|
||||
}
|
||||
else GAPI_Assert(false); // shouldn't be called in *EXT modes
|
||||
else GAPI_Error("InternalError"); // shouldn't be called in *EXT modes
|
||||
}
|
||||
|
||||
// Obtain a WRITE reference to underlying object
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
*
|
||||
* @param s a cv::Scalar value to associate with this GScalar object.
|
||||
*/
|
||||
GAPI_WRAP
|
||||
explicit GScalar(const cv::Scalar& s);
|
||||
|
||||
/**
|
||||
|
||||
@@ -556,9 +556,9 @@ is at the kernel center.
|
||||
@param borderValue border value in case of constant border type
|
||||
@sa boxFilter, gaussianBlur, medianBlur
|
||||
*/
|
||||
GAPI_EXPORTS GMat sepFilter(const GMat& src, int ddepth, const Mat& kernelX, const Mat& kernelY, const Point& anchor /*FIXME: = Point(-1,-1)*/,
|
||||
const Scalar& delta /*FIXME = GScalar(0)*/, int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
GAPI_EXPORTS_W GMat sepFilter(const GMat& src, int ddepth, const Mat& kernelX, const Mat& kernelY, const Point& anchor /*FIXME: = Point(-1,-1)*/,
|
||||
const Scalar& delta /*FIXME = GScalar(0)*/, int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
|
||||
/** @brief Convolves an image with the kernel.
|
||||
|
||||
@@ -593,8 +593,8 @@ is at the kernel center.
|
||||
@param borderValue border value in case of constant border type
|
||||
@sa sepFilter
|
||||
*/
|
||||
GAPI_EXPORTS GMat filter2D(const GMat& src, int ddepth, const Mat& kernel, const Point& anchor = Point(-1,-1), const Scalar& delta = Scalar(0),
|
||||
int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
|
||||
GAPI_EXPORTS_W GMat filter2D(const GMat& src, int ddepth, const Mat& kernel, const Point& anchor = Point(-1,-1), const Scalar& delta = Scalar(0),
|
||||
int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
|
||||
|
||||
|
||||
/** @brief Blurs an image using the box filter.
|
||||
@@ -627,9 +627,9 @@ is at the kernel center.
|
||||
@param borderValue border value in case of constant border type
|
||||
@sa sepFilter, gaussianBlur, medianBlur, integral
|
||||
*/
|
||||
GAPI_EXPORTS GMat boxFilter(const GMat& src, int dtype, const Size& ksize, const Point& anchor = Point(-1,-1),
|
||||
bool normalize = true, int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
GAPI_EXPORTS_W GMat boxFilter(const GMat& src, int dtype, const Size& ksize, const Point& anchor = Point(-1,-1),
|
||||
bool normalize = true, int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
|
||||
/** @brief Blurs an image using the normalized box filter.
|
||||
|
||||
@@ -654,8 +654,8 @@ center.
|
||||
@param borderValue border value in case of constant border type
|
||||
@sa boxFilter, bilateralFilter, GaussianBlur, medianBlur
|
||||
*/
|
||||
GAPI_EXPORTS GMat blur(const GMat& src, const Size& ksize, const Point& anchor = Point(-1,-1),
|
||||
int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
|
||||
GAPI_EXPORTS_W GMat blur(const GMat& src, const Size& ksize, const Point& anchor = Point(-1,-1),
|
||||
int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
|
||||
|
||||
|
||||
//GAPI_EXPORTS_W void blur( InputArray src, OutputArray dst,
|
||||
@@ -687,8 +687,8 @@ sigmaX, and sigmaY.
|
||||
@param borderValue border value in case of constant border type
|
||||
@sa sepFilter, boxFilter, medianBlur
|
||||
*/
|
||||
GAPI_EXPORTS GMat gaussianBlur(const GMat& src, const Size& ksize, double sigmaX, double sigmaY = 0,
|
||||
int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
|
||||
GAPI_EXPORTS_W GMat gaussianBlur(const GMat& src, const Size& ksize, double sigmaX, double sigmaY = 0,
|
||||
int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
|
||||
|
||||
/** @brief Blurs an image using the median filter.
|
||||
|
||||
@@ -730,9 +730,9 @@ anchor is at the element center.
|
||||
@param borderValue border value in case of a constant border
|
||||
@sa dilate, morphologyEx
|
||||
*/
|
||||
GAPI_EXPORTS GMat erode(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1,
|
||||
int borderType = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = morphologyDefaultBorderValue());
|
||||
GAPI_EXPORTS_W GMat erode(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1,
|
||||
int borderType = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = morphologyDefaultBorderValue());
|
||||
|
||||
/** @brief Erodes an image by using 3 by 3 rectangular structuring element.
|
||||
|
||||
@@ -750,9 +750,9 @@ Output image must have the same type, size, and number of channels as the input
|
||||
@param borderValue border value in case of a constant border
|
||||
@sa erode, dilate3x3
|
||||
*/
|
||||
GAPI_EXPORTS GMat erode3x3(const GMat& src, int iterations = 1,
|
||||
int borderType = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = morphologyDefaultBorderValue());
|
||||
GAPI_EXPORTS_W GMat erode3x3(const GMat& src, int iterations = 1,
|
||||
int borderType = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = morphologyDefaultBorderValue());
|
||||
|
||||
/** @brief Dilates an image by using a specific structuring element.
|
||||
|
||||
@@ -777,9 +777,9 @@ anchor is at the element center.
|
||||
@param borderValue border value in case of a constant border
|
||||
@sa erode, morphologyEx, getStructuringElement
|
||||
*/
|
||||
GAPI_EXPORTS GMat dilate(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1,
|
||||
int borderType = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = morphologyDefaultBorderValue());
|
||||
GAPI_EXPORTS_W GMat dilate(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1,
|
||||
int borderType = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = morphologyDefaultBorderValue());
|
||||
|
||||
/** @brief Dilates an image by using 3 by 3 rectangular structuring element.
|
||||
|
||||
@@ -801,9 +801,9 @@ Output image must have the same type, size, and number of channels as the input
|
||||
@sa dilate, erode3x3
|
||||
*/
|
||||
|
||||
GAPI_EXPORTS GMat dilate3x3(const GMat& src, int iterations = 1,
|
||||
int borderType = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = morphologyDefaultBorderValue());
|
||||
GAPI_EXPORTS_W GMat dilate3x3(const GMat& src, int iterations = 1,
|
||||
int borderType = BORDER_CONSTANT,
|
||||
const Scalar& borderValue = morphologyDefaultBorderValue());
|
||||
|
||||
/** @brief Performs advanced morphological transformations.
|
||||
|
||||
@@ -831,11 +831,11 @@ the kernel center.
|
||||
meaning.
|
||||
@sa dilate, erode, getStructuringElement
|
||||
*/
|
||||
GAPI_EXPORTS GMat morphologyEx(const GMat &src, const MorphTypes op, const Mat &kernel,
|
||||
const Point &anchor = Point(-1,-1),
|
||||
const int iterations = 1,
|
||||
const BorderTypes borderType = BORDER_CONSTANT,
|
||||
const Scalar &borderValue = morphologyDefaultBorderValue());
|
||||
GAPI_EXPORTS_W GMat morphologyEx(const GMat &src, const MorphTypes op, const Mat &kernel,
|
||||
const Point &anchor = Point(-1,-1),
|
||||
const int iterations = 1,
|
||||
const BorderTypes borderType = BORDER_CONSTANT,
|
||||
const Scalar &borderValue = morphologyDefaultBorderValue());
|
||||
|
||||
/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
|
||||
|
||||
@@ -883,10 +883,10 @@ applied (see cv::getDerivKernels for details).
|
||||
@param borderValue border value in case of constant border type
|
||||
@sa filter2D, gaussianBlur, cartToPolar
|
||||
*/
|
||||
GAPI_EXPORTS GMat Sobel(const GMat& src, int ddepth, int dx, int dy, int ksize = 3,
|
||||
double scale = 1, double delta = 0,
|
||||
int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
GAPI_EXPORTS_W GMat Sobel(const GMat& src, int ddepth, int dx, int dy, int ksize = 3,
|
||||
double scale = 1, double delta = 0,
|
||||
int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
|
||||
/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
|
||||
|
||||
@@ -934,10 +934,10 @@ applied (see cv::getDerivKernels for details).
|
||||
@param borderValue border value in case of constant border type
|
||||
@sa filter2D, gaussianBlur, cartToPolar
|
||||
*/
|
||||
GAPI_EXPORTS std::tuple<GMat, GMat> SobelXY(const GMat& src, int ddepth, int order, int ksize = 3,
|
||||
double scale = 1, double delta = 0,
|
||||
int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
GAPI_EXPORTS_W std::tuple<GMat, GMat> SobelXY(const GMat& src, int ddepth, int order, int ksize = 3,
|
||||
double scale = 1, double delta = 0,
|
||||
int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
|
||||
/** @brief Calculates the Laplacian of an image.
|
||||
|
||||
@@ -964,8 +964,8 @@ applied. See #getDerivKernels for details.
|
||||
@return Destination image of the same size and the same number of channels as src.
|
||||
@sa Sobel, Scharr
|
||||
*/
|
||||
GAPI_EXPORTS GMat Laplacian(const GMat& src, int ddepth, int ksize = 1,
|
||||
double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT);
|
||||
GAPI_EXPORTS_W GMat Laplacian(const GMat& src, int ddepth, int ksize = 1,
|
||||
double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT);
|
||||
|
||||
/** @brief Applies the bilateral filter to an image.
|
||||
|
||||
@@ -998,8 +998,8 @@ proportional to sigmaSpace.
|
||||
@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes
|
||||
@return Destination image of the same size and type as src.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bilateralFilter(const GMat& src, int d, double sigmaColor, double sigmaSpace,
|
||||
int borderType = BORDER_DEFAULT);
|
||||
GAPI_EXPORTS_W GMat bilateralFilter(const GMat& src, int d, double sigmaColor, double sigmaSpace,
|
||||
int borderType = BORDER_DEFAULT);
|
||||
|
||||
//! @} gapi_filters
|
||||
|
||||
@@ -1023,8 +1023,8 @@ largest value is used to find initial segments of strong edges. See
|
||||
L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough (
|
||||
L2gradient=false ).
|
||||
*/
|
||||
GAPI_EXPORTS GMat Canny(const GMat& image, double threshold1, double threshold2,
|
||||
int apertureSize = 3, bool L2gradient = false);
|
||||
GAPI_EXPORTS_W GMat Canny(const GMat& image, double threshold1, double threshold2,
|
||||
int apertureSize = 3, bool L2gradient = false);
|
||||
|
||||
/** @brief Determines strong corners on an image.
|
||||
|
||||
@@ -1070,14 +1070,14 @@ or #cornerMinEigenVal.
|
||||
|
||||
@return vector of detected corners.
|
||||
*/
|
||||
GAPI_EXPORTS_W GArray<Point2f> goodFeaturesToTrack(const GMat &image,
|
||||
int maxCorners,
|
||||
double qualityLevel,
|
||||
double minDistance,
|
||||
const Mat &mask = Mat(),
|
||||
int blockSize = 3,
|
||||
bool useHarrisDetector = false,
|
||||
double k = 0.04);
|
||||
GAPI_EXPORTS_W GArray<Point2f> goodFeaturesToTrack(const GMat &image,
|
||||
int maxCorners,
|
||||
double qualityLevel,
|
||||
double minDistance,
|
||||
const Mat &mask = Mat(),
|
||||
int blockSize = 3,
|
||||
bool useHarrisDetector = false,
|
||||
double k = 0.04);
|
||||
|
||||
/** @brief Equalizes the histogram of a grayscale image.
|
||||
|
||||
@@ -1098,7 +1098,7 @@ The algorithm normalizes the brightness and increases the contrast of the image.
|
||||
|
||||
@param src Source 8-bit single channel image.
|
||||
*/
|
||||
GAPI_EXPORTS GMat equalizeHist(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat equalizeHist(const GMat& src);
|
||||
|
||||
//! @addtogroup gapi_shape
|
||||
//! @{
|
||||
@@ -1209,7 +1209,7 @@ Calculates the up-right bounding rectangle of a point set.
|
||||
|
||||
@param src Input 2D point set, stored in std::vector<cv::Point2f>.
|
||||
*/
|
||||
GAPI_EXPORTS GOpaque<Rect> boundingRect(const GArray<Point2f>& src);
|
||||
GAPI_EXPORTS_W GOpaque<Rect> boundingRect(const GArray<Point2f>& src);
|
||||
|
||||
/** @brief Fits a line to a 2D point set.
|
||||
|
||||
@@ -1399,7 +1399,7 @@ Resulting gray color value computed as
|
||||
@param bY float multiplier for B channel.
|
||||
@sa RGB2YUV
|
||||
*/
|
||||
GAPI_EXPORTS GMat RGB2Gray(const GMat& src, float rY, float gY, float bY);
|
||||
GAPI_EXPORTS_W GMat RGB2Gray(const GMat& src, float rY, float gY, float bY);
|
||||
|
||||
/** @brief Converts an image from BGR color space to gray-scaled.
|
||||
|
||||
@@ -1412,7 +1412,7 @@ Resulting gray color value computed as
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
|
||||
@sa BGR2LUV
|
||||
*/
|
||||
GAPI_EXPORTS GMat BGR2Gray(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat BGR2Gray(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from RGB color space to YUV color space.
|
||||
|
||||
@@ -1429,7 +1429,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@sa YUV2RGB, RGB2Lab
|
||||
*/
|
||||
GAPI_EXPORTS GMat RGB2YUV(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat RGB2YUV(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from BGR color space to I420 color space.
|
||||
|
||||
@@ -1445,7 +1445,7 @@ Height of I420 output image must be equal 3/2 from height of input image.
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@sa I4202BGR
|
||||
*/
|
||||
GAPI_EXPORTS GMat BGR2I420(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat BGR2I420(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from RGB color space to I420 color space.
|
||||
|
||||
@@ -1461,7 +1461,7 @@ Height of I420 output image must be equal 3/2 from height of input image.
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@sa I4202RGB
|
||||
*/
|
||||
GAPI_EXPORTS GMat RGB2I420(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat RGB2I420(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from I420 color space to BGR color space.
|
||||
|
||||
@@ -1477,7 +1477,7 @@ Height of BGR output image must be equal 2/3 from height of input image.
|
||||
@param src input image: 8-bit unsigned 1-channel image @ref CV_8UC1.
|
||||
@sa BGR2I420
|
||||
*/
|
||||
GAPI_EXPORTS GMat I4202BGR(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat I4202BGR(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from I420 color space to BGR color space.
|
||||
|
||||
@@ -1493,7 +1493,7 @@ Height of RGB output image must be equal 2/3 from height of input image.
|
||||
@param src input image: 8-bit unsigned 1-channel image @ref CV_8UC1.
|
||||
@sa RGB2I420
|
||||
*/
|
||||
GAPI_EXPORTS GMat I4202RGB(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat I4202RGB(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from BGR color space to LUV color space.
|
||||
|
||||
@@ -1507,7 +1507,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@sa RGB2Lab, RGB2LUV
|
||||
*/
|
||||
GAPI_EXPORTS GMat BGR2LUV(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat BGR2LUV(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from LUV color space to BGR color space.
|
||||
|
||||
@@ -1521,7 +1521,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@sa BGR2LUV
|
||||
*/
|
||||
GAPI_EXPORTS GMat LUV2BGR(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat LUV2BGR(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from YUV color space to BGR color space.
|
||||
|
||||
@@ -1535,7 +1535,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@sa BGR2YUV
|
||||
*/
|
||||
GAPI_EXPORTS GMat YUV2BGR(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat YUV2BGR(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from BGR color space to YUV color space.
|
||||
|
||||
@@ -1549,7 +1549,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
@sa YUV2BGR
|
||||
*/
|
||||
GAPI_EXPORTS GMat BGR2YUV(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat BGR2YUV(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from RGB color space to Lab color space.
|
||||
|
||||
@@ -1563,7 +1563,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC1.
|
||||
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
|
||||
@sa RGB2YUV, RGB2LUV
|
||||
*/
|
||||
GAPI_EXPORTS GMat RGB2Lab(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat RGB2Lab(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from YUV color space to RGB.
|
||||
The function converts an input image from YUV color space to RGB.
|
||||
@@ -1577,7 +1577,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
|
||||
@sa RGB2Lab, RGB2YUV
|
||||
*/
|
||||
GAPI_EXPORTS GMat YUV2RGB(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat YUV2RGB(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from NV12 (YUV420p) color space to RGB.
|
||||
The function converts an input image from NV12 color space to RGB.
|
||||
@@ -1592,7 +1592,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
|
||||
@sa YUV2RGB, NV12toBGR
|
||||
*/
|
||||
GAPI_EXPORTS GMat NV12toRGB(const GMat& src_y, const GMat& src_uv);
|
||||
GAPI_EXPORTS_W GMat NV12toRGB(const GMat& src_y, const GMat& src_uv);
|
||||
|
||||
/** @brief Converts an image from NV12 (YUV420p) color space to gray-scaled.
|
||||
The function converts an input image from NV12 color space to gray-scaled.
|
||||
@@ -1607,7 +1607,7 @@ Output image must be 8-bit unsigned 1-channel image @ref CV_8UC1.
|
||||
|
||||
@sa YUV2RGB, NV12toBGR
|
||||
*/
|
||||
GAPI_EXPORTS GMat NV12toGray(const GMat& src_y, const GMat& src_uv);
|
||||
GAPI_EXPORTS_W GMat NV12toGray(const GMat& src_y, const GMat& src_uv);
|
||||
|
||||
/** @brief Converts an image from NV12 (YUV420p) color space to BGR.
|
||||
The function converts an input image from NV12 color space to RGB.
|
||||
@@ -1622,7 +1622,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
|
||||
@sa YUV2BGR, NV12toRGB
|
||||
*/
|
||||
GAPI_EXPORTS GMat NV12toBGR(const GMat& src_y, const GMat& src_uv);
|
||||
GAPI_EXPORTS_W GMat NV12toBGR(const GMat& src_y, const GMat& src_uv);
|
||||
|
||||
/** @brief Converts an image from BayerGR color space to RGB.
|
||||
The function converts an input image from BayerGR color space to RGB.
|
||||
@@ -1636,7 +1636,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
|
||||
@sa YUV2BGR, NV12toRGB
|
||||
*/
|
||||
GAPI_EXPORTS GMat BayerGR2RGB(const GMat& src_gr);
|
||||
GAPI_EXPORTS_W GMat BayerGR2RGB(const GMat& src_gr);
|
||||
|
||||
/** @brief Converts an image from RGB color space to HSV.
|
||||
The function converts an input image from RGB color space to HSV.
|
||||
@@ -1650,7 +1650,7 @@ Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
|
||||
|
||||
@sa YUV2BGR, NV12toRGB
|
||||
*/
|
||||
GAPI_EXPORTS GMat RGB2HSV(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat RGB2HSV(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from RGB color space to YUV422.
|
||||
The function converts an input image from RGB color space to YUV422.
|
||||
@@ -1664,7 +1664,7 @@ Output image must be 8-bit unsigned 2-channel image @ref CV_8UC2.
|
||||
|
||||
@sa YUV2BGR, NV12toRGB
|
||||
*/
|
||||
GAPI_EXPORTS GMat RGB2YUV422(const GMat& src);
|
||||
GAPI_EXPORTS_W GMat RGB2YUV422(const GMat& src);
|
||||
|
||||
/** @brief Converts an image from NV12 (YUV420p) color space to RGB.
|
||||
The function converts an input image from NV12 color space to RGB.
|
||||
|
||||
@@ -397,7 +397,7 @@ void inline unpackBlobs(const cv::GInferInputs::Map& blobs,
|
||||
kinds.emplace_back(cv::detail::OpaqueKind::CV_UNKNOWN);
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -629,7 +629,7 @@ infer2(const std::string& tag,
|
||||
kinds.emplace_back(cv::detail::OpaqueKind::CV_RECT);
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// 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.
|
||||
|
||||
#ifndef OPENCV_GAPI_INFER_BINDINGS_ONNX_HPP
|
||||
#define OPENCV_GAPI_INFER_BINDINGS_ONNX_HPP
|
||||
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
|
||||
#include <opencv2/gapi/infer/onnx.hpp> // Params
|
||||
#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/util/any.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace onnx {
|
||||
|
||||
// NB: Used by python wrapper
|
||||
// This class can be marked as SIMPLE, because it's implemented as pimpl
|
||||
class GAPI_EXPORTS_W_SIMPLE PyParams {
|
||||
public:
|
||||
GAPI_WRAP
|
||||
PyParams() = default;
|
||||
|
||||
GAPI_WRAP
|
||||
PyParams(const std::string& tag, const std::string& model_path);
|
||||
|
||||
GBackend backend() const;
|
||||
std::string tag() const;
|
||||
cv::util::any params() const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Params<cv::gapi::Generic>> m_priv;
|
||||
};
|
||||
|
||||
GAPI_EXPORTS_W PyParams params(const std::string& tag, const std::string& model_path);
|
||||
|
||||
} // namespace onnx
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_INFER_BINDINGS_ONNX_HPP
|
||||
@@ -52,6 +52,8 @@ enum class TraitAs: int
|
||||
|
||||
using IEConfig = std::map<std::string, std::string>;
|
||||
|
||||
enum InferMode {Sync, Async};
|
||||
|
||||
namespace detail {
|
||||
struct ParamDesc {
|
||||
std::string model_path;
|
||||
@@ -88,6 +90,20 @@ struct ParamDesc {
|
||||
|
||||
cv::optional<cv::gapi::wip::onevpl::Device> vpl_preproc_device;
|
||||
cv::optional<cv::gapi::wip::onevpl::Context> vpl_preproc_ctx;
|
||||
|
||||
InferMode mode;
|
||||
|
||||
using PrecisionT = int;
|
||||
using PrecisionMapT = std::unordered_map<std::string, PrecisionT>;
|
||||
// NB: This parameter can contain:
|
||||
// 1. cv::util::monostate - Don't specify precision, but use default from IR/Blob.
|
||||
// 2. PrecisionT (CV_8U, CV_32F, ...) - Specifies precision for all output layers.
|
||||
// 3. PrecisionMapT ({{"layer0", CV_32F}, {"layer1", CV_16F}} - Specifies precision for certain output layer.
|
||||
// cv::util::monostate is default value that means precision wasn't specified.
|
||||
using PrecisionVariantT = cv::util::variant<cv::util::monostate,
|
||||
PrecisionT,
|
||||
PrecisionMapT>;
|
||||
PrecisionVariantT output_precision;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
@@ -132,7 +148,9 @@ public:
|
||||
, {}
|
||||
, {}
|
||||
, {}
|
||||
, {}} {
|
||||
, {}
|
||||
, InferMode::Async
|
||||
, {} } {
|
||||
};
|
||||
|
||||
/** @overload
|
||||
@@ -156,7 +174,9 @@ public:
|
||||
, {}
|
||||
, {}
|
||||
, {}
|
||||
, {}} {
|
||||
, {}
|
||||
, InferMode::Async
|
||||
, {} } {
|
||||
};
|
||||
|
||||
/** @brief Specifies sequence of network input layers names for inference.
|
||||
@@ -351,6 +371,47 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Specifies which api will be used to run inference.
|
||||
|
||||
The function is used to specify mode for OpenVINO inference.
|
||||
OpenVINO has two options to run inference:
|
||||
1. Asynchronous (using StartAsync: https://docs.openvino.ai/latest/classInferenceEngine_1_1InferRequest.html#doxid-class-inference-engine-1-1-infer-request-1a405293e8423d82a5b45f642a3bef0d24)
|
||||
2. Synchronous (using Infer: https://docs.openvino.ai/latest/classInferenceEngine_1_1InferRequest.html#doxid-class-inference-engine-1-1-infer-request-1a3391ce30894abde730523e9ca9371ce8)
|
||||
By default asynchronous mode is used.
|
||||
|
||||
@param mode Inference mode which will be used.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>& cfgInferMode(InferMode mode) {
|
||||
desc.mode = mode;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Specifies the output precision for model.
|
||||
|
||||
The function is used to set an output precision for model.
|
||||
|
||||
@param precision Precision in OpenCV format (CV_8U, CV_32F, ...)
|
||||
will be applied to all output layers.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>& cfgOutputPrecision(detail::ParamDesc::PrecisionT precision) {
|
||||
desc.output_precision = precision;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @overload
|
||||
|
||||
@param precision_map Map of pairs: name of corresponding output layer
|
||||
and its precision in OpenCV format (CV_8U, CV_32F, ...)
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>&
|
||||
cfgOutputPrecision(detail::ParamDesc::PrecisionMapT precision_map) {
|
||||
desc.output_precision = precision_map;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// BEGIN(G-API's network parametrization API)
|
||||
GBackend backend() const { return cv::gapi::ie::backend(); }
|
||||
std::string tag() const { return Net::tag(); }
|
||||
@@ -385,7 +446,7 @@ public:
|
||||
const std::string &device)
|
||||
: desc{ model, weights, device, {}, {}, {}, 0u, 0u,
|
||||
detail::ParamDesc::Kind::Load, true, {}, {}, {}, 1u,
|
||||
{}, {}, {}, {}},
|
||||
{}, {}, {}, {}, InferMode::Async, {} },
|
||||
m_tag(tag) {
|
||||
};
|
||||
|
||||
@@ -403,7 +464,7 @@ public:
|
||||
const std::string &device)
|
||||
: desc{ model, {}, device, {}, {}, {}, 0u, 0u,
|
||||
detail::ParamDesc::Kind::Import, true, {}, {}, {}, 1u,
|
||||
{}, {}, {}, {}},
|
||||
{}, {}, {}, {}, InferMode::Async, {} },
|
||||
m_tag(tag) {
|
||||
};
|
||||
|
||||
@@ -476,6 +537,25 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ie::Params::cfgInferAPI */
|
||||
Params& cfgInferMode(InferMode mode) {
|
||||
desc.mode = mode;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ie::Params::cfgOutputPrecision */
|
||||
Params& cfgOutputPrecision(detail::ParamDesc::PrecisionT precision) {
|
||||
desc.output_precision = precision;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @overload */
|
||||
Params&
|
||||
cfgOutputPrecision(detail::ParamDesc::PrecisionMapT precision_map) {
|
||||
desc.output_precision = precision_map;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// BEGIN(G-API's network parametrization API)
|
||||
GBackend backend() const { return cv::gapi::ie::backend(); }
|
||||
std::string tag() const { return m_tag; }
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <opencv2/core/cvdef.h> // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
|
||||
#include <opencv2/gapi/infer.hpp> // Generic
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
@@ -67,6 +68,8 @@ struct ParamDesc {
|
||||
std::vector<bool> normalize; //!< Vector of bool values that enabled or disabled normalize of input data.
|
||||
|
||||
std::vector<std::string> names_to_remap; //!< Names of output layers that will be processed in PostProc function.
|
||||
|
||||
bool is_generic;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
@@ -103,6 +106,7 @@ public:
|
||||
desc.model_path = model;
|
||||
desc.num_in = std::tuple_size<typename Net::InArgs>::value;
|
||||
desc.num_out = std::tuple_size<typename Net::OutArgs>::value;
|
||||
desc.is_generic = false;
|
||||
};
|
||||
|
||||
/** @brief Specifies sequence of network input layers names for inference.
|
||||
@@ -277,6 +281,35 @@ protected:
|
||||
detail::ParamDesc desc;
|
||||
};
|
||||
|
||||
/*
|
||||
* @brief This structure provides functions for generic network type that
|
||||
* fill inference parameters.
|
||||
* @see struct Generic
|
||||
*/
|
||||
template<>
|
||||
class Params<cv::gapi::Generic> {
|
||||
public:
|
||||
/** @brief Class constructor.
|
||||
|
||||
Constructs Params based on input information and sets default values for other
|
||||
inference description parameters.
|
||||
|
||||
@param tag string tag of the network for which these parameters are intended.
|
||||
@param model_path path to model file (.onnx file).
|
||||
*/
|
||||
Params(const std::string& tag, const std::string& model_path)
|
||||
: desc{model_path, 0u, 0u, {}, {}, {}, {}, {}, {}, {}, {}, {}, true}, m_tag(tag) {}
|
||||
|
||||
// BEGIN(G-API's network parametrization API)
|
||||
GBackend backend() const { return cv::gapi::onnx::backend(); }
|
||||
std::string tag() const { return m_tag; }
|
||||
cv::util::any params() const { return { desc }; }
|
||||
// END(G-API's network parametrization API)
|
||||
protected:
|
||||
detail::ParamDesc desc;
|
||||
std::string m_tag;
|
||||
};
|
||||
|
||||
} // namespace onnx
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
@@ -242,11 +242,11 @@ public:
|
||||
// The default implementation does nothing
|
||||
virtual cv::util::any blobParams() const;
|
||||
virtual void serialize(cv::gapi::s11n::IOStream&) {
|
||||
GAPI_Assert(false && "Generic serialize method of MediaFrame::IAdapter does nothing by default. "
|
||||
GAPI_Error("Generic serialize method of MediaFrame::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 MediaFrame::IAdapter does nothing by default. "
|
||||
GAPI_Error("Generic deserialize method of MediaFrame::IAdapter does nothing by default. "
|
||||
"Please, implement it in derived class to properly deserialize the object.");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,6 +119,10 @@ template<typename U> struct ocl_get_in<cv::GArray<U> >
|
||||
{
|
||||
static const std::vector<U>& get(GOCLContext &ctx, int idx) { return ctx.inArg<VectorRef>(idx).rref<U>(); }
|
||||
};
|
||||
template<> struct ocl_get_in<cv::GFrame>
|
||||
{
|
||||
static cv::MediaFrame get(GOCLContext &ctx, int idx) { return ctx.inArg<cv::MediaFrame>(idx); }
|
||||
};
|
||||
template<typename U> struct ocl_get_in<cv::GOpaque<U> >
|
||||
{
|
||||
static const U& get(GOCLContext &ctx, int idx) { return ctx.inArg<OpaqueRef>(idx).rref<U>(); }
|
||||
@@ -149,6 +153,10 @@ struct tracked_cv_umat{
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
template<typename... Outputs>
|
||||
void postprocess_ocl(Outputs&... outs)
|
||||
{
|
||||
@@ -162,6 +170,9 @@ void postprocess_ocl(Outputs&... outs)
|
||||
int dummy[] = { 0, (validate(&outs), 0)... };
|
||||
cv::util::suppress_unused_warning(dummy);
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template<class T> struct ocl_get_out;
|
||||
template<> struct ocl_get_out<cv::GMat>
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
# define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr)
|
||||
#endif
|
||||
|
||||
#define GAPI_Error(msg) CV_Error(cv::Error::StsError, msg)
|
||||
|
||||
#else
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
@@ -49,6 +51,10 @@ namespace detail
|
||||
# define GAPI_DbgAssert(expr) GAPI_Assert(expr)
|
||||
#endif
|
||||
|
||||
#define GAPI_Error(msg) { \
|
||||
::detail::assert_abort(msg, __LINE__, __FILE__, __func__); \
|
||||
}
|
||||
|
||||
#endif // GAPI_STANDALONE
|
||||
|
||||
#endif // OPENCV_GAPI_OWN_ASSERT_HPP
|
||||
|
||||
@@ -31,19 +31,22 @@ struct GPythonContext
|
||||
const cv::GArgs &ins;
|
||||
const cv::GMetaArgs &in_metas;
|
||||
const cv::GTypesInfo &out_info;
|
||||
|
||||
cv::optional<cv::GArg> m_state;
|
||||
};
|
||||
|
||||
using Impl = std::function<cv::GRunArgs(const GPythonContext&)>;
|
||||
using Setup = std::function<cv::GArg(const GMetaArgs&, const GArgs&)>;
|
||||
|
||||
class GAPI_EXPORTS GPythonKernel
|
||||
{
|
||||
public:
|
||||
GPythonKernel() = default;
|
||||
GPythonKernel(Impl run);
|
||||
GPythonKernel(Impl run, Setup setup);
|
||||
|
||||
cv::GRunArgs operator()(const GPythonContext& ctx);
|
||||
private:
|
||||
Impl m_run;
|
||||
Impl run;
|
||||
Setup setup = nullptr;
|
||||
bool is_stateful = false;
|
||||
};
|
||||
|
||||
class GAPI_EXPORTS GPythonFunctor : public cv::gapi::GFunctor
|
||||
@@ -51,7 +54,8 @@ class GAPI_EXPORTS GPythonFunctor : public cv::gapi::GFunctor
|
||||
public:
|
||||
using Meta = cv::GKernel::M;
|
||||
|
||||
GPythonFunctor(const char* id, const Meta &meta, const Impl& impl);
|
||||
GPythonFunctor(const char* id, const Meta& meta, const Impl& impl,
|
||||
const Setup& setup = nullptr);
|
||||
|
||||
GKernelImpl impl() const override;
|
||||
gapi::GBackend backend() const override;
|
||||
|
||||
@@ -112,11 +112,11 @@ public:
|
||||
// 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::IAdapter does nothing by default. "
|
||||
GAPI_Error("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::IAdapter does nothing by default. "
|
||||
GAPI_Error("Generic deserialize method of RMat::IAdapter does nothing by default. "
|
||||
"Please, implement it in derived class to properly deserialize the object.");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
#include <opencv2/gapi/util/util.hpp>
|
||||
|
||||
// FIXME: caused by deserialize_runarg
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4702)
|
||||
#endif
|
||||
|
||||
@@ -229,6 +230,9 @@ GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point &pt);
|
||||
GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Point2f &pt);
|
||||
GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point2f &pt);
|
||||
|
||||
GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Point3f &pt);
|
||||
GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point3f &pt);
|
||||
|
||||
GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Size &sz);
|
||||
GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Size &sz);
|
||||
|
||||
@@ -332,7 +336,7 @@ IIStream& operator>> (IIStream& is, std::vector<T> &ts) {
|
||||
namespace detail {
|
||||
template<typename V>
|
||||
IOStream& put_v(IOStream&, const V&, std::size_t) {
|
||||
GAPI_Assert(false && "variant>>: requested index is invalid");
|
||||
GAPI_Error("variant>>: requested index is invalid");
|
||||
};
|
||||
|
||||
template<typename V, typename X, typename... Xs>
|
||||
@@ -344,7 +348,7 @@ IOStream& put_v(IOStream& os, const V& v, std::size_t x) {
|
||||
|
||||
template<typename V>
|
||||
IIStream& get_v(IIStream&, V&, std::size_t, std::size_t) {
|
||||
GAPI_Assert(false && "variant<<: requested index is invalid");
|
||||
GAPI_Error("variant<<: requested index is invalid");
|
||||
}
|
||||
|
||||
template<typename V, typename X, typename... Xs>
|
||||
@@ -420,7 +424,7 @@ static GRunArg exec(cv::gapi::s11n::IIStream& is) {
|
||||
template<typename RA>
|
||||
struct deserialize_arg_with_adapter<RA, void> {
|
||||
static GRunArg exec(cv::gapi::s11n::IIStream&) {
|
||||
GAPI_Assert(false && "No suitable adapter class found during RMat/MediaFrame deserialization. "
|
||||
GAPI_Error("No suitable adapter class found during RMat/MediaFrame deserialization. "
|
||||
"Please, make sure you've passed them in cv::gapi::deserialize() template");
|
||||
return GRunArg{};
|
||||
}
|
||||
@@ -502,4 +506,8 @@ cv::GRunArgs getRunArgsWithAdapters(const std::vector<char> &bytes) {
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // OPENCV_GAPI_S11N_HPP
|
||||
|
||||
@@ -52,7 +52,7 @@ struct S11N: public NotImplemented {
|
||||
* properly overload the function to use it.
|
||||
*/
|
||||
static void serialize(IOStream &, const T &) {
|
||||
GAPI_Assert(false && "No serialization routine is provided!");
|
||||
GAPI_Error("No serialization routine is provided!");
|
||||
}
|
||||
/**
|
||||
* @brief This function allows user to deserialize their custom type.
|
||||
@@ -61,7 +61,7 @@ struct S11N: public NotImplemented {
|
||||
* properly overload the function to use it.
|
||||
*/
|
||||
static T deserialize(IIStream &) {
|
||||
GAPI_Assert(false && "No deserialization routine is provided!");
|
||||
GAPI_Error("No deserialization routine is provided!");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ G_TYPED_KERNEL(GStereo, <GMat(GMat, GMat, const StereoOutputFormat)>, "org.openc
|
||||
case StereoOutputFormat::DISPARITY_FIXED16_12_4:
|
||||
return left.withDepth(CV_16SC1);
|
||||
default:
|
||||
GAPI_Assert(false && "Unknown output format!");
|
||||
GAPI_Error("Unknown output format!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ protected:
|
||||
cv::Mat tmp;
|
||||
if (!cap.read(tmp))
|
||||
{
|
||||
GAPI_Assert(false && "Couldn't grab the very first frame");
|
||||
GAPI_Error("Couldn't grab the very first frame");
|
||||
}
|
||||
// NOTE: Some decode/media VideoCapture backends continue
|
||||
// owning the video buffer under cv::Mat so in order to
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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) 2022 Intel Corporation
|
||||
|
||||
#ifndef OPENCV_GAPI_STREAMING_ONEVPL_UTILS_HPP
|
||||
#define OPENCV_GAPI_STREAMING_ONEVPL_UTILS_HPP
|
||||
|
||||
#include <opencv2/gapi/own/exports.hpp> // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/streaming/onevpl/cfg_params.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
/**
|
||||
* @brief Provides default device selector based on config.
|
||||
*/
|
||||
GAPI_EXPORTS std::shared_ptr<IDeviceSelector> getDefaultDeviceSelector(const std::vector<CfgParam>& cfg_params);
|
||||
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_STREAMING_ONEVPL_UTILS_HPP
|
||||
@@ -76,6 +76,10 @@ class GOpaque():
|
||||
def __new__(self):
|
||||
return cv.GOpaqueT(cv.gapi.CV_POINT2F)
|
||||
|
||||
class Point3f():
|
||||
def __new__(self):
|
||||
return cv.GOpaqueT(cv.gapi.CV_POINT3F)
|
||||
|
||||
class Size():
|
||||
def __new__(self):
|
||||
return cv.GOpaqueT(cv.gapi.CV_SIZE)
|
||||
@@ -127,6 +131,10 @@ class GArray():
|
||||
def __new__(self):
|
||||
return cv.GArrayT(cv.gapi.CV_POINT2F)
|
||||
|
||||
class Point3f():
|
||||
def __new__(self):
|
||||
return cv.GArrayT(cv.gapi.CV_POINT3F)
|
||||
|
||||
class Size():
|
||||
def __new__(self):
|
||||
return cv.GArrayT(cv.gapi.CV_SIZE)
|
||||
@@ -167,6 +175,7 @@ def op(op_id, in_types, out_types):
|
||||
cv.GArray.String: cv.gapi.CV_STRING,
|
||||
cv.GArray.Point: cv.gapi.CV_POINT,
|
||||
cv.GArray.Point2f: cv.gapi.CV_POINT2F,
|
||||
cv.GArray.Point3f: cv.gapi.CV_POINT3F,
|
||||
cv.GArray.Size: cv.gapi.CV_SIZE,
|
||||
cv.GArray.Rect: cv.gapi.CV_RECT,
|
||||
cv.GArray.Scalar: cv.gapi.CV_SCALAR,
|
||||
@@ -186,6 +195,7 @@ def op(op_id, in_types, out_types):
|
||||
cv.GOpaque.String: cv.gapi.CV_STRING,
|
||||
cv.GOpaque.Point: cv.gapi.CV_POINT,
|
||||
cv.GOpaque.Point2f: cv.gapi.CV_POINT2F,
|
||||
cv.GOpaque.Point3f: cv.gapi.CV_POINT3F,
|
||||
cv.GOpaque.Size: cv.gapi.CV_SIZE,
|
||||
cv.GOpaque.Rect: cv.gapi.CV_RECT,
|
||||
cv.GOpaque.Prim: cv.gapi.CV_DRAW_PRIM,
|
||||
@@ -200,6 +210,7 @@ def op(op_id, in_types, out_types):
|
||||
cv.gapi.CV_STRING: 'cv.gapi.CV_STRING' ,
|
||||
cv.gapi.CV_POINT: 'cv.gapi.CV_POINT' ,
|
||||
cv.gapi.CV_POINT2F: 'cv.gapi.CV_POINT2F' ,
|
||||
cv.gapi.CV_POINT3F: 'cv.gapi.CV_POINT3F' ,
|
||||
cv.gapi.CV_SIZE: 'cv.gapi.CV_SIZE',
|
||||
cv.gapi.CV_RECT: 'cv.gapi.CV_RECT',
|
||||
cv.gapi.CV_SCALAR: 'cv.gapi.CV_SCALAR',
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
using gapi_GKernelPackage = cv::GKernelPackage;
|
||||
using gapi_GNetPackage = cv::gapi::GNetPackage;
|
||||
using gapi_ie_PyParams = cv::gapi::ie::PyParams;
|
||||
using gapi_onnx_PyParams = cv::gapi::onnx::PyParams;
|
||||
using gapi_wip_IStreamSource_Ptr = cv::Ptr<cv::gapi::wip::IStreamSource>;
|
||||
using detail_ExtractArgsCallback = cv::detail::ExtractArgsCallback;
|
||||
using detail_ExtractMetaCallback = cv::detail::ExtractMetaCallback;
|
||||
using vector_GNetParam = std::vector<cv::gapi::GNetParam>;
|
||||
using vector_GMat = std::vector<cv::GMat>;
|
||||
using gapi_streaming_queue_capacity = cv::gapi::streaming::queue_capacity;
|
||||
using GStreamerSource_OutputType = cv::gapi::wip::GStreamerSource::OutputType;
|
||||
|
||||
@@ -40,6 +42,7 @@ using GArray_float = cv::GArray<double>;
|
||||
using GArray_string = cv::GArray<std::string>;
|
||||
using GArray_Point2i = cv::GArray<cv::Point>;
|
||||
using GArray_Point2f = cv::GArray<cv::Point2f>;
|
||||
using GArray_Point3f = cv::GArray<cv::Point3f>;
|
||||
using GArray_Size = cv::GArray<cv::Size>;
|
||||
using GArray_Rect = cv::GArray<cv::Rect>;
|
||||
using GArray_Scalar = cv::GArray<cv::Scalar>;
|
||||
@@ -237,6 +240,7 @@ PyObject* pyopencv_from(const cv::GArg& value)
|
||||
HANDLE_CASE(STRING, std::string);
|
||||
HANDLE_CASE(POINT, cv::Point);
|
||||
HANDLE_CASE(POINT2F, cv::Point2f);
|
||||
HANDLE_CASE(POINT3F, cv::Point3f);
|
||||
HANDLE_CASE(SIZE, cv::Size);
|
||||
HANDLE_CASE(RECT, cv::Rect);
|
||||
HANDLE_CASE(SCALAR, cv::Scalar);
|
||||
@@ -294,6 +298,7 @@ PyObject* pyopencv_from(const cv::detail::OpaqueRef& o)
|
||||
case cv::detail::OpaqueKind::CV_STRING : return pyopencv_from(o.rref<std::string>());
|
||||
case cv::detail::OpaqueKind::CV_POINT : return pyopencv_from(o.rref<cv::Point>());
|
||||
case cv::detail::OpaqueKind::CV_POINT2F : return pyopencv_from(o.rref<cv::Point2f>());
|
||||
case cv::detail::OpaqueKind::CV_POINT3F : return pyopencv_from(o.rref<cv::Point3f>());
|
||||
case cv::detail::OpaqueKind::CV_SIZE : return pyopencv_from(o.rref<cv::Size>());
|
||||
case cv::detail::OpaqueKind::CV_RECT : return pyopencv_from(o.rref<cv::Rect>());
|
||||
case cv::detail::OpaqueKind::CV_UNKNOWN : return pyopencv_from(o.rref<cv::GArg>());
|
||||
@@ -320,6 +325,7 @@ PyObject* pyopencv_from(const cv::detail::VectorRef& v)
|
||||
case cv::detail::OpaqueKind::CV_STRING : return pyopencv_from_generic_vec(v.rref<std::string>());
|
||||
case cv::detail::OpaqueKind::CV_POINT : return pyopencv_from_generic_vec(v.rref<cv::Point>());
|
||||
case cv::detail::OpaqueKind::CV_POINT2F : return pyopencv_from_generic_vec(v.rref<cv::Point2f>());
|
||||
case cv::detail::OpaqueKind::CV_POINT3F : return pyopencv_from_generic_vec(v.rref<cv::Point3f>());
|
||||
case cv::detail::OpaqueKind::CV_SIZE : return pyopencv_from_generic_vec(v.rref<cv::Size>());
|
||||
case cv::detail::OpaqueKind::CV_RECT : return pyopencv_from_generic_vec(v.rref<cv::Rect>());
|
||||
case cv::detail::OpaqueKind::CV_SCALAR : return pyopencv_from_generic_vec(v.rref<cv::Scalar>());
|
||||
@@ -490,6 +496,7 @@ static cv::detail::OpaqueRef extract_opaque_ref(PyObject* from, cv::detail::Opaq
|
||||
HANDLE_CASE(STRING, std::string);
|
||||
HANDLE_CASE(POINT, cv::Point);
|
||||
HANDLE_CASE(POINT2F, cv::Point2f);
|
||||
HANDLE_CASE(POINT3F, cv::Point3f);
|
||||
HANDLE_CASE(SIZE, cv::Size);
|
||||
HANDLE_CASE(RECT, cv::Rect);
|
||||
HANDLE_CASE(UNKNOWN, cv::GArg);
|
||||
@@ -522,6 +529,7 @@ static cv::detail::VectorRef extract_vector_ref(PyObject* from, cv::detail::Opaq
|
||||
HANDLE_CASE(STRING, std::string);
|
||||
HANDLE_CASE(POINT, cv::Point);
|
||||
HANDLE_CASE(POINT2F, cv::Point2f);
|
||||
HANDLE_CASE(POINT3F, cv::Point3f);
|
||||
HANDLE_CASE(SIZE, cv::Size);
|
||||
HANDLE_CASE(RECT, cv::Rect);
|
||||
HANDLE_CASE(SCALAR, cv::Scalar);
|
||||
@@ -660,7 +668,8 @@ static cv::GRunArgs run_py_kernel(cv::detail::PyObjectHolder kernel,
|
||||
// NB: Doesn't increase reference counter (false),
|
||||
// because PyObject already have ownership.
|
||||
// In case exception decrement reference counter.
|
||||
cv::detail::PyObjectHolder args(PyTuple_New(ins.size()), false);
|
||||
cv::detail::PyObjectHolder args(
|
||||
PyTuple_New(ctx.m_state.has_value() ? ins.size() + 1 : ins.size()), false);
|
||||
for (size_t i = 0; i < ins.size(); ++i)
|
||||
{
|
||||
// NB: If meta is monostate then object isn't associated with G-TYPE.
|
||||
@@ -690,6 +699,12 @@ static cv::GRunArgs run_py_kernel(cv::detail::PyObjectHolder kernel,
|
||||
}
|
||||
++in_idx;
|
||||
}
|
||||
|
||||
if (ctx.m_state.has_value())
|
||||
{
|
||||
PyTuple_SetItem(args.get(), ins.size(), pyopencv_from(ctx.m_state.value()));
|
||||
}
|
||||
|
||||
// NB: Doesn't increase reference counter (false).
|
||||
// In case PyObject_CallObject return NULL, do nothing in destructor.
|
||||
cv::detail::PyObjectHolder result(
|
||||
@@ -723,7 +738,7 @@ static cv::GRunArgs run_py_kernel(cv::detail::PyObjectHolder kernel,
|
||||
else
|
||||
{
|
||||
// Seems to be impossible case.
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
@@ -736,6 +751,86 @@ static cv::GRunArgs run_py_kernel(cv::detail::PyObjectHolder kernel,
|
||||
return outs;
|
||||
}
|
||||
|
||||
static void unpackMetasToTuple(const cv::GMetaArgs& meta,
|
||||
const cv::GArgs& gargs,
|
||||
cv::detail::PyObjectHolder& tuple)
|
||||
{
|
||||
size_t idx = 0;
|
||||
for (auto&& m : meta)
|
||||
{
|
||||
switch (m.index())
|
||||
{
|
||||
case cv::GMetaArg::index_of<cv::GMatDesc>():
|
||||
PyTuple_SetItem(tuple.get(), idx, pyopencv_from(cv::util::get<cv::GMatDesc>(m)));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::GScalarDesc>():
|
||||
PyTuple_SetItem(tuple.get(), idx,
|
||||
pyopencv_from(cv::util::get<cv::GScalarDesc>(m)));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::GArrayDesc>():
|
||||
PyTuple_SetItem(tuple.get(), idx,
|
||||
pyopencv_from(cv::util::get<cv::GArrayDesc>(m)));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::GOpaqueDesc>():
|
||||
PyTuple_SetItem(tuple.get(), idx,
|
||||
pyopencv_from(cv::util::get<cv::GOpaqueDesc>(m)));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::util::monostate>():
|
||||
PyTuple_SetItem(tuple.get(), idx, pyopencv_from(gargs[idx]));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::GFrameDesc>():
|
||||
util::throw_error(
|
||||
std::logic_error("GFrame isn't supported for custom operation"));
|
||||
break;
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
static cv::GArg setup_py(cv::detail::PyObjectHolder setup,
|
||||
const cv::GMetaArgs& meta,
|
||||
const cv::GArgs& gargs)
|
||||
{
|
||||
PyGILState_STATE gstate;
|
||||
gstate = PyGILState_Ensure();
|
||||
|
||||
cv::GArg out;
|
||||
|
||||
try
|
||||
{
|
||||
// NB: Doesn't increase reference counter (false),
|
||||
// because PyObject already have ownership.
|
||||
// In case exception decrement reference counter.
|
||||
cv::detail::PyObjectHolder args(PyTuple_New(meta.size()), false);
|
||||
unpackMetasToTuple(meta, gargs, args);
|
||||
// NB: Take an onwership because this state is "Python" type so it will be wrapped as-is
|
||||
// into cv::GArg and stored in GPythonBackend. Object without ownership can't
|
||||
// be dealocated outside this function.
|
||||
cv::detail::PyObjectHolder result(PyObject_CallObject(setup.get(), args.get()), true);
|
||||
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
PyErr_PrintEx(0);
|
||||
PyErr_Clear();
|
||||
throw std::logic_error("Python kernel failed with error!");
|
||||
}
|
||||
// NB: In fact it's impossible situation, because errors were handled above.
|
||||
GAPI_Assert(result.get() && "Python kernel returned NULL!");
|
||||
|
||||
if (!pyopencv_to(result.get(), out, ArgInfo("arg", false)))
|
||||
{
|
||||
util::throw_error(std::logic_error("Unsupported output meta type"));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
PyGILState_Release(gstate);
|
||||
throw;
|
||||
}
|
||||
PyGILState_Release(gstate);
|
||||
return out;
|
||||
}
|
||||
|
||||
static GMetaArg get_meta_arg(PyObject* obj)
|
||||
{
|
||||
cv::GMetaArg arg;
|
||||
@@ -761,8 +856,8 @@ static cv::GMetaArgs get_meta_args(PyObject* tuple)
|
||||
}
|
||||
|
||||
static GMetaArgs run_py_meta(cv::detail::PyObjectHolder out_meta,
|
||||
const cv::GMetaArgs &meta,
|
||||
const cv::GArgs &gargs)
|
||||
const cv::GMetaArgs &meta,
|
||||
const cv::GArgs &gargs)
|
||||
{
|
||||
PyGILState_STATE gstate;
|
||||
gstate = PyGILState_Ensure();
|
||||
@@ -774,32 +869,7 @@ static GMetaArgs run_py_meta(cv::detail::PyObjectHolder out_meta,
|
||||
// because PyObject already have ownership.
|
||||
// In case exception decrement reference counter.
|
||||
cv::detail::PyObjectHolder args(PyTuple_New(meta.size()), false);
|
||||
size_t idx = 0;
|
||||
for (auto&& m : meta)
|
||||
{
|
||||
switch (m.index())
|
||||
{
|
||||
case cv::GMetaArg::index_of<cv::GMatDesc>():
|
||||
PyTuple_SetItem(args.get(), idx, pyopencv_from(cv::util::get<cv::GMatDesc>(m)));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::GScalarDesc>():
|
||||
PyTuple_SetItem(args.get(), idx, pyopencv_from(cv::util::get<cv::GScalarDesc>(m)));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::GArrayDesc>():
|
||||
PyTuple_SetItem(args.get(), idx, pyopencv_from(cv::util::get<cv::GArrayDesc>(m)));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::GOpaqueDesc>():
|
||||
PyTuple_SetItem(args.get(), idx, pyopencv_from(cv::util::get<cv::GOpaqueDesc>(m)));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::util::monostate>():
|
||||
PyTuple_SetItem(args.get(), idx, pyopencv_from(gargs[idx]));
|
||||
break;
|
||||
case cv::GMetaArg::index_of<cv::GFrameDesc>():
|
||||
util::throw_error(std::logic_error("GFrame isn't supported for custom operation"));
|
||||
break;
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
unpackMetasToTuple(meta, gargs, args);
|
||||
// NB: Doesn't increase reference counter (false).
|
||||
// In case PyObject_CallObject return NULL, do nothing in destructor.
|
||||
cv::detail::PyObjectHolder result(
|
||||
@@ -860,6 +930,10 @@ static PyObject* pyopencv_cv_gapi_kernels(PyObject* , PyObject* py_args, PyObjec
|
||||
"Python kernel should contain run, please use cv.gapi.kernel to define kernel");
|
||||
return NULL;
|
||||
}
|
||||
PyObject* setup = nullptr;
|
||||
if (PyObject_HasAttrString(user_kernel, "setup")) {
|
||||
setup = PyObject_GetAttrString(user_kernel, "setup");
|
||||
}
|
||||
|
||||
std::string id;
|
||||
if (!pyopencv_to(id_obj, id, ArgInfo("id", false)))
|
||||
@@ -869,10 +943,22 @@ static PyObject* pyopencv_cv_gapi_kernels(PyObject* , PyObject* py_args, PyObjec
|
||||
}
|
||||
|
||||
using namespace std::placeholders;
|
||||
gapi::python::GPythonFunctor f(id.c_str(),
|
||||
std::bind(run_py_meta , cv::detail::PyObjectHolder{out_meta}, _1, _2),
|
||||
std::bind(run_py_kernel, cv::detail::PyObjectHolder{run} , _1));
|
||||
pkg.include(f);
|
||||
|
||||
if (setup)
|
||||
{
|
||||
gapi::python::GPythonFunctor f(
|
||||
id.c_str(), std::bind(run_py_meta, cv::detail::PyObjectHolder{out_meta}, _1, _2),
|
||||
std::bind(run_py_kernel, cv::detail::PyObjectHolder{run}, _1),
|
||||
std::bind(setup_py, cv::detail::PyObjectHolder{setup}, _1, _2));
|
||||
pkg.include(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
gapi::python::GPythonFunctor f(
|
||||
id.c_str(), std::bind(run_py_meta, cv::detail::PyObjectHolder{out_meta}, _1, _2),
|
||||
std::bind(run_py_kernel, cv::detail::PyObjectHolder{run}, _1));
|
||||
pkg.include(f);
|
||||
}
|
||||
}
|
||||
return pyopencv_from(pkg);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
switch(type) { \
|
||||
LIST_G(HC, HC) \
|
||||
default: \
|
||||
GAPI_Assert(false && "Unsupported type"); \
|
||||
GAPI_Error("Unsupported type"); \
|
||||
}
|
||||
|
||||
using cv::gapi::wip::draw::Prim;
|
||||
@@ -36,6 +36,7 @@ WRAP_ARGS(float , cv::gapi::ArgType::CV_FLOAT, G) \
|
||||
WRAP_ARGS(std::string , cv::gapi::ArgType::CV_STRING, G) \
|
||||
WRAP_ARGS(cv::Point , cv::gapi::ArgType::CV_POINT, G) \
|
||||
WRAP_ARGS(cv::Point2f , cv::gapi::ArgType::CV_POINT2F, G) \
|
||||
WRAP_ARGS(cv::Point3f , cv::gapi::ArgType::CV_POINT3F, G) \
|
||||
WRAP_ARGS(cv::Size , cv::gapi::ArgType::CV_SIZE, G) \
|
||||
WRAP_ARGS(cv::Rect , cv::gapi::ArgType::CV_RECT, G) \
|
||||
WRAP_ARGS(cv::Scalar , cv::gapi::ArgType::CV_SCALAR, G) \
|
||||
@@ -53,6 +54,7 @@ WRAP_ARGS(float , cv::gapi::ArgType::CV_FLOAT, G) \
|
||||
WRAP_ARGS(std::string , cv::gapi::ArgType::CV_STRING, G) \
|
||||
WRAP_ARGS(cv::Point , cv::gapi::ArgType::CV_POINT, G) \
|
||||
WRAP_ARGS(cv::Point2f , cv::gapi::ArgType::CV_POINT2F, G) \
|
||||
WRAP_ARGS(cv::Point3f , cv::gapi::ArgType::CV_POINT3F, G) \
|
||||
WRAP_ARGS(cv::Size , cv::gapi::ArgType::CV_SIZE, G) \
|
||||
WRAP_ARGS(cv::GArg , cv::gapi::ArgType::CV_ANY, G) \
|
||||
WRAP_ARGS(cv::Rect , cv::gapi::ArgType::CV_RECT, G2) \
|
||||
@@ -70,6 +72,7 @@ enum ArgType {
|
||||
CV_STRING,
|
||||
CV_POINT,
|
||||
CV_POINT2F,
|
||||
CV_POINT3F,
|
||||
CV_SIZE,
|
||||
CV_RECT,
|
||||
CV_SCALAR,
|
||||
@@ -154,7 +157,7 @@ public:
|
||||
SWITCH(m_arg.index(), GOPAQUE_TYPE_LIST_G, HC)
|
||||
#undef HC
|
||||
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
|
||||
GAPI_WRAP gapi::ArgType type() { return m_type; }
|
||||
@@ -192,7 +195,7 @@ public:
|
||||
SWITCH(m_arg.index(), GARRAY_TYPE_LIST_G, HC)
|
||||
#undef HC
|
||||
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
|
||||
GAPI_WRAP gapi::ArgType type() { return m_type; }
|
||||
|
||||
@@ -79,5 +79,6 @@ namespace streaming
|
||||
namespace detail
|
||||
{
|
||||
gapi::GNetParam GAPI_EXPORTS_W strip(gapi::ie::PyParams params);
|
||||
gapi::GNetParam GAPI_EXPORTS_W strip(gapi::onnx::PyParams params);
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
@@ -164,7 +164,7 @@ try:
|
||||
|
||||
def generate_random_points(self, sz):
|
||||
arr = np.random.random(sz).astype(np.float32).T
|
||||
return list(zip(arr[0], arr[1]))
|
||||
return list(zip(*[arr[i] for i in range(sz[1])]))
|
||||
|
||||
|
||||
def test_kmeans_2d(self):
|
||||
@@ -194,6 +194,33 @@ try:
|
||||
self.assertEqual(K, len(centers))
|
||||
|
||||
|
||||
def test_kmeans_3d(self):
|
||||
# K-means 3D params
|
||||
count = 100
|
||||
sz = (count, 3)
|
||||
amount = sz[0]
|
||||
K = 5
|
||||
flags = cv.KMEANS_RANDOM_CENTERS
|
||||
attempts = 1
|
||||
criteria = (cv.TERM_CRITERIA_MAX_ITER + cv.TERM_CRITERIA_EPS, 30, 0)
|
||||
in_vector = self.generate_random_points(sz)
|
||||
in_labels = []
|
||||
|
||||
# G-API
|
||||
data = cv.GArrayT(cv.gapi.CV_POINT3F)
|
||||
best_labels = cv.GArrayT(cv.gapi.CV_INT)
|
||||
|
||||
compactness, out_labels, centers = cv.gapi.kmeans(data, K, best_labels, criteria, attempts, flags)
|
||||
comp = cv.GComputation(cv.GIn(data, best_labels), cv.GOut(compactness, out_labels, centers))
|
||||
|
||||
compact, labels, centers = comp.apply(cv.gin(in_vector, in_labels))
|
||||
|
||||
# Assert
|
||||
self.assertTrue(compact >= 0)
|
||||
self.assertEqual(amount, len(labels))
|
||||
self.assertEqual(K, len(centers))
|
||||
|
||||
|
||||
except unittest.SkipTest as e:
|
||||
|
||||
message = str(e)
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import numpy as np
|
||||
import cv2 as cv
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from tests_common import NewOpenCVTests
|
||||
|
||||
|
||||
try:
|
||||
|
||||
if sys.version_info[:2] < (3, 0):
|
||||
raise unittest.SkipTest('Python 2.x is not supported')
|
||||
|
||||
CLASSIFICATION_MODEL_PATH = "onnx_models/vision/classification/squeezenet/model/squeezenet1.0-9.onnx"
|
||||
|
||||
testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False))
|
||||
|
||||
class test_gapi_infer(NewOpenCVTests):
|
||||
def find_dnn_file(self, filename, required=None):
|
||||
if not required:
|
||||
required = testdata_required
|
||||
return self.find_file(filename, [os.environ.get('OPENCV_DNN_TEST_DATA_PATH', os.getcwd()),
|
||||
os.environ['OPENCV_TEST_DATA_PATH']],
|
||||
required=required)
|
||||
|
||||
def test_onnx_classification(self):
|
||||
model_path = self.find_dnn_file(CLASSIFICATION_MODEL_PATH)
|
||||
|
||||
if model_path is None:
|
||||
raise unittest.SkipTest("Missing DNN test file")
|
||||
|
||||
in_mat = cv.imread(
|
||||
self.find_file("cv/dpm/cat.png",
|
||||
[os.environ.get('OPENCV_TEST_DATA_PATH')]))
|
||||
|
||||
g_in = cv.GMat()
|
||||
g_infer_inputs = cv.GInferInputs()
|
||||
g_infer_inputs.setInput("data_0", g_in)
|
||||
g_infer_out = cv.gapi.infer("squeeze-net", g_infer_inputs)
|
||||
g_out = g_infer_out.at("softmaxout_1")
|
||||
|
||||
comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_out))
|
||||
|
||||
net = cv.gapi.onnx.params("squeeze-net", model_path)
|
||||
try:
|
||||
out_gapi = comp.apply(cv.gin(in_mat), cv.gapi.compile_args(cv.gapi.networks(net)))
|
||||
except cv.error as err:
|
||||
if err.args[0] == "G-API has been compiled without ONNX support":
|
||||
raise unittest.SkipTest("G-API has been compiled without ONNX support")
|
||||
else:
|
||||
raise
|
||||
|
||||
self.assertEqual((1, 1000, 1, 1), out_gapi.shape)
|
||||
|
||||
|
||||
except unittest.SkipTest as e:
|
||||
|
||||
message = str(e)
|
||||
|
||||
class TestSkip(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.skipTest('Skip tests: ' + message)
|
||||
|
||||
def test_skip():
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
NewOpenCVTests.bootstrap()
|
||||
@@ -432,7 +432,7 @@ try:
|
||||
with self.assertRaises(Exception): create_op([cv.GMat, int], [cv.GMat]).on(cv.GMat())
|
||||
|
||||
|
||||
def test_stateful_kernel(self):
|
||||
def test_state_in_class(self):
|
||||
@cv.gapi.op('custom.sum', in_types=[cv.GArray.Int], out_types=[cv.GOpaque.Int])
|
||||
class GSum:
|
||||
@staticmethod
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import numpy as np
|
||||
import cv2 as cv
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from tests_common import NewOpenCVTests
|
||||
|
||||
|
||||
try:
|
||||
|
||||
if sys.version_info[:2] < (3, 0):
|
||||
raise unittest.SkipTest('Python 2.x is not supported')
|
||||
|
||||
|
||||
class CounterState:
|
||||
def __init__(self):
|
||||
self.counter = 0
|
||||
|
||||
|
||||
@cv.gapi.op('stateful_counter',
|
||||
in_types=[cv.GOpaque.Int],
|
||||
out_types=[cv.GOpaque.Int])
|
||||
class GStatefulCounter:
|
||||
"""Accumulate state counter on every call"""
|
||||
|
||||
@staticmethod
|
||||
def outMeta(desc):
|
||||
return cv.empty_gopaque_desc()
|
||||
|
||||
|
||||
@cv.gapi.kernel(GStatefulCounter)
|
||||
class GStatefulCounterImpl:
|
||||
"""Implementation for GStatefulCounter operation."""
|
||||
|
||||
@staticmethod
|
||||
def setup(desc):
|
||||
return CounterState()
|
||||
|
||||
@staticmethod
|
||||
def run(value, state):
|
||||
state.counter += value
|
||||
return state.counter
|
||||
|
||||
|
||||
class gapi_sample_pipelines(NewOpenCVTests):
|
||||
def test_stateful_kernel_single_instance(self):
|
||||
g_in = cv.GOpaque.Int()
|
||||
g_out = GStatefulCounter.on(g_in)
|
||||
comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_out))
|
||||
pkg = cv.gapi.kernels(GStatefulCounterImpl)
|
||||
|
||||
nums = [i for i in range(10)]
|
||||
acc = 0
|
||||
for v in nums:
|
||||
acc = comp.apply(cv.gin(v), args=cv.gapi.compile_args(pkg))
|
||||
|
||||
self.assertEqual(sum(nums), acc)
|
||||
|
||||
|
||||
def test_stateful_kernel_multiple_instances(self):
|
||||
# NB: Every counter has his own independent state.
|
||||
g_in = cv.GOpaque.Int()
|
||||
g_out0 = GStatefulCounter.on(g_in)
|
||||
g_out1 = GStatefulCounter.on(g_in)
|
||||
comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_out0, g_out1))
|
||||
pkg = cv.gapi.kernels(GStatefulCounterImpl)
|
||||
|
||||
nums = [i for i in range(10)]
|
||||
acc0 = acc1 = 0
|
||||
for v in nums:
|
||||
acc0, acc1 = comp.apply(cv.gin(v), args=cv.gapi.compile_args(pkg))
|
||||
|
||||
ref = sum(nums)
|
||||
self.assertEqual(ref, acc0)
|
||||
self.assertEqual(ref, acc1)
|
||||
|
||||
|
||||
def test_stateful_throw_setup(self):
|
||||
@cv.gapi.kernel(GStatefulCounter)
|
||||
class GThrowStatefulCounterImpl:
|
||||
"""Implementation for GStatefulCounter operation
|
||||
that throw exception in setup method"""
|
||||
|
||||
@staticmethod
|
||||
def setup(desc):
|
||||
raise Exception('Throw from setup method')
|
||||
|
||||
@staticmethod
|
||||
def run(value, state):
|
||||
raise Exception('Unreachable')
|
||||
|
||||
g_in = cv.GOpaque.Int()
|
||||
g_out = GStatefulCounter.on(g_in)
|
||||
comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_out))
|
||||
pkg = cv.gapi.kernels(GThrowStatefulCounterImpl)
|
||||
|
||||
with self.assertRaises(Exception): comp.apply(cv.gin(42),
|
||||
args=cv.gapi.compile_args(pkg))
|
||||
|
||||
|
||||
def test_stateful_reset(self):
|
||||
g_in = cv.GOpaque.Int()
|
||||
g_out = GStatefulCounter.on(g_in)
|
||||
comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_out))
|
||||
pkg = cv.gapi.kernels(GStatefulCounterImpl)
|
||||
|
||||
cc = comp.compileStreaming(args=cv.gapi.compile_args(pkg))
|
||||
|
||||
cc.setSource(cv.gin(1))
|
||||
cc.start()
|
||||
for i in range(1, 10):
|
||||
_, actual = cc.pull()
|
||||
self.assertEqual(i, actual)
|
||||
cc.stop()
|
||||
|
||||
cc.setSource(cv.gin(2))
|
||||
cc.start()
|
||||
for i in range(2, 10, 2):
|
||||
_, actual = cc.pull()
|
||||
self.assertEqual(i, actual)
|
||||
cc.stop()
|
||||
|
||||
|
||||
except unittest.SkipTest as e:
|
||||
|
||||
message = str(e)
|
||||
|
||||
class TestSkip(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.skipTest('Skip tests: ' + message)
|
||||
|
||||
def test_skip():
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
NewOpenCVTests.bootstrap()
|
||||
@@ -18,8 +18,9 @@ try:
|
||||
|
||||
def test_garray_type(self):
|
||||
types = [cv.gapi.CV_BOOL , cv.gapi.CV_INT , cv.gapi.CV_DOUBLE , cv.gapi.CV_FLOAT,
|
||||
cv.gapi.CV_STRING, cv.gapi.CV_POINT , cv.gapi.CV_POINT2F, cv.gapi.CV_SIZE ,
|
||||
cv.gapi.CV_RECT , cv.gapi.CV_SCALAR, cv.gapi.CV_MAT , cv.gapi.CV_GMAT]
|
||||
cv.gapi.CV_STRING, cv.gapi.CV_POINT , cv.gapi.CV_POINT2F, cv.gapi.CV_POINT3F ,
|
||||
cv.gapi.CV_SIZE , cv.gapi.CV_RECT , cv.gapi.CV_SCALAR , cv.gapi.CV_MAT ,
|
||||
cv.gapi.CV_GMAT]
|
||||
|
||||
for t in types:
|
||||
g_array = cv.GArrayT(t)
|
||||
@@ -27,9 +28,9 @@ try:
|
||||
|
||||
|
||||
def test_gopaque_type(self):
|
||||
types = [cv.gapi.CV_BOOL , cv.gapi.CV_INT , cv.gapi.CV_DOUBLE , cv.gapi.CV_FLOAT,
|
||||
cv.gapi.CV_STRING, cv.gapi.CV_POINT , cv.gapi.CV_POINT2F, cv.gapi.CV_SIZE ,
|
||||
cv.gapi.CV_RECT]
|
||||
types = [cv.gapi.CV_BOOL , cv.gapi.CV_INT , cv.gapi.CV_DOUBLE , cv.gapi.CV_FLOAT ,
|
||||
cv.gapi.CV_STRING, cv.gapi.CV_POINT, cv.gapi.CV_POINT2F, cv.gapi.CV_POINT3F,
|
||||
cv.gapi.CV_SIZE , cv.gapi.CV_RECT]
|
||||
|
||||
for t in types:
|
||||
g_opaque = cv.GOpaqueT(t)
|
||||
|
||||
+2
-4
@@ -20,13 +20,11 @@
|
||||
|
||||
#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 <d3d11.h>
|
||||
#pragma comment(lib, "dxgi")
|
||||
#undef NOMINMAX
|
||||
#undef D3D11_NO_HELPERS
|
||||
#endif // HAVE_D3D11
|
||||
@@ -499,11 +497,11 @@ int main(int argc, char *argv[]) {
|
||||
std::tie(dx11_dev, dx11_ctx) = create_device_with_ctx(intel_adapter.get());
|
||||
gpu_accel_device = cv::util::make_optional(
|
||||
cv::gapi::wip::onevpl::create_dx11_device(
|
||||
reinterpret_cast<void*>(dx11_dev.get()),
|
||||
reinterpret_cast<void*>(dx11_dev.release()),
|
||||
"GPU"));
|
||||
gpu_accel_ctx = cv::util::make_optional(
|
||||
cv::gapi::wip::onevpl::create_dx11_context(
|
||||
reinterpret_cast<void*>(dx11_ctx.get())));
|
||||
reinterpret_cast<void*>(dx11_ctx.release())));
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
#ifdef __linux__
|
||||
@@ -0,0 +1,106 @@
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <cctype>
|
||||
#include <tuple>
|
||||
#include <memory>
|
||||
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <opencv2/gapi.hpp>
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
#include <opencv2/gapi/gpu/ggpukernel.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/source.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/default.hpp>
|
||||
#include <opencv2/highgui.hpp> // CommandLineParser
|
||||
#include <opencv2/gapi/ocl/core.hpp>
|
||||
|
||||
const std::string about =
|
||||
"This is an example presents decoding on GPU using VPL Source and passing it to OpenCL backend";
|
||||
const std::string keys =
|
||||
"{ h help | | Print this help message }"
|
||||
"{ input | | Path to the input video file. Use .avi extension }"
|
||||
"{ accel_mode | mfxImplDescription.AccelerationMode:MFX_ACCEL_MODE_VIA_D3D11 | Acceleration mode for VPL }";
|
||||
|
||||
namespace {
|
||||
namespace cfg {
|
||||
// FIXME: Move OneVPL arguments parser to a single place
|
||||
typename cv::gapi::wip::onevpl::CfgParam create_from_string(const std::string &line);
|
||||
} // namespace cfg
|
||||
} // anonymous namespace
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
cv::CommandLineParser cmd(argc, argv, keys);
|
||||
cmd.about(about);
|
||||
if (cmd.has("help")) {
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get file name
|
||||
const auto input = cmd.get<std::string>("input");
|
||||
const auto accel_mode = cmd.get<std::string>("accel_mode");
|
||||
|
||||
// Create VPL config
|
||||
std::vector<cv::gapi::wip::onevpl::CfgParam> source_cfgs;
|
||||
source_cfgs.push_back(cfg::create_from_string(accel_mode));
|
||||
|
||||
// Create VPL-based source
|
||||
std::shared_ptr<cv::gapi::wip::onevpl::IDeviceSelector> default_device_selector =
|
||||
cv::gapi::wip::onevpl::getDefaultDeviceSelector(source_cfgs);
|
||||
|
||||
cv::gapi::wip::IStreamSource::Ptr source = cv::gapi::wip::make_onevpl_src(input, source_cfgs,
|
||||
default_device_selector);
|
||||
|
||||
// Build the graph
|
||||
cv::GFrame in; // input frame from VPL source
|
||||
auto bgr_gmat = cv::gapi::streaming::BGR(in); // conversion from VPL source frame to BGR UMat
|
||||
auto out = cv::gapi::blur(bgr_gmat, cv::Size(4,4)); // ocl kernel of blur operation
|
||||
|
||||
cv::GStreamingCompiled pipeline = cv::GComputation(cv::GIn(in), cv::GOut(out))
|
||||
.compileStreaming(cv::compile_args(cv::gapi::core::ocl::kernels()));
|
||||
pipeline.setSource(std::move(source));
|
||||
|
||||
// The execution part
|
||||
size_t frames = 0u;
|
||||
cv::TickMeter tm;
|
||||
cv::Mat outMat;
|
||||
|
||||
pipeline.start();
|
||||
tm.start();
|
||||
|
||||
while (pipeline.pull(cv::gout(outMat))) {
|
||||
cv::imshow("OutVideo", outMat);
|
||||
cv::waitKey(1);
|
||||
++frames;
|
||||
}
|
||||
tm.stop();
|
||||
std::cout << "Processed " << frames << " frames" << " (" << frames / tm.getTimeSec() << " FPS)" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
namespace cfg {
|
||||
typename cv::gapi::wip::onevpl::CfgParam create_from_string(const std::string &line) {
|
||||
using namespace cv::gapi::wip;
|
||||
|
||||
if (line.empty()) {
|
||||
throw std::runtime_error("Cannot parse CfgParam from emply line");
|
||||
}
|
||||
|
||||
std::string::size_type name_endline_pos = line.find(':');
|
||||
if (name_endline_pos == std::string::npos) {
|
||||
throw std::runtime_error("Cannot parse CfgParam from: " + line +
|
||||
"\nExpected separator \":\"");
|
||||
}
|
||||
|
||||
std::string name = line.substr(0, name_endline_pos);
|
||||
std::string value = line.substr(name_endline_pos + 1);
|
||||
|
||||
return cv::gapi::wip::onevpl::CfgParam::create(name, value,
|
||||
/* vpp params strongly optional */
|
||||
name.find("vpp.") == std::string::npos);
|
||||
}
|
||||
} // namespace cfg
|
||||
} // anonymous namespace
|
||||
@@ -175,6 +175,17 @@ static PLMode strToPLMode(const std::string& mode_str) {
|
||||
}
|
||||
}
|
||||
|
||||
static cv::gapi::ie::InferMode strToInferMode(const std::string& infer_mode) {
|
||||
if (infer_mode == "async") {
|
||||
return cv::gapi::ie::InferMode::Async;
|
||||
} else if (infer_mode == "sync") {
|
||||
return cv::gapi::ie::InferMode::Sync;
|
||||
} else {
|
||||
throw std::logic_error("Unsupported Infer mode: " + infer_mode +
|
||||
"\nPlease chose between: async and sync");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
CallParams read<CallParams>(const cv::FileNode& fn) {
|
||||
auto name =
|
||||
@@ -190,6 +201,15 @@ CallParams read<CallParams>(const cv::FileNode& fn) {
|
||||
return CallParams{std::move(name), static_cast<size_t>(call_every_nth)};
|
||||
}
|
||||
|
||||
template <typename V>
|
||||
std::map<std::string, V> readMap(const cv::FileNode& fn) {
|
||||
std::map<std::string, V> map;
|
||||
for (auto item : fn) {
|
||||
map.emplace(item.name(), read<V>(item));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
template <>
|
||||
InferParams read<InferParams>(const cv::FileNode& fn) {
|
||||
auto name =
|
||||
@@ -200,7 +220,13 @@ InferParams read<InferParams>(const cv::FileNode& fn) {
|
||||
params.device = check_and_read<std::string>(fn, "device", name);
|
||||
params.input_layers = readList<std::string>(fn, "input_layers", name);
|
||||
params.output_layers = readList<std::string>(fn, "output_layers", name);
|
||||
params.config = readMap<std::string>(fn["config"]);
|
||||
|
||||
auto out_prec_str = readOpt<std::string>(fn["output_precision"]);
|
||||
if (out_prec_str.has_value()) {
|
||||
params.out_precision =
|
||||
cv::optional<int>(strToPrecision(out_prec_str.value()));
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -273,7 +299,8 @@ int main(int argc, char* argv[]) {
|
||||
"{ drop_frames | false | Drop frames if they come earlier than pipeline is completed. }"
|
||||
"{ exec_list | | A comma-separated list of pipelines that"
|
||||
" will be executed. Spaces around commas"
|
||||
" are prohibited. }";
|
||||
" are prohibited. }"
|
||||
"{ infer_mode | async | OpenVINO inference mode (async/sync). }";
|
||||
|
||||
cv::CommandLineParser cmd(argc, argv, keys);
|
||||
if (cmd.has("help")) {
|
||||
@@ -289,6 +316,7 @@ int main(int argc, char* argv[]) {
|
||||
const auto qc = cmd.get<int>("qc");
|
||||
const auto app_mode = strToAppMode(cmd.get<std::string>("app_mode"));
|
||||
const auto exec_str = cmd.get<std::string>("exec_list");
|
||||
const auto infer_mode = strToInferMode(cmd.get<std::string>("infer_mode"));
|
||||
const auto drop_frames = cmd.get<bool>("drop_frames");
|
||||
|
||||
cv::FileStorage fs;
|
||||
@@ -309,20 +337,24 @@ int main(int argc, char* argv[]) {
|
||||
cv::FileStorage::MEMORY);
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> config;
|
||||
std::map<std::string, std::string> gconfig;
|
||||
if (!load_config.empty()) {
|
||||
loadConfig(load_config, config);
|
||||
loadConfig(load_config, gconfig);
|
||||
}
|
||||
// NB: Takes priority over config from file
|
||||
if (!cached_dir.empty()) {
|
||||
config =
|
||||
gconfig =
|
||||
std::map<std::string, std::string>{{"CACHE_DIR", cached_dir}};
|
||||
}
|
||||
|
||||
const double work_time_ms =
|
||||
check_and_read<double>(fs, "work_time", "Config");
|
||||
if (work_time_ms < 0) {
|
||||
throw std::logic_error("work_time must be positive");
|
||||
auto opt_work_time_ms = readOpt<double>(fs["work_time"]);
|
||||
cv::optional<int64_t> opt_work_time_mcs;
|
||||
if (opt_work_time_ms) {
|
||||
const double work_time_ms = opt_work_time_ms.value();
|
||||
if (work_time_ms < 0) {
|
||||
throw std::logic_error("work_time must be positive");
|
||||
}
|
||||
opt_work_time_mcs = cv::optional<int64_t>(utils::ms_to_mcs(work_time_ms));
|
||||
}
|
||||
|
||||
auto pipelines_fn = check_and_get_fn(fs, "Pipelines", "Config");
|
||||
@@ -341,6 +373,21 @@ int main(int argc, char* argv[]) {
|
||||
for (const auto& name : exec_list) {
|
||||
const auto& pl_fn = check_and_get_fn(pipelines_fn, name, "Pipelines");
|
||||
builder.setName(name);
|
||||
StopCriterion::Ptr stop_criterion;
|
||||
auto opt_num_iters = readOpt<int>(pl_fn["num_iters"]);
|
||||
// NB: num_iters for specific pipeline takes priority over global work_time.
|
||||
if (opt_num_iters) {
|
||||
stop_criterion.reset(new NumItersCriterion(opt_num_iters.value()));
|
||||
} else if (opt_work_time_mcs) {
|
||||
stop_criterion.reset(new ElapsedTimeCriterion(opt_work_time_mcs.value()));
|
||||
} else {
|
||||
throw std::logic_error(
|
||||
"Failed: Pipeline " + name + " doesn't have stop criterion!\n"
|
||||
"Please specify either work_time: <value> in the config root"
|
||||
" or num_iters: <value> for specific pipeline.");
|
||||
}
|
||||
builder.setStopCriterion(std::move(stop_criterion));
|
||||
|
||||
// NB: Set source
|
||||
{
|
||||
const auto& src_fn = check_and_get_fn(pl_fn, "source", name);
|
||||
@@ -371,7 +418,15 @@ int main(int argc, char* argv[]) {
|
||||
builder.addDummy(call_params, read<DummyParams>(node_fn));
|
||||
} else if (node_type == "Infer") {
|
||||
auto infer_params = read<InferParams>(node_fn);
|
||||
infer_params.config = config;
|
||||
try {
|
||||
utils::mergeMapWith(infer_params.config, gconfig);
|
||||
} catch (std::exception& e) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to merge global and local config for Infer node: "
|
||||
<< call_params.name << std::endl << e.what();
|
||||
throw std::logic_error(ss.str());
|
||||
}
|
||||
infer_params.mode = infer_mode;
|
||||
builder.addInfer(call_params, infer_params);
|
||||
} else {
|
||||
throw std::logic_error("Unsupported node type: " + node_type);
|
||||
@@ -428,7 +483,7 @@ int main(int argc, char* argv[]) {
|
||||
for (size_t i = 0; i < pipelines.size(); ++i) {
|
||||
threads[i] = std::thread([&, i]() {
|
||||
try {
|
||||
pipelines[i]->run(work_time_ms);
|
||||
pipelines[i]->run();
|
||||
} catch (...) {
|
||||
eptrs[i] = std::current_exception();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
const bool drop_frames);
|
||||
bool pull(cv::gapi::wip::Data& data) override;
|
||||
cv::GMetaArg descr_of() const override;
|
||||
double latency() const { return m_latency; };
|
||||
|
||||
private:
|
||||
double m_latency;
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
#ifndef OPENCV_GAPI_PIPELINE_MODELING_TOOL_PIPELINE_HPP
|
||||
#define OPENCV_GAPI_PIPELINE_MODELING_TOOL_PIPELINE_HPP
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
struct PerfReport {
|
||||
std::string name;
|
||||
double avg_latency = 0.0;
|
||||
double throughput = 0.0;
|
||||
int64_t first_run_latency = 0;
|
||||
int64_t elapsed = 0;
|
||||
int64_t compilation_time = 0;
|
||||
std::string name;
|
||||
double avg_latency = 0.0;
|
||||
int64_t min_latency = 0;
|
||||
int64_t max_latency = 0;
|
||||
int64_t first_latency = 0;
|
||||
double throughput = 0.0;
|
||||
int64_t elapsed = 0;
|
||||
int64_t warmup_time = 0;
|
||||
int64_t num_late_frames = 0;
|
||||
std::vector<int64_t> latencies;
|
||||
|
||||
std::string toStr(bool expanded = false) const;
|
||||
@@ -15,17 +20,19 @@ struct PerfReport {
|
||||
|
||||
std::string PerfReport::toStr(bool expand) const {
|
||||
std::stringstream ss;
|
||||
ss << name << ": Compilation time: " << compilation_time << " ms; "
|
||||
<< "Average latency: " << avg_latency << " ms; Throughput: "
|
||||
<< throughput << " FPS; First latency: "
|
||||
<< first_run_latency << " ms";
|
||||
|
||||
ss << name << ": \n"
|
||||
<< " Warm up time: " << warmup_time << " ms\n"
|
||||
<< " Execution time: " << elapsed << " ms\n"
|
||||
<< " Frames: " << num_late_frames << "/" << latencies.size() << " (late/all)\n"
|
||||
<< " Latency:\n"
|
||||
<< " first: " << first_latency << " ms\n"
|
||||
<< " min: " << min_latency << " ms\n"
|
||||
<< " max: " << max_latency << " ms\n"
|
||||
<< " avg: " << std::fixed << std::setprecision(3) << avg_latency << " ms\n"
|
||||
<< " Throughput: " << std::fixed << std::setprecision(3) << throughput << " FPS";
|
||||
if (expand) {
|
||||
ss << "\nTotal processed frames: " << latencies.size()
|
||||
<< "\nTotal elapsed time: " << elapsed << " ms" << std::endl;
|
||||
for (size_t i = 0; i < latencies.size(); ++i) {
|
||||
ss << std::endl;
|
||||
ss << "Frame:" << i << "\nLatency: "
|
||||
ss << "\nFrame:" << i << "\nLatency: "
|
||||
<< latencies[i] << " ms";
|
||||
}
|
||||
}
|
||||
@@ -33,74 +40,103 @@ std::string PerfReport::toStr(bool expand) const {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
class StopCriterion {
|
||||
public:
|
||||
using Ptr = std::unique_ptr<StopCriterion>;
|
||||
|
||||
virtual void start() = 0;
|
||||
virtual void iter() = 0;
|
||||
virtual bool done() = 0;
|
||||
virtual ~StopCriterion() = default;
|
||||
};
|
||||
|
||||
class Pipeline {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<Pipeline>;
|
||||
|
||||
Pipeline(std::string&& name,
|
||||
cv::GComputation&& comp,
|
||||
cv::gapi::wip::IStreamSource::Ptr&& src,
|
||||
cv::GCompileArgs&& args,
|
||||
const size_t num_outputs);
|
||||
Pipeline(std::string&& name,
|
||||
cv::GComputation&& comp,
|
||||
std::shared_ptr<DummySource>&& src,
|
||||
StopCriterion::Ptr stop_criterion,
|
||||
cv::GCompileArgs&& args,
|
||||
const size_t num_outputs);
|
||||
|
||||
void compile();
|
||||
void run(double work_time_ms);
|
||||
void run();
|
||||
|
||||
const PerfReport& report() const;
|
||||
const std::string& name() const { return m_name;}
|
||||
|
||||
virtual ~Pipeline() = default;
|
||||
|
||||
protected:
|
||||
struct RunPerf {
|
||||
int64_t elapsed = 0;
|
||||
std::vector<int64_t> latencies;
|
||||
};
|
||||
virtual void _compile() = 0;
|
||||
virtual int64_t run_iter() = 0;
|
||||
virtual void init() {};
|
||||
virtual void deinit() {};
|
||||
|
||||
virtual void _compile() = 0;
|
||||
virtual RunPerf _run(double work_time_ms) = 0;
|
||||
|
||||
std::string m_name;
|
||||
cv::GComputation m_comp;
|
||||
cv::gapi::wip::IStreamSource::Ptr m_src;
|
||||
cv::GCompileArgs m_args;
|
||||
size_t m_num_outputs;
|
||||
PerfReport m_perf;
|
||||
std::string m_name;
|
||||
cv::GComputation m_comp;
|
||||
std::shared_ptr<DummySource> m_src;
|
||||
StopCriterion::Ptr m_stop_criterion;
|
||||
cv::GCompileArgs m_args;
|
||||
size_t m_num_outputs;
|
||||
PerfReport m_perf;
|
||||
};
|
||||
|
||||
Pipeline::Pipeline(std::string&& name,
|
||||
cv::GComputation&& comp,
|
||||
cv::gapi::wip::IStreamSource::Ptr&& src,
|
||||
cv::GCompileArgs&& args,
|
||||
const size_t num_outputs)
|
||||
Pipeline::Pipeline(std::string&& name,
|
||||
cv::GComputation&& comp,
|
||||
std::shared_ptr<DummySource>&& src,
|
||||
StopCriterion::Ptr stop_criterion,
|
||||
cv::GCompileArgs&& args,
|
||||
const size_t num_outputs)
|
||||
: m_name(std::move(name)),
|
||||
m_comp(std::move(comp)),
|
||||
m_src(std::move(src)),
|
||||
m_stop_criterion(std::move(stop_criterion)),
|
||||
m_args(std::move(args)),
|
||||
m_num_outputs(num_outputs) {
|
||||
m_perf.name = m_name;
|
||||
}
|
||||
|
||||
void Pipeline::compile() {
|
||||
m_perf.compilation_time =
|
||||
m_perf.warmup_time =
|
||||
utils::measure<std::chrono::milliseconds>([this]() {
|
||||
_compile();
|
||||
});
|
||||
}
|
||||
|
||||
void Pipeline::run(double work_time_ms) {
|
||||
auto run_perf = _run(work_time_ms);
|
||||
void Pipeline::run() {
|
||||
using namespace std::chrono;
|
||||
|
||||
m_perf.elapsed = run_perf.elapsed;
|
||||
m_perf.latencies = std::move(run_perf.latencies);
|
||||
init();
|
||||
auto start = high_resolution_clock::now();
|
||||
m_stop_criterion->start();
|
||||
while (true) {
|
||||
m_perf.latencies.push_back(run_iter());
|
||||
m_perf.elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - start).count();
|
||||
m_stop_criterion->iter();
|
||||
|
||||
if (m_stop_criterion->done()) {
|
||||
deinit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_perf.avg_latency = utils::avg(m_perf.latencies);
|
||||
m_perf.min_latency = utils::min(m_perf.latencies);
|
||||
m_perf.max_latency = utils::max(m_perf.latencies);
|
||||
m_perf.first_latency = m_perf.latencies[0];
|
||||
|
||||
// NB: Count how many executions don't fit into camera latency interval.
|
||||
m_perf.num_late_frames =
|
||||
std::count_if(m_perf.latencies.begin(), m_perf.latencies.end(),
|
||||
[this](int64_t latency) {
|
||||
return static_cast<double>(latency) > m_src->latency();
|
||||
});
|
||||
|
||||
m_perf.avg_latency =
|
||||
std::accumulate(m_perf.latencies.begin(),
|
||||
m_perf.latencies.end(),
|
||||
0.0) / static_cast<double>(m_perf.latencies.size());
|
||||
m_perf.throughput =
|
||||
(m_perf.latencies.size() / static_cast<double>(m_perf.elapsed)) * 1000;
|
||||
|
||||
m_perf.first_run_latency = m_perf.latencies[0];
|
||||
}
|
||||
|
||||
const PerfReport& Pipeline::report() const {
|
||||
@@ -118,39 +154,31 @@ private:
|
||||
cv::GCompileArgs(m_args));
|
||||
}
|
||||
|
||||
Pipeline::RunPerf _run(double work_time_ms) override {
|
||||
// NB: Setup.
|
||||
virtual void init() override {
|
||||
using namespace std::chrono;
|
||||
// NB: N-1 buffers + timestamp.
|
||||
std::vector<cv::Mat> out_mats(m_num_outputs - 1);
|
||||
int64_t start_ts = -1;
|
||||
cv::GRunArgsP pipeline_outputs;
|
||||
for (auto& m : out_mats) {
|
||||
pipeline_outputs += cv::gout(m);
|
||||
m_out_mats.resize(m_num_outputs - 1);
|
||||
for (auto& m : m_out_mats) {
|
||||
m_pipeline_outputs += cv::gout(m);
|
||||
}
|
||||
pipeline_outputs += cv::gout(start_ts);
|
||||
m_pipeline_outputs += cv::gout(m_start_ts);
|
||||
m_compiled.setSource(m_src);
|
||||
|
||||
// NB: Start execution & measure performance statistics.
|
||||
Pipeline::RunPerf perf;
|
||||
auto start = high_resolution_clock::now();
|
||||
m_compiled.start();
|
||||
while (m_compiled.pull(cv::GRunArgsP{pipeline_outputs})) {
|
||||
int64_t latency = utils::timestamp<milliseconds>() - start_ts;
|
||||
}
|
||||
|
||||
perf.latencies.push_back(latency);
|
||||
perf.elapsed = duration_cast<milliseconds>(
|
||||
high_resolution_clock::now() - start).count();
|
||||
virtual void deinit() override {
|
||||
m_compiled.stop();
|
||||
}
|
||||
|
||||
if (perf.elapsed >= work_time_ms) {
|
||||
m_compiled.stop();
|
||||
break;
|
||||
}
|
||||
};
|
||||
return perf;
|
||||
virtual int64_t run_iter() override {
|
||||
m_compiled.pull(cv::GRunArgsP{m_pipeline_outputs});
|
||||
return utils::timestamp<std::chrono::milliseconds>() - m_start_ts;
|
||||
}
|
||||
|
||||
cv::GStreamingCompiled m_compiled;
|
||||
cv::GRunArgsP m_pipeline_outputs;
|
||||
std::vector<cv::Mat> m_out_mats;
|
||||
int64_t m_start_ts;
|
||||
};
|
||||
|
||||
class RegularPipeline : public Pipeline {
|
||||
@@ -164,37 +192,26 @@ private:
|
||||
cv::GCompileArgs(m_args));
|
||||
}
|
||||
|
||||
Pipeline::RunPerf _run(double work_time_ms) override {
|
||||
// NB: Setup
|
||||
using namespace std::chrono;
|
||||
cv::gapi::wip::Data d;
|
||||
std::vector<cv::Mat> out_mats(m_num_outputs);
|
||||
cv::GRunArgsP pipeline_outputs;
|
||||
for (auto& m : out_mats) {
|
||||
pipeline_outputs += cv::gout(m);
|
||||
virtual void init() override {
|
||||
m_out_mats.resize(m_num_outputs);
|
||||
for (auto& m : m_out_mats) {
|
||||
m_pipeline_outputs += cv::gout(m);
|
||||
}
|
||||
|
||||
// NB: Start execution & measure performance statistics.
|
||||
Pipeline::RunPerf perf;
|
||||
auto start = high_resolution_clock::now();
|
||||
while (m_src->pull(d)) {
|
||||
auto in_mat = cv::util::get<cv::Mat>(d);
|
||||
int64_t latency = utils::measure<milliseconds>([&]{
|
||||
m_compiled(cv::gin(in_mat), cv::GRunArgsP{pipeline_outputs});
|
||||
});
|
||||
|
||||
perf.latencies.push_back(latency);
|
||||
perf.elapsed = duration_cast<milliseconds>(
|
||||
high_resolution_clock::now() - start).count();
|
||||
|
||||
if (perf.elapsed >= work_time_ms) {
|
||||
break;
|
||||
}
|
||||
};
|
||||
return perf;
|
||||
}
|
||||
|
||||
cv::GCompiled m_compiled;
|
||||
virtual int64_t run_iter() override {
|
||||
using namespace std::chrono;
|
||||
cv::gapi::wip::Data d;
|
||||
m_src->pull(d);
|
||||
auto in_mat = cv::util::get<cv::Mat>(d);
|
||||
return utils::measure<milliseconds>([&]{
|
||||
m_compiled(cv::gin(in_mat), cv::GRunArgsP{m_pipeline_outputs});
|
||||
});
|
||||
}
|
||||
|
||||
cv::GCompiled m_compiled;
|
||||
cv::GRunArgsP m_pipeline_outputs;
|
||||
std::vector<cv::Mat> m_out_mats;
|
||||
};
|
||||
|
||||
enum class PLMode {
|
||||
|
||||
@@ -258,8 +258,69 @@ struct InferParams {
|
||||
std::vector<std::string> input_layers;
|
||||
std::vector<std::string> output_layers;
|
||||
std::map<std::string, std::string> config;
|
||||
cv::gapi::ie::InferMode mode;
|
||||
cv::util::optional<int> out_precision;
|
||||
};
|
||||
|
||||
class ElapsedTimeCriterion : public StopCriterion {
|
||||
public:
|
||||
ElapsedTimeCriterion(int64_t work_time_mcs);
|
||||
|
||||
void start() override;
|
||||
void iter() override;
|
||||
bool done() override;
|
||||
|
||||
private:
|
||||
int64_t m_work_time_mcs;
|
||||
int64_t m_start_ts = -1;
|
||||
int64_t m_curr_ts = -1;
|
||||
};
|
||||
|
||||
ElapsedTimeCriterion::ElapsedTimeCriterion(int64_t work_time_mcs)
|
||||
: m_work_time_mcs(work_time_mcs) {
|
||||
};
|
||||
|
||||
void ElapsedTimeCriterion::start() {
|
||||
m_start_ts = m_curr_ts = utils::timestamp<std::chrono::microseconds>();
|
||||
}
|
||||
|
||||
void ElapsedTimeCriterion::iter() {
|
||||
m_curr_ts = utils::timestamp<std::chrono::microseconds>();
|
||||
}
|
||||
|
||||
bool ElapsedTimeCriterion::done() {
|
||||
return (m_curr_ts - m_start_ts) >= m_work_time_mcs;
|
||||
}
|
||||
|
||||
class NumItersCriterion : public StopCriterion {
|
||||
public:
|
||||
NumItersCriterion(int64_t num_iters);
|
||||
|
||||
void start() override;
|
||||
void iter() override;
|
||||
bool done() override;
|
||||
|
||||
private:
|
||||
int64_t m_num_iters;
|
||||
int64_t m_curr_iters = 0;
|
||||
};
|
||||
|
||||
NumItersCriterion::NumItersCriterion(int64_t num_iters)
|
||||
: m_num_iters(num_iters) {
|
||||
}
|
||||
|
||||
void NumItersCriterion::start() {
|
||||
m_curr_iters = 0;
|
||||
}
|
||||
|
||||
void NumItersCriterion::iter() {
|
||||
++m_curr_iters;
|
||||
}
|
||||
|
||||
bool NumItersCriterion::done() {
|
||||
return m_curr_iters == m_num_iters;
|
||||
}
|
||||
|
||||
class PipelineBuilder {
|
||||
public:
|
||||
PipelineBuilder();
|
||||
@@ -277,6 +338,7 @@ public:
|
||||
void setDumpFilePath(const std::string& dump);
|
||||
void setQueueCapacity(const size_t qc);
|
||||
void setName(const std::string& name);
|
||||
void setStopCriterion(StopCriterion::Ptr stop_criterion);
|
||||
|
||||
Pipeline::Ptr build();
|
||||
|
||||
@@ -295,15 +357,16 @@ private:
|
||||
std::vector<Edge> output_edges;
|
||||
};
|
||||
|
||||
M<std::string, Node::Ptr> calls_map;
|
||||
std::vector<Node::Ptr> all_calls;
|
||||
M<std::string, Node::Ptr> calls_map;
|
||||
std::vector<Node::Ptr> all_calls;
|
||||
|
||||
cv::gapi::GNetPackage networks;
|
||||
cv::gapi::GKernelPackage kernels;
|
||||
cv::GCompileArgs compile_args;
|
||||
cv::gapi::wip::IStreamSource::Ptr src;
|
||||
PLMode mode = PLMode::STREAMING;
|
||||
std::string name;
|
||||
cv::gapi::GNetPackage networks;
|
||||
cv::gapi::GKernelPackage kernels;
|
||||
cv::GCompileArgs compile_args;
|
||||
std::shared_ptr<DummySource> src;
|
||||
PLMode mode = PLMode::STREAMING;
|
||||
std::string name;
|
||||
StopCriterion::Ptr stop_criterion;
|
||||
};
|
||||
|
||||
std::unique_ptr<State> m_state;
|
||||
@@ -362,6 +425,10 @@ void PipelineBuilder::addInfer(const CallParams& call_params,
|
||||
}
|
||||
|
||||
pp->pluginConfig(infer_params.config);
|
||||
pp->cfgInferMode(infer_params.mode);
|
||||
if (infer_params.out_precision) {
|
||||
pp->cfgOutputPrecision(infer_params.out_precision.value());
|
||||
}
|
||||
m_state->networks += cv::gapi::networks(*pp);
|
||||
|
||||
addCall(call_params,
|
||||
@@ -426,6 +493,10 @@ void PipelineBuilder::setName(const std::string& name) {
|
||||
m_state->name = name;
|
||||
}
|
||||
|
||||
void PipelineBuilder::setStopCriterion(StopCriterion::Ptr stop_criterion) {
|
||||
m_state->stop_criterion = std::move(stop_criterion);
|
||||
}
|
||||
|
||||
static bool visit(Node::Ptr node,
|
||||
std::vector<Node::Ptr>& sorted,
|
||||
std::unordered_map<Node::Ptr, int>& visited) {
|
||||
@@ -584,6 +655,7 @@ Pipeline::Ptr PipelineBuilder::construct() {
|
||||
}
|
||||
}
|
||||
|
||||
GAPI_Assert(m_state->stop_criterion);
|
||||
if (m_state->mode == PLMode::STREAMING) {
|
||||
GAPI_Assert(graph_inputs.size() == 1);
|
||||
GAPI_Assert(cv::util::holds_alternative<cv::GMat>(graph_inputs[0]));
|
||||
@@ -599,6 +671,7 @@ Pipeline::Ptr PipelineBuilder::construct() {
|
||||
cv::GProtoInputArgs{graph_inputs},
|
||||
cv::GProtoOutputArgs{graph_outputs}),
|
||||
std::move(m_state->src),
|
||||
std::move(m_state->stop_criterion),
|
||||
std::move(m_state->compile_args),
|
||||
graph_outputs.size());
|
||||
}
|
||||
@@ -608,6 +681,7 @@ Pipeline::Ptr PipelineBuilder::construct() {
|
||||
cv::GProtoInputArgs{graph_inputs},
|
||||
cv::GProtoOutputArgs{graph_outputs}),
|
||||
std::move(m_state->src),
|
||||
std::move(m_state->stop_criterion),
|
||||
std::move(m_state->compile_args),
|
||||
graph_outputs.size());
|
||||
}
|
||||
|
||||
@@ -26,14 +26,6 @@ def test_error_no_config_exists():
|
||||
assert 'Failed to open config file: not_existing_cfg.yml' in out
|
||||
|
||||
|
||||
def test_error_no_work_time():
|
||||
cfg_file = """\"%YAML:1.0\" """
|
||||
|
||||
exec_str = '{} --cfg={}'.format(pipeline_modeling_tool, cfg_file)
|
||||
out = get_output(exec_str)
|
||||
assert out.startswith('Config must contain field: work_time')
|
||||
|
||||
|
||||
def test_error_work_time_not_positive():
|
||||
cfg_file = """\"%YAML:1.0
|
||||
work_time: -1\" """
|
||||
@@ -77,7 +69,8 @@ def test_error_no_source():
|
||||
cfg_file = """\"%YAML:1.0
|
||||
work_time: 1000
|
||||
Pipelines:
|
||||
PL1:\" """
|
||||
PL1:
|
||||
queue_capacity: 1\" """
|
||||
|
||||
exec_str = '{} --cfg={}'.format(pipeline_modeling_tool, cfg_file)
|
||||
out = get_output(exec_str)
|
||||
@@ -982,3 +975,29 @@ Pipelines:
|
||||
|
||||
check(cfg_file, -3)
|
||||
check(cfg_file, 0)
|
||||
|
||||
|
||||
def test_error_no_worktime_and_num_iters():
|
||||
cfg_file = """\"%YAML:1.0
|
||||
Pipelines:
|
||||
PL1:
|
||||
source:
|
||||
name: 'Src'
|
||||
latency: 20
|
||||
output:
|
||||
dims: [1,1]
|
||||
precision: 'U8'
|
||||
nodes:
|
||||
- name: 'Node0'
|
||||
type: 'Dummy'
|
||||
time: 0.2
|
||||
output:
|
||||
dims: [1,2,3,4]
|
||||
precision: 'U8'
|
||||
edges:
|
||||
- from: 'Src'
|
||||
to: 'Node0'\" """
|
||||
|
||||
exec_str = '{} --cfg={}'.format(pipeline_modeling_tool, cfg_file)
|
||||
out = get_output(exec_str)
|
||||
assert out.startswith('Failed: Pipeline PL1 doesn\'t have stop criterion!')
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef OPENCV_GAPI_PIPELINE_MODELING_TOOL_UTILS_HPP
|
||||
#define OPENCV_GAPI_PIPELINE_MODELING_TOOL_UTILS_HPP
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
#if defined(_WIN32)
|
||||
@@ -91,6 +93,38 @@ typename duration_t::rep timestamp() {
|
||||
return duration_cast<duration_t>(now.time_since_epoch()).count();
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
void mergeMapWith(std::map<K, V>& target, const std::map<K, V>& second) {
|
||||
for (auto&& item : second) {
|
||||
auto it = target.find(item.first);
|
||||
if (it != target.end()) {
|
||||
throw std::logic_error("Error: key: " + it->first + " is already in target map");
|
||||
}
|
||||
target.insert(item);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
double avg(const std::vector<T>& vec) {
|
||||
return std::accumulate(vec.begin(), vec.end(), 0.0) / vec.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T max(const std::vector<T>& vec) {
|
||||
return *std::max_element(vec.begin(), vec.end());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T min(const std::vector<T>& vec) {
|
||||
return *std::min_element(vec.begin(), vec.end());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int64_t ms_to_mcs(T ms) {
|
||||
using namespace std::chrono;
|
||||
return duration_cast<microseconds>(duration<T, std::milli>(ms)).count();
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
|
||||
#endif // OPENCV_GAPI_PIPELINE_MODELING_TOOL_UTILS_HPP
|
||||
|
||||
@@ -35,7 +35,7 @@ cv::gapi::GBackend::Priv::compile(const ade::Graph&,
|
||||
const std::vector<ade::NodeHandle> &) const
|
||||
{
|
||||
// ...and this method is here for the same reason!
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ void unbind(Mag& mag, const RcDesc &rc)
|
||||
break;
|
||||
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ std::ostream& operator<<(std::ostream& os, const cv::GFrameDesc &d) {
|
||||
case MediaFormat::BGR: os << "BGR"; break;
|
||||
case MediaFormat::NV12: os << "NV12"; break;
|
||||
case MediaFormat::GRAY: os << "GRAY"; break;
|
||||
default: GAPI_Assert(false && "Invalid media format");
|
||||
default: GAPI_Error("Invalid media format");
|
||||
}
|
||||
os << ' ' << d.size << ']';
|
||||
return os;
|
||||
|
||||
@@ -313,7 +313,7 @@ std::ostream& operator<<(std::ostream& os, const cv::GMetaArg &arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
|
||||
return os;
|
||||
|
||||
@@ -98,7 +98,7 @@ cv::GRunArgsP cv::gapi::bind(cv::GRunArgs &out_args)
|
||||
outputs.emplace_back(&(cv::util::get<cv::MediaFrame>(res_obj)));
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false && "This value type is not supported!"); // ...maybe because of STANDALONE mode.
|
||||
GAPI_Error("This value type is not supported!"); // ...maybe because of STANDALONE mode.
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ cv::GRunArg cv::gapi::bind(cv::GRunArgP &out)
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case T::index_of<cv::UMat*>() :
|
||||
GAPI_Assert(false && "Please implement this!");
|
||||
GAPI_Error("Please implement this!");
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -138,7 +138,7 @@ cv::GRunArg cv::gapi::bind(cv::GRunArgP &out)
|
||||
|
||||
default:
|
||||
// ...maybe our types were extended
|
||||
GAPI_Assert(false && "This value type is UNKNOWN!");
|
||||
GAPI_Error("This value type is UNKNOWN!");
|
||||
break;
|
||||
}
|
||||
return cv::GRunArg();
|
||||
|
||||
@@ -37,7 +37,7 @@ cv::detail::GCompoundContext::GCompoundContext(const cv::GArgs& in_args)
|
||||
// do nothing - as handled in a special way, see gcompoundkernel.hpp for details
|
||||
// same applies to GMatP
|
||||
break;
|
||||
default: GAPI_Assert(false);
|
||||
default: GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +176,13 @@ IIStream& operator>> (IIStream& is, cv::Point2f& pt) {
|
||||
return is >> pt.x >> pt.y;
|
||||
}
|
||||
|
||||
IOStream& operator<< (IOStream& os, const cv::Point3f &pt) {
|
||||
return os << pt.x << pt.y << pt.z;
|
||||
}
|
||||
IIStream& operator>> (IIStream& is, cv::Point3f& pt) {
|
||||
return is >> pt.x >> pt.y >> pt.z;
|
||||
}
|
||||
|
||||
IOStream& operator<< (IOStream& os, const cv::Size &sz) {
|
||||
return os << sz.width << sz.height;
|
||||
}
|
||||
@@ -283,7 +290,7 @@ IOStream& operator<< (IOStream& os, const cv::Mat &m) {
|
||||
case CV_32S: write_mat_data< int32_t>(os, m); break;
|
||||
case CV_32F: write_mat_data< float>(os, m); break;
|
||||
case CV_64F: write_mat_data< double>(os, m); break;
|
||||
default: GAPI_Assert(false && "Unsupported Mat depth");
|
||||
default: GAPI_Error("Unsupported Mat depth");
|
||||
}
|
||||
return os;
|
||||
}
|
||||
@@ -299,7 +306,7 @@ IIStream& operator>> (IIStream& is, cv::Mat& m) {
|
||||
case CV_32S: read_mat_data< int32_t>(is, m); break;
|
||||
case CV_32F: read_mat_data< float>(is, m); break;
|
||||
case CV_64F: read_mat_data< double>(is, m); break;
|
||||
default: GAPI_Assert(false && "Unsupported Mat depth");
|
||||
default: GAPI_Error("Unsupported Mat depth");
|
||||
}
|
||||
return is;
|
||||
}
|
||||
@@ -312,10 +319,10 @@ IIStream& operator>> (IIStream& is, cv::gapi::wip::draw::Text &t) {
|
||||
}
|
||||
|
||||
IOStream& operator<< (IOStream&, const cv::gapi::wip::draw::FText &) {
|
||||
GAPI_Assert(false && "Serialization: Unsupported << for FText");
|
||||
GAPI_Error("Serialization: Unsupported << for FText");
|
||||
}
|
||||
IIStream& operator>> (IIStream&, cv::gapi::wip::draw::FText &) {
|
||||
GAPI_Assert(false && "Serialization: Unsupported >> for FText");
|
||||
GAPI_Error("Serialization: Unsupported >> for FText");
|
||||
}
|
||||
|
||||
IOStream& operator<< (IOStream& os, const cv::gapi::wip::draw::Circle &c) {
|
||||
@@ -391,19 +398,19 @@ IIStream& operator>> (IIStream& is, cv::GArrayDesc &) {return is;}
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
IOStream& operator<< (IOStream& os, const cv::UMat &)
|
||||
{
|
||||
GAPI_Assert(false && "Serialization: Unsupported << for UMat");
|
||||
GAPI_Error("Serialization: Unsupported << for UMat");
|
||||
return os;
|
||||
}
|
||||
IIStream& operator >> (IIStream& is, cv::UMat &)
|
||||
{
|
||||
GAPI_Assert(false && "Serialization: Unsupported >> for UMat");
|
||||
GAPI_Error("Serialization: Unsupported >> for UMat");
|
||||
return is;
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
IOStream& operator<< (IOStream& os, const cv::gapi::wip::IStreamSource::Ptr &)
|
||||
{
|
||||
GAPI_Assert(false && "Serialization: Unsupported << for IStreamSource::Ptr");
|
||||
GAPI_Error("Serialization: Unsupported << for IStreamSource::Ptr");
|
||||
return os;
|
||||
}
|
||||
IIStream& operator >> (IIStream& is, cv::gapi::wip::IStreamSource::Ptr &)
|
||||
@@ -422,7 +429,7 @@ struct putToStream<Ref, std::tuple<>>
|
||||
{
|
||||
static void put(IOStream&, const Ref &)
|
||||
{
|
||||
GAPI_Assert(false && "Unsupported type for GArray/GOpaque serialization");
|
||||
GAPI_Error("Unsupported type for GArray/GOpaque serialization");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -447,7 +454,7 @@ struct getFromStream<Ref, std::tuple<>>
|
||||
{
|
||||
static void get(IIStream&, Ref &, cv::detail::OpaqueKind)
|
||||
{
|
||||
GAPI_Assert(false && "Unsupported type for GArray/GOpaque deserialization");
|
||||
GAPI_Error("Unsupported type for GArray/GOpaque deserialization");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -553,7 +560,7 @@ IOStream& operator<< (IOStream& os, const cv::GArg &arg) {
|
||||
case cv::detail::OpaqueKind::CV_RECT: os << arg.get<cv::Rect>(); break;
|
||||
case cv::detail::OpaqueKind::CV_SCALAR: os << arg.get<cv::Scalar>(); break;
|
||||
case cv::detail::OpaqueKind::CV_MAT: os << arg.get<cv::Mat>(); break;
|
||||
default: GAPI_Assert(false && "GArg: Unsupported (unknown?) opaque value type");
|
||||
default: GAPI_Error("GArg: Unsupported (unknown?) opaque value type");
|
||||
}
|
||||
}
|
||||
return os;
|
||||
@@ -584,12 +591,13 @@ IIStream& operator>> (IIStream& is, cv::GArg &arg) {
|
||||
HANDLE_CASE(STRING , std::string);
|
||||
HANDLE_CASE(POINT , cv::Point);
|
||||
HANDLE_CASE(POINT2F , cv::Point2f);
|
||||
HANDLE_CASE(POINT3F , cv::Point3f);
|
||||
HANDLE_CASE(SIZE , cv::Size);
|
||||
HANDLE_CASE(RECT , cv::Rect);
|
||||
HANDLE_CASE(SCALAR , cv::Scalar);
|
||||
HANDLE_CASE(MAT , cv::Mat);
|
||||
#undef HANDLE_CASE
|
||||
default: GAPI_Assert(false && "GArg: Unsupported (unknown?) opaque value type");
|
||||
default: GAPI_Error("GArg: Unsupported (unknown?) opaque value type");
|
||||
}
|
||||
}
|
||||
return is;
|
||||
@@ -657,7 +665,7 @@ struct initCtor<Ref, std::tuple<>>
|
||||
{
|
||||
static void init(cv::gimpl::Data&)
|
||||
{
|
||||
GAPI_Assert(false && "Unsupported type for GArray/GOpaque deserialization");
|
||||
GAPI_Error("Unsupported type for GArray/GOpaque deserialization");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#include "opencv2/gapi/render/render_types.hpp"
|
||||
#include "opencv2/gapi/s11n.hpp" // basic interfaces
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4702)
|
||||
#endif
|
||||
|
||||
@@ -232,4 +233,8 @@ GAPI_EXPORTS std::vector<std::string> vector_of_strings_deserialize(IIStream& is
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // OPENCV_GAPI_COMMON_SERIALIZATION_HPP
|
||||
|
||||
@@ -63,9 +63,9 @@ GAPI_OCV_KERNEL_ST(GCPUStereo, cv::gapi::calib3d::GStereo, StereoSetup)
|
||||
stereoSetup.stereoBM->compute(left, right, out_mat);
|
||||
break;
|
||||
case cv::gapi::StereoOutputFormat::DISPARITY_FIXED16_11_5:
|
||||
GAPI_Assert(false && "This case may be supported in future.");
|
||||
GAPI_Error("This case may be supported in future.");
|
||||
default:
|
||||
GAPI_Assert(false && "Unknown output format!");
|
||||
GAPI_Error("Unknown output format!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -313,7 +313,7 @@ static int maxLineConsumption(const cv::GFluidKernel::Kind kind, int window, int
|
||||
}
|
||||
} break;
|
||||
case cv::GFluidKernel::Kind::YUV420toRGB: return inPort == 0 ? 2 : 1; break;
|
||||
default: GAPI_Assert(false); return 0;
|
||||
default: GAPI_Error("InternalError"); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ static int borderSize(const cv::GFluidKernel::Kind kind, int window)
|
||||
// Resize never reads from border pixels
|
||||
case cv::GFluidKernel::Kind::Resize: return 0; break;
|
||||
case cv::GFluidKernel::Kind::YUV420toRGB: return 0; break;
|
||||
default: GAPI_Assert(false); return 0;
|
||||
default: GAPI_Error("InternalError"); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -685,7 +685,7 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
case 0: roi = produced; break;
|
||||
case 1:
|
||||
case 2: roi = cv::Rect{ produced.x/2, produced.y/2, produced.width/2, produced.height/2 }; break;
|
||||
default: GAPI_Assert(false);
|
||||
default: GAPI_Error("InternalError");
|
||||
}
|
||||
return roi;
|
||||
};
|
||||
@@ -699,7 +699,7 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
case GFluidKernel::Kind::Filter: resized = produced; break;
|
||||
case GFluidKernel::Kind::Resize: resized = adjResizeRoi(produced, in_meta.size, meta.size); break;
|
||||
case GFluidKernel::Kind::YUV420toRGB: resized = adj420Roi(produced, m_gm.metadata(in_edge).get<Input>().port); break;
|
||||
default: GAPI_Assert(false);
|
||||
default: GAPI_Error("InternalError");
|
||||
}
|
||||
|
||||
// All below transformations affect roi of the writer, preserve read start position here
|
||||
@@ -814,7 +814,7 @@ cv::gimpl::FluidGraphInputData cv::gimpl::fluidExtractInputDataFromGraph(const a
|
||||
last_agent++;
|
||||
break;
|
||||
}
|
||||
default: GAPI_Assert(false);
|
||||
default: GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,7 +844,7 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph
|
||||
case GFluidKernel::Kind::Filter: agent_ptr.reset(new FluidFilterAgent(g, agent_data.nh)); break;
|
||||
case GFluidKernel::Kind::Resize: agent_ptr.reset(new FluidResizeAgent(g, agent_data.nh)); break;
|
||||
case GFluidKernel::Kind::YUV420toRGB: agent_ptr.reset(new Fluid420toRGBAgent(g, agent_data.nh)); break;
|
||||
default: GAPI_Assert(false);
|
||||
default: GAPI_Error("InternalError");
|
||||
}
|
||||
std::tie(agent_ptr->in_buffer_ids, agent_ptr->out_buffer_ids) = std::tie(agent_data.in_buffer_ids, agent_data.out_buffer_ids);
|
||||
return agent_ptr;
|
||||
@@ -1388,7 +1388,7 @@ cv::gimpl::GParallelFluidExecutable::GParallelFluidExecutable(const ade::Graph
|
||||
void cv::gimpl::GParallelFluidExecutable::reshape(ade::Graph&, const GCompileArgs& )
|
||||
{
|
||||
//TODO: implement ?
|
||||
GAPI_Assert(false && "Not Implemented;");
|
||||
GAPI_Error("Not Implemented;");
|
||||
}
|
||||
|
||||
void cv::gimpl::GParallelFluidExecutable::run(std::vector<InObj> &&input_objs,
|
||||
@@ -1474,7 +1474,7 @@ void GFluidBackendImpl::addMetaSensitiveBackendPasses(ade::ExecutionEngineSetupC
|
||||
case NodeKind::EMIT:
|
||||
case NodeKind::SINK:
|
||||
break; // do nothing for Streaming nodes
|
||||
default: GAPI_Assert(false);
|
||||
default: GAPI_Error("InternalError");
|
||||
} // switch
|
||||
} // for (gim.nodes())
|
||||
});
|
||||
|
||||
@@ -90,7 +90,7 @@ void fillBorderConstant(int borderSize, cv::Scalar borderValue, cv::Mat& mat)
|
||||
case CV_16S: return &fillConstBorderRow< int16_t>; break;
|
||||
case CV_16U: return &fillConstBorderRow<uint16_t>; break;
|
||||
case CV_32F: return &fillConstBorderRow< float >; break;
|
||||
default: GAPI_Assert(false); return &fillConstBorderRow<uint8_t>;
|
||||
default: GAPI_Error("InternalError"); return &fillConstBorderRow<uint8_t>;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -231,7 +231,7 @@ void fluid::BufferStorageWithBorder::init(int dtype, int border_size, Border bor
|
||||
case cv::BORDER_REFLECT_101:
|
||||
m_borderHandler.reset(new BorderHandlerT<cv::BORDER_REFLECT_101>(border_size, dtype)); break;
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ inline IE::Precision toIE(int depth) {
|
||||
case CV_32S: return IE::Precision::I32;
|
||||
case CV_32F: return IE::Precision::FP32;
|
||||
case CV_16F: return IE::Precision::FP16;
|
||||
default: GAPI_Assert(false && "IE. Unsupported data type");
|
||||
default: GAPI_Error("IE. Unsupported data type");
|
||||
}
|
||||
return IE::Precision::UNSPECIFIED;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ inline int toCV(IE::Precision prec) {
|
||||
case IE::Precision::I32: return CV_32S;
|
||||
case IE::Precision::I64: return CV_32S;
|
||||
case IE::Precision::FP16: return CV_16F;
|
||||
default: GAPI_Assert(false && "IE. Unsupported data type");
|
||||
default: GAPI_Error("IE. Unsupported data type");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ inline IE::Blob::Ptr wrapIE(const cv::Mat &mat, cv::gapi::ie::TraitAs hint) {
|
||||
HANDLE(32S, int);
|
||||
HANDLE(16F, int16_t);
|
||||
#undef HANDLE
|
||||
default: GAPI_Assert(false && "IE. Unsupported data type");
|
||||
default: GAPI_Error("IE. Unsupported data type");
|
||||
}
|
||||
return IE::Blob::Ptr{};
|
||||
}
|
||||
@@ -190,13 +190,23 @@ inline IE::Blob::Ptr wrapIE(const cv::MediaFrame::View& view,
|
||||
return wrapIE(gray, cv::gapi::ie::TraitAs::IMAGE);
|
||||
}
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported media format for IE backend");
|
||||
GAPI_Error("Unsupported media format for IE backend");
|
||||
}
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
|
||||
template<class MatType>
|
||||
inline void copyFromIE(const IE::Blob::Ptr &blob, MatType &mat) {
|
||||
const auto& desc = blob->getTensorDesc();
|
||||
const auto ie_type = toCV(desc.getPrecision());
|
||||
if (ie_type != mat.type()) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to copy blob from IE to OCV: "
|
||||
<< "Blobs have different data types "
|
||||
<< "(IE type: " << ie_type
|
||||
<< " vs OCV type: " << mat.type() << ")." << std::endl;
|
||||
throw std::logic_error(ss.str());
|
||||
}
|
||||
switch (blob->getTensorDesc().getPrecision()) {
|
||||
#define HANDLE(E,T) \
|
||||
case IE::Precision::E: std::copy_n(blob->buffer().as<T*>(), \
|
||||
@@ -215,7 +225,7 @@ inline void copyFromIE(const IE::Blob::Ptr &blob, MatType &mat) {
|
||||
mat.total());
|
||||
break;
|
||||
}
|
||||
default: GAPI_Assert(false && "IE. Unsupported data type");
|
||||
default: GAPI_Error("IE. Unsupported data type");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,6 +375,13 @@ struct IEUnit {
|
||||
cv::util::throw_error(std::logic_error("Unsupported ParamDesc::Kind"));
|
||||
}
|
||||
|
||||
if (params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import &&
|
||||
!cv::util::holds_alternative<cv::util::monostate>(params.output_precision)) {
|
||||
cv::util::throw_error(
|
||||
std::logic_error("Setting output precision isn't supported for imported network"));
|
||||
}
|
||||
|
||||
|
||||
using namespace cv::gapi::wip::onevpl;
|
||||
if (params.vpl_preproc_device.has_value() && params.vpl_preproc_ctx.has_value()) {
|
||||
using namespace cv::gapi::wip;
|
||||
@@ -375,6 +392,12 @@ struct IEUnit {
|
||||
params.vpl_preproc_ctx.value());
|
||||
GAPI_LOG_INFO(nullptr, "VPP preproc created successfuly");
|
||||
}
|
||||
|
||||
if (params.mode == cv::gapi::ie::InferMode::Sync &&
|
||||
params.nireq != 1u) {
|
||||
throw std::logic_error(
|
||||
"Failed: cv::gapi::ie::InferMode::Sync works only with nireq equal to 1.");
|
||||
}
|
||||
}
|
||||
|
||||
// This method is [supposed to be] called at Island compilation stage
|
||||
@@ -416,7 +439,7 @@ void IEUnit::InputFramesDesc::set_param(const input_name_type &input,
|
||||
if (layout != InferenceEngine::NHWC && layout != InferenceEngine::NCHW) {
|
||||
GAPI_LOG_WARNING(nullptr, "Unsupported layout for VPP preproc: " << layout <<
|
||||
", input name: " << input);
|
||||
GAPI_Assert(false && "Unsupported layout for VPP preproc");
|
||||
GAPI_Error("Unsupported layout for VPP preproc");
|
||||
}
|
||||
GAPI_Assert(inDims.size() == 4u);
|
||||
ret.size.width = static_cast<int>(inDims[3]);
|
||||
@@ -731,7 +754,7 @@ inline IE::Blob::Ptr extractBlob(IECallContext& ctx,
|
||||
|
||||
NV12ParamType* blob_params = cv::util::any_cast<NV12ParamType>(&any_blob_params);
|
||||
if (blob_params == nullptr) {
|
||||
GAPI_Assert(false && "Incorrect type of blobParams:"
|
||||
GAPI_Error("Incorrect type of blobParams:"
|
||||
"expected std::pair<ParamType, ParamType>,"
|
||||
"with ParamType std::pair<InferenceEngine::TensorDesc,"
|
||||
"InferenceEngine::ParamMap >>");
|
||||
@@ -759,7 +782,7 @@ inline IE::Blob::Ptr extractBlob(IECallContext& ctx,
|
||||
default:
|
||||
GAPI_Assert("Unsupported input shape for IE backend");
|
||||
}
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
|
||||
|
||||
@@ -826,40 +849,130 @@ std::vector<InferenceEngine::InferRequest> cv::gimpl::ie::IECompiled::createInfe
|
||||
return requests;
|
||||
}
|
||||
|
||||
class cv::gimpl::ie::RequestPool {
|
||||
class IInferExecutor {
|
||||
public:
|
||||
using RunF = std::function<void(InferenceEngine::InferRequest&)>;
|
||||
using CallbackF = std::function<void(InferenceEngine::InferRequest&, InferenceEngine::StatusCode)>;
|
||||
using Ptr = std::shared_ptr<IInferExecutor>;
|
||||
using NotifyCallbackF = std::function<void()>;
|
||||
using SetInputDataF = std::function<void(InferenceEngine::InferRequest&)>;
|
||||
using ReadOutputDataF = std::function<void(InferenceEngine::InferRequest&, InferenceEngine::StatusCode)>;
|
||||
|
||||
// NB: The task is represented by:
|
||||
// RunF - function which is set blobs and run async inference.
|
||||
// CallbackF - function which is obtain output blobs and post it to output.
|
||||
// SetInputDataF - function which set input data.
|
||||
// ReadOutputDataF - function which read output data.
|
||||
struct Task {
|
||||
RunF run;
|
||||
CallbackF callback;
|
||||
SetInputDataF set_input_data;
|
||||
ReadOutputDataF read_output_data;
|
||||
};
|
||||
|
||||
explicit RequestPool(std::vector<InferenceEngine::InferRequest>&& requests);
|
||||
IInferExecutor(IE::InferRequest request, NotifyCallbackF notify)
|
||||
: m_request(std::move(request)),
|
||||
m_notify(std::move(notify)) {
|
||||
};
|
||||
|
||||
void execute(Task&& t);
|
||||
void waitAll();
|
||||
virtual void execute(const Task& task) = 0;
|
||||
virtual ~IInferExecutor() = default;
|
||||
|
||||
protected:
|
||||
IE::InferRequest m_request;
|
||||
NotifyCallbackF m_notify;
|
||||
};
|
||||
|
||||
class SyncInferExecutor : public IInferExecutor {
|
||||
using IInferExecutor::IInferExecutor;
|
||||
virtual void execute(const IInferExecutor::Task& task) override;
|
||||
};
|
||||
|
||||
void SyncInferExecutor::execute(const IInferExecutor::Task& task) {
|
||||
try {
|
||||
task.set_input_data(m_request);
|
||||
m_request.Infer();
|
||||
task.read_output_data(m_request, IE::StatusCode::OK);
|
||||
} catch (...) {
|
||||
m_notify();
|
||||
throw;
|
||||
}
|
||||
// NB: Notify pool that executor has finished.
|
||||
m_notify();
|
||||
}
|
||||
|
||||
class AsyncInferExecutor : public IInferExecutor {
|
||||
public:
|
||||
using IInferExecutor::IInferExecutor;
|
||||
virtual void execute(const IInferExecutor::Task& task) override;
|
||||
|
||||
private:
|
||||
void callback(Task task,
|
||||
size_t id,
|
||||
IE::InferRequest request,
|
||||
IE::StatusCode code) noexcept;
|
||||
void setup();
|
||||
|
||||
QueueClass<size_t> m_idle_ids;
|
||||
std::vector<InferenceEngine::InferRequest> m_requests;
|
||||
};
|
||||
|
||||
// RequestPool implementation //////////////////////////////////////////////
|
||||
cv::gimpl::ie::RequestPool::RequestPool(std::vector<InferenceEngine::InferRequest>&& requests)
|
||||
: m_requests(std::move(requests)) {
|
||||
setup();
|
||||
void AsyncInferExecutor::execute(const IInferExecutor::Task& task) {
|
||||
using namespace std::placeholders;
|
||||
using callback_t = std::function<void(IE::InferRequest, IE::StatusCode)>;
|
||||
m_request.SetCompletionCallback(
|
||||
static_cast<callback_t>(
|
||||
std::bind(&AsyncInferExecutor::callback, this, task, _1, _2)));
|
||||
try {
|
||||
task.set_input_data(m_request);
|
||||
m_request.StartAsync();
|
||||
} catch (...) {
|
||||
m_request.SetCompletionCallback([](){});
|
||||
m_notify();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncInferExecutor::callback(IInferExecutor::Task task,
|
||||
IE::InferRequest request,
|
||||
IE::StatusCode code) noexcept {
|
||||
task.read_output_data(request, code);
|
||||
request.SetCompletionCallback([](){});
|
||||
// NB: Notify pool that executor has finished.
|
||||
m_notify();
|
||||
}
|
||||
|
||||
class cv::gimpl::ie::RequestPool {
|
||||
public:
|
||||
|
||||
explicit RequestPool(cv::gapi::ie::InferMode mode,
|
||||
std::vector<InferenceEngine::InferRequest>&& requests);
|
||||
|
||||
IInferExecutor::Ptr getIdleRequest();
|
||||
void waitAll();
|
||||
|
||||
private:
|
||||
void setup();
|
||||
void release(const size_t id);
|
||||
|
||||
QueueClass<size_t> m_idle_ids;
|
||||
std::vector<IInferExecutor::Ptr> m_requests;
|
||||
};
|
||||
|
||||
void cv::gimpl::ie::RequestPool::release(const size_t id) {
|
||||
m_idle_ids.push(id);
|
||||
}
|
||||
|
||||
// RequestPool implementation //////////////////////////////////////////////
|
||||
cv::gimpl::ie::RequestPool::RequestPool(cv::gapi::ie::InferMode mode,
|
||||
std::vector<InferenceEngine::InferRequest>&& requests) {
|
||||
for (size_t i = 0; i < requests.size(); ++i) {
|
||||
IInferExecutor::Ptr iexec = nullptr;
|
||||
switch (mode) {
|
||||
case cv::gapi::ie::InferMode::Async:
|
||||
iexec = std::make_shared<AsyncInferExecutor>(std::move(requests[i]),
|
||||
std::bind(&RequestPool::release, this, i));
|
||||
break;
|
||||
case cv::gapi::ie::InferMode::Sync:
|
||||
iexec = std::make_shared<SyncInferExecutor>(std::move(requests[i]),
|
||||
std::bind(&RequestPool::release, this, i));
|
||||
break;
|
||||
default:
|
||||
GAPI_Error("Unsupported cv::gapi::ie::InferMode");
|
||||
}
|
||||
m_requests.emplace_back(std::move(iexec));
|
||||
}
|
||||
setup();
|
||||
}
|
||||
|
||||
void cv::gimpl::ie::RequestPool::setup() {
|
||||
for (size_t i = 0; i < m_requests.size(); ++i) {
|
||||
@@ -867,40 +980,10 @@ void cv::gimpl::ie::RequestPool::setup() {
|
||||
}
|
||||
}
|
||||
|
||||
void cv::gimpl::ie::RequestPool::execute(cv::gimpl::ie::RequestPool::Task&& t) {
|
||||
IInferExecutor::Ptr cv::gimpl::ie::RequestPool::getIdleRequest() {
|
||||
size_t id = 0u;
|
||||
m_idle_ids.pop(id);
|
||||
|
||||
auto& request = m_requests[id];
|
||||
|
||||
using namespace std::placeholders;
|
||||
using callback_t = std::function<void(IE::InferRequest, IE::StatusCode)>;
|
||||
request.SetCompletionCallback(
|
||||
static_cast<callback_t>(
|
||||
std::bind(&cv::gimpl::ie::RequestPool::callback, this,
|
||||
t, id, _1, _2)));
|
||||
// NB: InferRequest is already marked as busy
|
||||
// in case of exception need to return it back to the idle.
|
||||
try {
|
||||
t.run(request);
|
||||
} catch (...) {
|
||||
request.SetCompletionCallback([](){});
|
||||
m_idle_ids.push(id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void cv::gimpl::ie::RequestPool::callback(cv::gimpl::ie::RequestPool::Task task,
|
||||
size_t id,
|
||||
IE::InferRequest request,
|
||||
IE::StatusCode code) noexcept {
|
||||
// NB: Inference is over.
|
||||
// 1. Run callback
|
||||
// 2. Destroy callback to free resources.
|
||||
// 3. Mark InferRequest as idle.
|
||||
task.callback(request, code);
|
||||
request.SetCompletionCallback([](){});
|
||||
m_idle_ids.push(id);
|
||||
return m_requests[id];
|
||||
}
|
||||
|
||||
// NB: Not thread-safe.
|
||||
@@ -927,7 +1010,7 @@ cv::gimpl::ie::GIEExecutable::GIEExecutable(const ade::Graph &g,
|
||||
if (this_nh == nullptr) {
|
||||
this_nh = nh;
|
||||
this_iec = iem.metadata(this_nh).get<IEUnit>().compile();
|
||||
m_reqPool.reset(new RequestPool(this_iec.createInferRequests()));
|
||||
m_reqPool.reset(new RequestPool(this_iec.params.mode, this_iec.createInferRequests()));
|
||||
}
|
||||
else
|
||||
util::throw_error(std::logic_error("Multi-node inference is not supported!"));
|
||||
@@ -1061,7 +1144,7 @@ static void configureInputReshapeByImage(const IE::InputInfo::Ptr& ii,
|
||||
auto input_dims = ii->getTensorDesc().getDims();
|
||||
const auto size = input_dims.size();
|
||||
if (size <= 1) {
|
||||
GAPI_Assert(false && "Unsupported number of dimensions for reshape by image");
|
||||
GAPI_Error("Unsupported number of dimensions for reshape by image");
|
||||
}
|
||||
input_dims.at(size - 2) = static_cast<size_t>(image_sz.height);
|
||||
input_dims.at(size - 1) = static_cast<size_t>(image_sz.width);
|
||||
@@ -1090,7 +1173,7 @@ static void configureInputInfo(const IE::InputInfo::Ptr& ii, const cv::GMetaArg
|
||||
// NB: Do nothing
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported media format for IE backend");
|
||||
GAPI_Error("Unsupported media format for IE backend");
|
||||
}
|
||||
ii->setPrecision(toIE(CV_8U));
|
||||
break;
|
||||
@@ -1122,6 +1205,28 @@ static IE::PreProcessInfo configurePreProcInfo(const IE::InputInfo::CPtr& ii,
|
||||
return info;
|
||||
}
|
||||
|
||||
using namespace cv::gapi::ie::detail;
|
||||
static void configureOutputPrecision(const IE::OutputsDataMap &outputs_info,
|
||||
const ParamDesc::PrecisionVariantT &output_precision) {
|
||||
cv::util::visit(cv::util::overload_lambdas(
|
||||
[&outputs_info](ParamDesc::PrecisionT cvdepth) {
|
||||
auto precision = toIE(cvdepth);
|
||||
for (auto it : outputs_info) {
|
||||
it.second->setPrecision(precision);
|
||||
}
|
||||
},
|
||||
[&outputs_info](const ParamDesc::PrecisionMapT& precision_map) {
|
||||
for (auto it : precision_map) {
|
||||
outputs_info.at(it.first)->setPrecision(toIE(it.second));
|
||||
}
|
||||
},
|
||||
[&outputs_info](cv::util::monostate) {
|
||||
// Do nothing.
|
||||
}
|
||||
), output_precision
|
||||
);
|
||||
}
|
||||
|
||||
// NB: This is a callback used by async infer
|
||||
// to post outputs blobs (cv::GMat's).
|
||||
static void PostOutputs(InferenceEngine::InferRequest &request,
|
||||
@@ -1241,7 +1346,7 @@ struct Infer: public cv::detail::KernelTag {
|
||||
GAPI_Assert(uu.params.input_names.size() == in_metas.size()
|
||||
&& "Known input layers count doesn't match input meta count");
|
||||
|
||||
// NB: Configuring input precision and network reshape must be done
|
||||
// NB: Configuring input/output precision and network reshape must be done
|
||||
// only in the loadNetwork case.
|
||||
using namespace cv::gapi::ie::detail;
|
||||
if (uu.params.kind == ParamDesc::Kind::Load) {
|
||||
@@ -1275,6 +1380,7 @@ struct Infer: public cv::detail::KernelTag {
|
||||
if (!input_reshape_table.empty()) {
|
||||
const_cast<IE::CNNNetwork *>(&uu.net)->reshape(input_reshape_table);
|
||||
}
|
||||
configureOutputPrecision(uu.net.getOutputsInfo(), uu.params.output_precision);
|
||||
} else {
|
||||
GAPI_Assert(uu.params.kind == ParamDesc::Kind::Import);
|
||||
auto inputs = uu.this_network.GetInputsInfo();
|
||||
@@ -1316,8 +1422,8 @@ struct Infer: public cv::detail::KernelTag {
|
||||
static void run(std::shared_ptr<IECallContext> ctx,
|
||||
cv::gimpl::ie::RequestPool &reqPool) {
|
||||
using namespace std::placeholders;
|
||||
reqPool.execute(
|
||||
cv::gimpl::ie::RequestPool::Task {
|
||||
reqPool.getIdleRequest()->execute(
|
||||
IInferExecutor::Task {
|
||||
[ctx](InferenceEngine::InferRequest &req) {
|
||||
// non-generic version for now:
|
||||
// - assumes all inputs/outputs are always Mats
|
||||
@@ -1335,9 +1441,6 @@ struct Infer: public cv::detail::KernelTag {
|
||||
cv::util::optional<cv::Rect>{});
|
||||
setBlob(req, layer_name, this_blob, *ctx);
|
||||
}
|
||||
// FIXME: Should it be done by kernel ?
|
||||
// What about to do that in RequestPool ?
|
||||
req.StartAsync();
|
||||
},
|
||||
std::bind(PostOutputs, _1, _2, ctx)
|
||||
}
|
||||
@@ -1393,6 +1496,7 @@ struct InferROI: public cv::detail::KernelTag {
|
||||
const_cast<IEUnit::InputFramesDesc &>(uu.net_input_params)
|
||||
.set_param(input_name, ii->getTensorDesc());
|
||||
}
|
||||
configureOutputPrecision(uu.net.getOutputsInfo(), uu.params.output_precision);
|
||||
} else {
|
||||
GAPI_Assert(uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import);
|
||||
auto inputs = uu.this_network.GetInputsInfo();
|
||||
@@ -1429,8 +1533,8 @@ struct InferROI: public cv::detail::KernelTag {
|
||||
static void run(std::shared_ptr<IECallContext> ctx,
|
||||
cv::gimpl::ie::RequestPool &reqPool) {
|
||||
using namespace std::placeholders;
|
||||
reqPool.execute(
|
||||
cv::gimpl::ie::RequestPool::Task {
|
||||
reqPool.getIdleRequest()->execute(
|
||||
IInferExecutor::Task {
|
||||
[ctx](InferenceEngine::InferRequest &req) {
|
||||
GAPI_Assert(ctx->uu.params.num_in == 1);
|
||||
auto&& this_roi = ctx->inArg<cv::detail::OpaqueRef>(0).rref<cv::Rect>();
|
||||
@@ -1455,9 +1559,6 @@ struct InferROI: public cv::detail::KernelTag {
|
||||
*(ctx->uu.params.input_names.begin()),
|
||||
this_blob, *ctx);
|
||||
}
|
||||
// FIXME: Should it be done by kernel ?
|
||||
// What about to do that in RequestPool ?
|
||||
req.StartAsync();
|
||||
},
|
||||
std::bind(PostOutputs, _1, _2, ctx)
|
||||
}
|
||||
@@ -1513,6 +1614,7 @@ struct InferList: public cv::detail::KernelTag {
|
||||
if (!input_reshape_table.empty()) {
|
||||
const_cast<IE::CNNNetwork *>(&uu.net)->reshape(input_reshape_table);
|
||||
}
|
||||
configureOutputPrecision(uu.net.getOutputsInfo(), uu.params.output_precision);
|
||||
} else {
|
||||
GAPI_Assert(uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import);
|
||||
std::size_t idx = 1u;
|
||||
@@ -1571,11 +1673,10 @@ struct InferList: public cv::detail::KernelTag {
|
||||
for (auto&& it : ade::util::indexed(in_roi_vec)) {
|
||||
auto pos = ade::util::index(it);
|
||||
const auto& rc = ade::util::value(it);
|
||||
reqPool.execute(
|
||||
cv::gimpl::ie::RequestPool::Task {
|
||||
reqPool.getIdleRequest()->execute(
|
||||
IInferExecutor::Task {
|
||||
[ctx, rc, this_blob](InferenceEngine::InferRequest &req) {
|
||||
setROIBlob(req, ctx->uu.params.input_names[0u], this_blob, rc, *ctx);
|
||||
req.StartAsync();
|
||||
},
|
||||
std::bind(callback, std::placeholders::_1, std::placeholders::_2, pos)
|
||||
}
|
||||
@@ -1667,6 +1768,7 @@ struct InferList2: public cv::detail::KernelTag {
|
||||
if (!input_reshape_table.empty()) {
|
||||
const_cast<IE::CNNNetwork *>(&uu.net)->reshape(input_reshape_table);
|
||||
}
|
||||
configureOutputPrecision(uu.net.getOutputsInfo(), uu.params.output_precision);
|
||||
} else {
|
||||
GAPI_Assert(uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import);
|
||||
auto inputs = uu.this_network.GetInputsInfo();
|
||||
@@ -1727,8 +1829,8 @@ struct InferList2: public cv::detail::KernelTag {
|
||||
|
||||
PostOutputsList callback(list_size, ctx, std::move(cached_dims));
|
||||
for (const auto &list_idx : ade::util::iota(list_size)) {
|
||||
reqPool.execute(
|
||||
cv::gimpl::ie::RequestPool::Task {
|
||||
reqPool.getIdleRequest()->execute(
|
||||
IInferExecutor::Task {
|
||||
[ctx, list_idx, list_size, blob_0](InferenceEngine::InferRequest &req) {
|
||||
for (auto in_idx : ade::util::iota(ctx->uu.params.num_in)) {
|
||||
const auto &this_vec = ctx->inArg<cv::detail::VectorRef>(in_idx+1u);
|
||||
@@ -1748,7 +1850,6 @@ struct InferList2: public cv::detail::KernelTag {
|
||||
"Only Rect and Mat types are supported for infer list 2!");
|
||||
}
|
||||
}
|
||||
req.StartAsync();
|
||||
},
|
||||
std::bind(callback, std::placeholders::_1, std::placeholders::_2, list_idx)
|
||||
} // task
|
||||
|
||||
@@ -62,12 +62,12 @@ public:
|
||||
|
||||
virtual inline bool canReshape() const override { return false; }
|
||||
virtual inline void reshape(ade::Graph&, const GCompileArgs&) override {
|
||||
GAPI_Assert(false); // Not implemented yet
|
||||
GAPI_Error("InternalError"); // Not implemented yet
|
||||
}
|
||||
|
||||
virtual void run(std::vector<InObj> &&,
|
||||
std::vector<OutObj> &&) override {
|
||||
GAPI_Assert(false && "Not implemented");
|
||||
GAPI_Error("Not implemented");
|
||||
}
|
||||
|
||||
virtual void run(GIslandExecutable::IInput &in,
|
||||
|
||||
@@ -39,7 +39,7 @@ class GOAKExecutable final: public GIslandExecutable {
|
||||
friend class OAKKernelParams;
|
||||
virtual void run(std::vector<InObj>&&,
|
||||
std::vector<OutObj>&&) override {
|
||||
GAPI_Assert(false && "Not implemented");
|
||||
GAPI_Error("Not implemented");
|
||||
}
|
||||
|
||||
virtual void run(GIslandExecutable::IInput &in,
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
// FIXME: could it reshape?
|
||||
virtual bool canReshape() const override { return false; }
|
||||
virtual void reshape(ade::Graph&, const GCompileArgs&) override {
|
||||
GAPI_Assert(false && "GOAKExecutable::reshape() is not supported");
|
||||
GAPI_Error("GOAKExecutable::reshape() is not supported");
|
||||
}
|
||||
|
||||
virtual void handleNewStream() override;
|
||||
@@ -391,7 +391,7 @@ void cv::gimpl::GOAKExecutable::linkCopy(ade::NodeHandle handle) {
|
||||
for (const auto& copy_next_op : copy_out.front().get()->outNodes()) {
|
||||
const auto& op = m_gm.metadata(copy_next_op).get<Op>();
|
||||
if (op.k.name == "org.opencv.oak.copy") {
|
||||
GAPI_Assert(false && "Back-to-back Copy operations are not supported in graph");
|
||||
GAPI_Error("Back-to-back Copy operations are not supported in graph");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,14 +701,14 @@ cv::gimpl::GOAKExecutable::GOAKExecutable(const ade::Graph& g,
|
||||
[](ExtractTypeHelper::InputPtr ptr) {
|
||||
return ptr == nullptr;
|
||||
})) {
|
||||
GAPI_Assert(false && "DAI input are not set");
|
||||
GAPI_Error("DAI input are not set");
|
||||
}
|
||||
|
||||
if (std::any_of(node_info.outputs.cbegin(), node_info.outputs.cend(),
|
||||
[](ExtractTypeHelper::OutputPtr ptr) {
|
||||
return ptr == nullptr;
|
||||
})) {
|
||||
GAPI_Assert(false && "DAI outputs are not set");
|
||||
GAPI_Error("DAI outputs are not set");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -907,7 +907,7 @@ void cv::gimpl::GOAKExecutable::run(GIslandExecutable::IInput &in,
|
||||
}
|
||||
// FIXME: Add support for remaining types
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported type in OAK backend");
|
||||
GAPI_Error("Unsupported type in OAK backend");
|
||||
}
|
||||
|
||||
out.meta(out_arg, meta);
|
||||
@@ -1080,7 +1080,7 @@ class GOAKBackendImpl final : public cv::gapi::GBackend::Priv {
|
||||
// NB: how could we have non-OAK source in streaming mode, then OAK backend in
|
||||
// streaming mode but without camera input?
|
||||
if (!gm.metadata().contains<cv::gimpl::Streaming>()) {
|
||||
GAPI_Assert(false && "OAK backend only supports Streaming mode for now");
|
||||
GAPI_Error("OAK backend only supports Streaming mode for now");
|
||||
}
|
||||
return EPtr{new cv::gimpl::GOAKExecutable(graph, args, nodes, ins_data, outs_data)};
|
||||
}
|
||||
@@ -1118,14 +1118,11 @@ namespace gapi {
|
||||
namespace oak {
|
||||
|
||||
cv::gapi::GKernelPackage kernels() {
|
||||
GAPI_Assert(false && "Built without OAK support");
|
||||
return {};
|
||||
GAPI_Error("Built without OAK support");
|
||||
}
|
||||
|
||||
cv::gapi::GBackend backend() {
|
||||
GAPI_Assert(false && "Built without OAK support");
|
||||
static cv::gapi::GBackend this_backend(nullptr);
|
||||
return this_backend;
|
||||
GAPI_Error("Built without OAK support");
|
||||
}
|
||||
|
||||
} // namespace oak
|
||||
|
||||
@@ -114,7 +114,8 @@ cv::GArg cv::gimpl::GOCLExecutable::packArg(const GArg &arg)
|
||||
GAPI_Assert( arg.kind != cv::detail::ArgKind::GMAT
|
||||
&& arg.kind != cv::detail::ArgKind::GSCALAR
|
||||
&& arg.kind != cv::detail::ArgKind::GARRAY
|
||||
&& arg.kind != cv::detail::ArgKind::GOPAQUE);
|
||||
&& arg.kind != cv::detail::ArgKind::GOPAQUE
|
||||
&& arg.kind != cv::detail::ArgKind::GFRAME);
|
||||
|
||||
if (arg.kind != cv::detail::ArgKind::GOBJREF)
|
||||
{
|
||||
@@ -136,6 +137,7 @@ cv::GArg cv::gimpl::GOCLExecutable::packArg(const GArg &arg)
|
||||
// Note: .at() is intentional for GOpaque as object MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
case GShape::GOPAQUE: return GArg(m_res.slot<cv::detail::OpaqueRef>().at(ref.id));
|
||||
case GShape::GFRAME: return GArg(m_res.slot<cv::MediaFrame>().at(ref.id));
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
break;
|
||||
|
||||
@@ -6,11 +6,32 @@
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
#include <opencv2/gapi/ocl/core.hpp>
|
||||
#include <opencv2/gapi/util/throw.hpp>
|
||||
|
||||
#include "backends/ocl/goclcore.hpp"
|
||||
|
||||
#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 <d3d11.h>
|
||||
#pragma comment(lib, "dxgi")
|
||||
#undef NOMINMAX
|
||||
#undef D3D11_NO_HELPERS
|
||||
#include <opencv2/core/directx.hpp>
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
|
||||
#include <opencv2/core/ocl.hpp>
|
||||
#include "streaming/onevpl/accelerators/surface/dx11_frame_adapter.hpp"
|
||||
|
||||
GAPI_OCL_KERNEL(GOCLAdd, cv::gapi::core::GAdd)
|
||||
{
|
||||
static void run(const cv::UMat& a, const cv::UMat& b, int dtype, cv::UMat& out)
|
||||
@@ -523,6 +544,79 @@ GAPI_OCL_KERNEL(GOCLTranspose, cv::gapi::core::GTranspose)
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCL_KERNEL(GOCLBGR, cv::gapi::streaming::GBGR)
|
||||
{
|
||||
static void run(const cv::MediaFrame& in, cv::UMat& out)
|
||||
{
|
||||
cv::util::suppress_unused_warning(in);
|
||||
cv::util::suppress_unused_warning(out);
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#ifdef HAVE_ONEVPL
|
||||
auto d = in.desc();
|
||||
if (d.fmt != cv::MediaFormat::NV12)
|
||||
{
|
||||
GAPI_LOG_FATAL(nullptr, "Unsupported format provided: " << static_cast<int>(d.fmt) <<
|
||||
". Expected cv::MediaFormat::NV12.");
|
||||
cv::util::throw_error(std::logic_error("Unsupported MediaFrame format provided"));
|
||||
}
|
||||
|
||||
// FIXME: consider a better solution.
|
||||
// Current approach cannot be easily extended for other adapters (getHandle).
|
||||
auto adapterPtr = in.get<cv::gapi::wip::onevpl::VPLMediaFrameDX11Adapter>();
|
||||
if (adapterPtr == nullptr)
|
||||
{
|
||||
GAPI_LOG_FATAL(nullptr, "Unsupported adapter type. Only VPLMediaFrameDX11Adapter is supported");
|
||||
cv::util::throw_error(std::logic_error("Unsupported adapter type. Only VPLMediaFrameDX11Adapter is supported"));
|
||||
}
|
||||
|
||||
auto params = adapterPtr->getHandle();
|
||||
auto handle = cv::util::any_cast<mfxHDLPair>(params);
|
||||
ID3D11Texture2D* texture = reinterpret_cast<ID3D11Texture2D*>(handle.first);
|
||||
if (texture == nullptr)
|
||||
{
|
||||
GAPI_LOG_FATAL(nullptr, "mfxHDLPair contains ID3D11Texture2D that is nullptr. Handle address" <<
|
||||
reinterpret_cast<uint64_t>(handle.first));
|
||||
cv::util::throw_error(std::logic_error("mfxHDLPair contains ID3D11Texture2D that is nullptr"));
|
||||
}
|
||||
|
||||
// FIXME: Assuming here that we only have 1 device
|
||||
// TODO: Textures are reusable, so to improve the peroformance here
|
||||
// consider creating a hash map texture <-> device/ctx
|
||||
static thread_local ID3D11Device* pD3D11Device = nullptr;
|
||||
if (pD3D11Device == nullptr)
|
||||
{
|
||||
texture->GetDevice(&pD3D11Device);
|
||||
}
|
||||
if (pD3D11Device == nullptr)
|
||||
{
|
||||
GAPI_LOG_FATAL(nullptr, "D3D11Texture2D::GetDevice returns pD3D11Device that is nullptr");
|
||||
cv::util::throw_error(std::logic_error("D3D11Texture2D::GetDevice returns pD3D11Device that is nullptr"));
|
||||
}
|
||||
|
||||
// FIXME: assuming here that the context is always the same
|
||||
// TODO: Textures are reusable, so to improve the peroformance here
|
||||
// consider creating a hash map texture <-> device/ctx
|
||||
static thread_local cv::ocl::Context ctx = cv::directx::ocl::initializeContextFromD3D11Device(pD3D11Device);
|
||||
if (ctx.ptr() == nullptr)
|
||||
{
|
||||
GAPI_LOG_FATAL(nullptr, "initializeContextFromD3D11Device returned null context");
|
||||
cv::util::throw_error(std::logic_error("initializeContextFromD3D11Device returned null context"));
|
||||
}
|
||||
|
||||
cv::directx::convertFromD3D11Texture2D(texture, out);
|
||||
#else
|
||||
GAPI_LOG_FATAL(nullptr, "HAVE_ONEVPL is not set. Please, check your cmake flags");
|
||||
cv::util::throw_error(std::logic_error("HAVE_ONEVPL is not set. Please, check your cmake flags"));
|
||||
#endif // HAVE_ONEVPL
|
||||
#else
|
||||
GAPI_LOG_FATAL(nullptr, "HAVE_D3D11 or HAVE_DIRECTX is not set. Please, check your cmake flags");
|
||||
cv::util::throw_error(std::logic_error("HAVE_D3D11 or HAVE_DIRECTX is not set. Please, check your cmake flags"));
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
}
|
||||
};
|
||||
|
||||
cv::GKernelPackage cv::gapi::core::ocl::kernels()
|
||||
{
|
||||
static auto pkg = cv::gapi::kernels
|
||||
@@ -587,6 +681,7 @@ cv::GKernelPackage cv::gapi::core::ocl::kernels()
|
||||
, GOCLLUT
|
||||
, GOCLConvertTo
|
||||
, GOCLTranspose
|
||||
, GOCLBGR
|
||||
>();
|
||||
return pkg;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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.
|
||||
|
||||
#include <opencv2/gapi/infer/bindings_onnx.hpp>
|
||||
|
||||
cv::gapi::onnx::PyParams::PyParams(const std::string& tag,
|
||||
const std::string& model_path)
|
||||
: m_priv(std::make_shared<Params<cv::gapi::Generic>>(tag, model_path)) {}
|
||||
|
||||
cv::gapi::GBackend cv::gapi::onnx::PyParams::backend() const {
|
||||
return m_priv->backend();
|
||||
}
|
||||
|
||||
std::string cv::gapi::onnx::PyParams::tag() const { return m_priv->tag(); }
|
||||
|
||||
cv::util::any cv::gapi::onnx::PyParams::params() const {
|
||||
return m_priv->params();
|
||||
}
|
||||
|
||||
cv::gapi::onnx::PyParams cv::gapi::onnx::params(
|
||||
const std::string& tag, const std::string& model_path) {
|
||||
return {tag, model_path};
|
||||
}
|
||||
@@ -171,7 +171,7 @@ inline int toCV(ONNXTensorElementDataType prec) {
|
||||
case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT: return CV_32F;
|
||||
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32: return CV_32S;
|
||||
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64: return CV_32S;
|
||||
default: GAPI_Assert(false && "ONNX. Unsupported data type");
|
||||
default: GAPI_Error("ONNX. Unsupported data type");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ inline void copyFromONNX(Ort::Value &v, cv::Mat& mat) {
|
||||
mat.total());
|
||||
break;
|
||||
}
|
||||
default: GAPI_Assert(false && "ONNX. Unsupported data type");
|
||||
default: GAPI_Error("ONNX. Unsupported data type");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ inline void preprocess(const cv::Mat& src,
|
||||
"32F tensor dimensions should match with all non-dynamic NN input dimensions");
|
||||
}
|
||||
} else {
|
||||
GAPI_Assert(false && "32F tensor size should match with NN input");
|
||||
GAPI_Error("32F tensor size should match with NN input");
|
||||
}
|
||||
|
||||
dst = src;
|
||||
@@ -338,7 +338,7 @@ void preprocess(const cv::MediaFrame::View& view,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported media format for ONNX backend");
|
||||
GAPI_Error("Unsupported media format for ONNX backend");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ inline Ort::Value createTensor(const Ort::MemoryInfo& memory_info,
|
||||
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32:
|
||||
return createTensor<int32_t>(memory_info, tensor_params, data);
|
||||
default:
|
||||
GAPI_Assert(false && "ONNX. Unsupported data type");
|
||||
GAPI_Error("ONNX. Unsupported data type");
|
||||
}
|
||||
return Ort::Value{nullptr};
|
||||
}
|
||||
@@ -735,7 +735,8 @@ void ONNXCompiled::extractMat(ONNXCallContext &ctx, const size_t in_idx, Views&
|
||||
}
|
||||
}
|
||||
|
||||
void ONNXCompiled::setOutput(int i, cv::Mat &m) {
|
||||
void ONNXCompiled::setOutput(int i, cv::Mat &m)
|
||||
{
|
||||
// FIXME: No need in double-indexing?
|
||||
out_data[i] = m;
|
||||
}
|
||||
@@ -857,7 +858,7 @@ static void checkInputMeta(const cv::GMetaArg mm) {
|
||||
case cv::MediaFormat::NV12: break;
|
||||
case cv::MediaFormat::BGR: break;
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported media format for ONNX backend");
|
||||
GAPI_Error("Unsupported media format for ONNX backend");
|
||||
} break;
|
||||
} break;
|
||||
default:
|
||||
@@ -1100,7 +1101,7 @@ struct InferList2: public cv::detail::KernelTag {
|
||||
const auto &vec = this_vec.rref<cv::Mat>();
|
||||
uu.oc->setInput(in_idx, vec[list_idx]);
|
||||
} else {
|
||||
GAPI_Assert(false && "Only Rect and Mat types are supported for infer list 2!");
|
||||
GAPI_Error("Only Rect and Mat types are supported for infer list 2!");
|
||||
}
|
||||
// }}} (Prepare input)
|
||||
} // }}} (For every input of the net)
|
||||
@@ -1133,9 +1134,34 @@ namespace {
|
||||
// FIXME: Introduce a DNNBackend interface which'd specify
|
||||
// the framework for this???
|
||||
GONNXModel gm(gr);
|
||||
const auto &np = gm.metadata(nh).get<NetworkParams>();
|
||||
const auto &pp = cv::util::any_cast<cv::gapi::onnx::detail::ParamDesc>(np.opaque);
|
||||
auto &np = gm.metadata(nh).get<NetworkParams>();
|
||||
auto &pp = cv::util::any_cast<cv::gapi::onnx::detail::ParamDesc>(np.opaque);
|
||||
const auto &ki = cv::util::any_cast<KImpl>(ii.opaque);
|
||||
|
||||
GModel::Graph model(gr);
|
||||
auto& op = model.metadata(nh).get<Op>();
|
||||
if (pp.is_generic) {
|
||||
auto& info = cv::util::any_cast<cv::detail::InOutInfo>(op.params);
|
||||
|
||||
for (const auto& a : info.in_names)
|
||||
{
|
||||
pp.input_names.push_back(a);
|
||||
}
|
||||
// Adding const input is necessary because the definition of input_names
|
||||
// includes const input.
|
||||
for (const auto& a : pp.const_inputs)
|
||||
{
|
||||
pp.input_names.push_back(a.first);
|
||||
}
|
||||
pp.num_in = info.in_names.size();
|
||||
|
||||
for (const auto& a : info.out_names)
|
||||
{
|
||||
pp.output_names.push_back(a);
|
||||
}
|
||||
pp.num_out = info.out_names.size();
|
||||
}
|
||||
|
||||
gm.metadata(nh).set(ONNXUnit{pp});
|
||||
gm.metadata(nh).set(ONNXCallable{ki.run});
|
||||
gm.metadata(nh).set(CustomMetaFunction{ki.customMetaFunc});
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
virtual inline bool canReshape() const override { return false; }
|
||||
virtual inline void reshape(ade::Graph&, const GCompileArgs&) override {
|
||||
GAPI_Assert(false); // Not implemented yet
|
||||
GAPI_Error("InternalError"); // Not implemented yet
|
||||
}
|
||||
|
||||
virtual void run(std::vector<InObj> &&input_objs,
|
||||
|
||||
@@ -6,26 +6,25 @@
|
||||
|
||||
#include <ade/util/zip_range.hpp> // zip_range, indexed
|
||||
|
||||
#include "compiler/gmodel.hpp"
|
||||
#include <opencv2/gapi/garg.hpp>
|
||||
#include <opencv2/gapi/util/throw.hpp> // throw_error
|
||||
#include <opencv2/gapi/python/python.hpp>
|
||||
|
||||
#include "api/gbackend_priv.hpp"
|
||||
#include "backends/common/gbackend.hpp"
|
||||
|
||||
cv::gapi::python::GPythonKernel::GPythonKernel(cv::gapi::python::Impl run)
|
||||
: m_run(run)
|
||||
cv::gapi::python::GPythonKernel::GPythonKernel(cv::gapi::python::Impl runf,
|
||||
cv::gapi::python::Setup setupf)
|
||||
: run(runf), setup(setupf), is_stateful(setup != nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
cv::GRunArgs cv::gapi::python::GPythonKernel::operator()(const cv::gapi::python::GPythonContext& ctx)
|
||||
{
|
||||
return m_run(ctx);
|
||||
}
|
||||
|
||||
cv::gapi::python::GPythonFunctor::GPythonFunctor(const char* id,
|
||||
const cv::gapi::python::GPythonFunctor::Meta &meta,
|
||||
const cv::gapi::python::Impl& impl)
|
||||
: gapi::GFunctor(id), impl_{GPythonKernel{impl}, meta}
|
||||
const cv::gapi::python::GPythonFunctor::Meta& meta,
|
||||
const cv::gapi::python::Impl& impl,
|
||||
const cv::gapi::python::Setup& setup)
|
||||
: gapi::GFunctor(id), impl_{GPythonKernel{impl, setup}, meta}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -68,6 +67,7 @@ class GPythonExecutable final: public cv::gimpl::GIslandExecutable
|
||||
virtual cv::RMat allocate(const cv::GMatDesc&) const override { return {}; }
|
||||
|
||||
virtual bool canReshape() const override { return true; }
|
||||
virtual void handleNewStream() override;
|
||||
virtual void reshape(ade::Graph&, const cv::GCompileArgs&) override {
|
||||
// Do nothing here
|
||||
}
|
||||
@@ -80,6 +80,7 @@ public:
|
||||
cv::gimpl::GModel::ConstGraph m_gm;
|
||||
cv::gapi::python::GPythonKernel m_kernel;
|
||||
ade::NodeHandle m_op;
|
||||
cv::GArg m_node_state;
|
||||
|
||||
cv::GTypesInfo m_out_info;
|
||||
cv::GMetaArgs m_in_metas;
|
||||
@@ -149,10 +150,19 @@ static void writeBack(cv::GRunArg& arg, cv::GRunArgP& out)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported output type");
|
||||
GAPI_Error("Unsupported output type");
|
||||
}
|
||||
}
|
||||
|
||||
void GPythonExecutable::handleNewStream()
|
||||
{
|
||||
if (!m_kernel.is_stateful)
|
||||
return;
|
||||
|
||||
m_node_state = m_kernel.setup(cv::gimpl::GModel::collectInputMeta(m_gm, m_op),
|
||||
m_gm.metadata(m_op).get<cv::gimpl::Op>().args);
|
||||
}
|
||||
|
||||
void GPythonExecutable::run(std::vector<InObj> &&input_objs,
|
||||
std::vector<OutObj> &&output_objs)
|
||||
{
|
||||
@@ -165,9 +175,15 @@ void GPythonExecutable::run(std::vector<InObj> &&input_objs,
|
||||
std::back_inserter(inputs),
|
||||
std::bind(&packArg, std::ref(m_res), _1));
|
||||
|
||||
cv::gapi::python::GPythonContext ctx{inputs, m_in_metas, m_out_info, /*state*/{}};
|
||||
|
||||
cv::gapi::python::GPythonContext ctx{inputs, m_in_metas, m_out_info};
|
||||
auto outs = m_kernel(ctx);
|
||||
// NB: For stateful kernel add state to its execution context
|
||||
if (m_kernel.is_stateful)
|
||||
{
|
||||
ctx.m_state = cv::optional<cv::GArg>(m_node_state);
|
||||
}
|
||||
|
||||
auto outs = m_kernel.run(ctx);
|
||||
|
||||
for (auto&& it : ade::util::zip(outs, output_objs))
|
||||
{
|
||||
@@ -225,6 +241,12 @@ GPythonExecutable::GPythonExecutable(const ade::Graph& g,
|
||||
m_op = *it;
|
||||
m_kernel = cag.metadata(m_op).get<PythonUnit>().kernel;
|
||||
|
||||
// If kernel is stateful then prepare storage for its state.
|
||||
if (m_kernel.is_stateful)
|
||||
{
|
||||
m_node_state = cv::GArg{ };
|
||||
}
|
||||
|
||||
// Ensure this the only op in the graph
|
||||
if (std::any_of(it+1, nodes.end(), is_op))
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ class GStreamingIntrinExecutable final: public cv::gimpl::GIslandExecutable
|
||||
{
|
||||
virtual void run(std::vector<InObj> &&,
|
||||
std::vector<OutObj> &&) override {
|
||||
GAPI_Assert(false && "Not implemented");
|
||||
GAPI_Error("Not implemented");
|
||||
}
|
||||
|
||||
virtual void run(GIslandExecutable::IInput &in,
|
||||
@@ -188,7 +188,7 @@ void Copy::Actor::run(cv::gimpl::GIslandExecutable::IInput &in,
|
||||
break;
|
||||
// FIXME: Add support for remaining types
|
||||
default:
|
||||
GAPI_Assert(false && "Copy: unsupported data type");
|
||||
GAPI_Error("Copy: unsupported data type");
|
||||
}
|
||||
out.meta(out_arg, in_arg.meta);
|
||||
out.post(std::move(out_arg));
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
|
||||
#include "compiler/gcompiled_priv.hpp"
|
||||
#include "backends/common/gbackend.hpp"
|
||||
#include "executor/gexecutor.hpp"
|
||||
|
||||
// GCompiled private implementation ////////////////////////////////////////////
|
||||
void cv::GCompiled::Priv::setup(const GMetaArgs &_metaArgs,
|
||||
const GMetaArgs &_outMetas,
|
||||
std::unique_ptr<cv::gimpl::GExecutor> &&_pE)
|
||||
std::unique_ptr<cv::gimpl::GAbstractExecutor> &&_pE)
|
||||
{
|
||||
m_metas = _metaArgs;
|
||||
m_outMetas = _outMetas;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "opencv2/gapi/util/optional.hpp"
|
||||
#include "compiler/gmodel.hpp"
|
||||
#include "executor/gexecutor.hpp"
|
||||
#include "executor/gabstractexecutor.hpp"
|
||||
|
||||
// NB: BTW, GCompiled is the only "public API" class which
|
||||
// private part (implementation) is hosted in the "compiler/" module.
|
||||
@@ -36,14 +36,14 @@ class GAPI_EXPORTS GCompiled::Priv
|
||||
// If we want to go autonomous, we might to do something with this.
|
||||
GMetaArgs m_metas; // passed by user
|
||||
GMetaArgs m_outMetas; // inferred by compiler
|
||||
std::unique_ptr<cv::gimpl::GExecutor> m_exec;
|
||||
std::unique_ptr<cv::gimpl::GAbstractExecutor> m_exec;
|
||||
|
||||
void checkArgs(const cv::gimpl::GRuntimeArgs &args) const;
|
||||
|
||||
public:
|
||||
void setup(const GMetaArgs &metaArgs,
|
||||
const GMetaArgs &outMetas,
|
||||
std::unique_ptr<cv::gimpl::GExecutor> &&pE);
|
||||
std::unique_ptr<cv::gimpl::GAbstractExecutor> &&pE);
|
||||
bool isEmpty() const;
|
||||
|
||||
bool canReshape() const;
|
||||
|
||||
@@ -338,7 +338,7 @@ void cv::gimpl::GCompiler::validateInputMeta()
|
||||
return util::holds_alternative<cv::GOpaqueDesc>(meta);
|
||||
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
return false; // should never happen
|
||||
};
|
||||
@@ -485,7 +485,7 @@ cv::GStreamingCompiled cv::gimpl::GCompiler::produceStreamingCompiled(GPtr &&pg)
|
||||
// Otherwise, set it up with executor object only
|
||||
compiled.priv().setup(std::move(pE));
|
||||
}
|
||||
else GAPI_Assert(false && "Impossible happened -- please report a bug");
|
||||
else GAPI_Error("Impossible happened -- please report a bug");
|
||||
return compiled;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ ade::NodeHandle GIsland::producer(const ade::Graph &g,
|
||||
}
|
||||
// Consistency: A GIsland requested for producer() of slot_nh should
|
||||
// always had the appropriate GModel node handle in its m_out_ops vector.
|
||||
GAPI_Assert(false && "Broken GIslandModel ?.");
|
||||
GAPI_Error("Broken GIslandModel ?.");
|
||||
}
|
||||
|
||||
std::string GIsland::name() const
|
||||
@@ -164,7 +164,7 @@ void GIslandModel::generateInitial(GIslandModel::Graph &g,
|
||||
{
|
||||
case NodeType::OP: all_operations.insert(src_nh); break;
|
||||
case NodeType::DATA: data_to_slot[src_nh] = mkSlotNode(g, src_nh); break;
|
||||
default: GAPI_Assert(false); break;
|
||||
default: GAPI_Error("InternalError"); break;
|
||||
}
|
||||
} // for (src_g.nodes)
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
virtual bool canReshape() const = 0;
|
||||
virtual void reshape(ade::Graph& g, const GCompileArgs& args) = 0;
|
||||
virtual bool allocatesOutputs() const { return false; }
|
||||
virtual cv::RMat allocate(const cv::GMatDesc&) const { GAPI_Assert(false && "should never be called"); }
|
||||
virtual cv::RMat allocate(const cv::GMatDesc&) const { GAPI_Error("should never be called"); }
|
||||
|
||||
// This method is called when the GStreamingCompiled gets a new
|
||||
// input source to process. Normally this method is called once
|
||||
|
||||
@@ -162,7 +162,7 @@ cv::gimpl::Unrolled cv::gimpl::unrollExpr(const GProtoArgs &ins,
|
||||
|
||||
default:
|
||||
// Unsupported node shape
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
// GStreamingCompiled private implementation ///////////////////////////////////
|
||||
void cv::GStreamingCompiled::Priv::setup(const GMetaArgs &_metaArgs,
|
||||
const GMetaArgs &_outMetas,
|
||||
std::unique_ptr<cv::gimpl::GStreamingExecutor> &&_pE)
|
||||
std::unique_ptr<cv::gimpl::GAbstractStreamingExecutor> &&_pE)
|
||||
{
|
||||
m_metas = _metaArgs;
|
||||
m_outMetas = _outMetas;
|
||||
m_exec = std::move(_pE);
|
||||
}
|
||||
|
||||
void cv::GStreamingCompiled::Priv::setup(std::unique_ptr<cv::gimpl::GStreamingExecutor> &&_pE)
|
||||
void cv::GStreamingCompiled::Priv::setup(std::unique_ptr<cv::gimpl::GAbstractStreamingExecutor> &&_pE)
|
||||
{
|
||||
m_exec = std::move(_pE);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define OPENCV_GAPI_GSTREAMING_COMPILED_PRIV_HPP
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
#include "executor/gstreamingexecutor.hpp"
|
||||
#include "executor/gabstractstreamingexecutor.hpp"
|
||||
|
||||
namespace cv {
|
||||
|
||||
@@ -26,7 +26,7 @@ class GAPI_EXPORTS GStreamingCompiled::Priv
|
||||
{
|
||||
GMetaArgs m_metas; // passed by user
|
||||
GMetaArgs m_outMetas; // inferred by compiler
|
||||
std::unique_ptr<cv::gimpl::GStreamingExecutor> m_exec;
|
||||
std::unique_ptr<cv::gimpl::GAbstractStreamingExecutor> m_exec;
|
||||
|
||||
// NB: Used by python wrapper to clarify input/output types
|
||||
GTypesInfo m_out_info;
|
||||
@@ -35,8 +35,8 @@ class GAPI_EXPORTS GStreamingCompiled::Priv
|
||||
public:
|
||||
void setup(const GMetaArgs &metaArgs,
|
||||
const GMetaArgs &outMetas,
|
||||
std::unique_ptr<cv::gimpl::GStreamingExecutor> &&pE);
|
||||
void setup(std::unique_ptr<cv::gimpl::GStreamingExecutor> &&pE);
|
||||
std::unique_ptr<cv::gimpl::GAbstractStreamingExecutor> &&pE);
|
||||
void setup(std::unique_ptr<cv::gimpl::GAbstractStreamingExecutor> &&pE);
|
||||
bool isEmpty() const;
|
||||
|
||||
const GMetaArgs& metas() const;
|
||||
|
||||
@@ -149,7 +149,7 @@ void dumpDot(const ade::Graph &g, std::ostream& os)
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: GAPI_Assert(false);
|
||||
default: GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ void dumpDot(const ade::Graph &g, std::ostream& os)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void traceUp(cv::gimpl::GModel::Graph &g,
|
||||
// this recursive process (e.g. via some other output or branch in the
|
||||
// subgraph)
|
||||
if (g.metadata(nh).get<DesyncPath>().index != desync_id) {
|
||||
GAPI_Assert(false && "Desynchronization can't be nested!");
|
||||
GAPI_Error("Desynchronization can't be nested!");
|
||||
}
|
||||
return; // This object belongs to the desync path - exit early.
|
||||
}
|
||||
|
||||
@@ -371,10 +371,9 @@ cv::gimpl::findMatches(const cv::gimpl::GModel::Graph& patternGraph,
|
||||
testNodeMeta,
|
||||
isAlreadyVisited);
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported Node type!");
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
GAPI_Error("Unsupported Node type!");
|
||||
});
|
||||
|
||||
if (testIt == testOutputNodesLabeled.end()) {
|
||||
|
||||
@@ -117,7 +117,7 @@ struct ChangeT
|
||||
{
|
||||
case Direction::In: eh = g.link(m_sibling, m_node); break;
|
||||
case Direction::Out: eh = g.link(m_node, m_sibling); break;
|
||||
default: GAPI_Assert(false);
|
||||
default: GAPI_Error("InternalError");
|
||||
}
|
||||
GAPI_Assert(eh != nullptr);
|
||||
m_meta.copyTo(g, eh);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// 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) 2022 Intel Corporation
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
|
||||
#include "executor/gabstractexecutor.hpp"
|
||||
|
||||
cv::gimpl::GAbstractExecutor::GAbstractExecutor(std::unique_ptr<ade::Graph> &&g_model)
|
||||
: m_orig_graph(std::move(g_model))
|
||||
, m_island_graph(GModel::Graph(*m_orig_graph).metadata()
|
||||
.get<IslandModel>().model)
|
||||
, m_gm(*m_orig_graph)
|
||||
, m_gim(*m_island_graph)
|
||||
{
|
||||
}
|
||||
|
||||
const cv::gimpl::GModel::Graph& cv::gimpl::GAbstractExecutor::model() const
|
||||
{
|
||||
return m_gm;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// 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) 2022 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_GABSTRACT_EXECUTOR_HPP
|
||||
#define OPENCV_GAPI_GABSTRACT_EXECUTOR_HPP
|
||||
|
||||
#include <memory> // unique_ptr, shared_ptr
|
||||
|
||||
#include <utility> // tuple, required by magazine
|
||||
#include <unordered_map> // required by magazine
|
||||
|
||||
#include <ade/graph.hpp>
|
||||
|
||||
#include "backends/common/gbackend.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace gimpl {
|
||||
|
||||
// Graph-level executor interface.
|
||||
//
|
||||
// This class specifies API for a "super-executor" which orchestrates
|
||||
// the overall Island graph execution.
|
||||
//
|
||||
// Every Island (subgraph) execution is delegated to a particular
|
||||
// backend and is done opaquely to the GExecutor.
|
||||
//
|
||||
// Inputs to a GExecutor instance are:
|
||||
// - GIslandModel - a high-level graph model which may be seen as a
|
||||
// "procedure" to execute.
|
||||
// - GModel - a low-level graph of operations (from which a GIslandModel
|
||||
// is projected)
|
||||
// - GComputation runtime arguments - vectors of input/output objects
|
||||
//
|
||||
// Every GExecutor is responsible for
|
||||
// a. Maintaining non-island (intermediate) data objects within graph
|
||||
// b. Providing GIslandExecutables with input/output data according to
|
||||
// their protocols
|
||||
// c. Triggering execution of GIslandExecutables when task/data dependencies
|
||||
// are met.
|
||||
//
|
||||
// By default G-API stores all data on host, and cross-Island
|
||||
// exchange happens via host buffers (and CV data objects).
|
||||
//
|
||||
// Today's exchange data objects are:
|
||||
// - cv::Mat, cv::RMat - for image buffers
|
||||
// - cv::Scalar - for single values (with up to four components inside)
|
||||
// - cv::detail::VectorRef - an untyped wrapper over std::vector<T>
|
||||
// - cv::detail::OpaqueRef - an untyped wrapper over T
|
||||
// - cv::MediaFrame - for image textures and surfaces (e.g. in planar format)
|
||||
|
||||
class GAbstractExecutor
|
||||
{
|
||||
protected:
|
||||
std::unique_ptr<ade::Graph> m_orig_graph;
|
||||
std::shared_ptr<ade::Graph> m_island_graph;
|
||||
|
||||
cv::gimpl::GModel::Graph m_gm; // FIXME: make const?
|
||||
cv::gimpl::GIslandModel::Graph m_gim; // FIXME: make const?
|
||||
|
||||
public:
|
||||
explicit GAbstractExecutor(std::unique_ptr<ade::Graph> &&g_model);
|
||||
virtual ~GAbstractExecutor() = default;
|
||||
virtual void run(cv::gimpl::GRuntimeArgs &&args) = 0;
|
||||
|
||||
virtual bool canReshape() const = 0;
|
||||
virtual void reshape(const GMetaArgs& inMetas, const GCompileArgs& args) = 0;
|
||||
|
||||
virtual void prepareForNewStream() = 0;
|
||||
|
||||
const GModel::Graph& model() const; // FIXME: make it ConstGraph?
|
||||
};
|
||||
|
||||
} // namespace gimpl
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GABSTRACT_EXECUTOR_HPP
|
||||
@@ -0,0 +1,23 @@
|
||||
// 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) 2022 Intel Corporation
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
|
||||
#include "executor/gabstractstreamingexecutor.hpp"
|
||||
|
||||
cv::gimpl::GAbstractStreamingExecutor::GAbstractStreamingExecutor(std::unique_ptr<ade::Graph> &&g_model,
|
||||
const GCompileArgs &comp_args)
|
||||
: m_orig_graph(std::move(g_model))
|
||||
, m_island_graph(GModel::Graph(*m_orig_graph).metadata()
|
||||
.get<IslandModel>().model)
|
||||
, m_comp_args(comp_args)
|
||||
, m_gim(*m_island_graph)
|
||||
, m_desync(GModel::Graph(*m_orig_graph).metadata()
|
||||
.contains<Desynchronized>())
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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) 2022 Intel Corporation
|
||||
|
||||
#ifndef OPENCV_GAPI_GABSTRACT_STREAMING_EXECUTOR_HPP
|
||||
#define OPENCV_GAPI_GABSTRACT_STREAMING_EXECUTOR_HPP
|
||||
|
||||
#include <memory> // unique_ptr, shared_ptr
|
||||
|
||||
#include <ade/graph.hpp>
|
||||
|
||||
#include "backends/common/gbackend.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace gimpl {
|
||||
|
||||
class GAbstractStreamingExecutor
|
||||
{
|
||||
protected:
|
||||
std::unique_ptr<ade::Graph> m_orig_graph;
|
||||
std::shared_ptr<ade::Graph> m_island_graph;
|
||||
cv::GCompileArgs m_comp_args;
|
||||
|
||||
cv::gimpl::GIslandModel::Graph m_gim; // FIXME: make const?
|
||||
const bool m_desync;
|
||||
|
||||
public:
|
||||
explicit GAbstractStreamingExecutor(std::unique_ptr<ade::Graph> &&g_model,
|
||||
const cv::GCompileArgs &comp_args);
|
||||
virtual ~GAbstractStreamingExecutor() = default;
|
||||
virtual void setSource(GRunArgs &&args) = 0;
|
||||
virtual void start() = 0;
|
||||
virtual bool pull(cv::GRunArgsP &&outs) = 0;
|
||||
virtual bool pull(cv::GOptRunArgsP &&outs) = 0;
|
||||
|
||||
using PyPullResult = std::tuple<bool, cv::util::variant<cv::GRunArgs, cv::GOptRunArgs>>;
|
||||
virtual PyPullResult pull() = 0;
|
||||
|
||||
virtual bool try_pull(cv::GRunArgsP &&outs) = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual bool running() const = 0;
|
||||
};
|
||||
|
||||
} // namespace gimpl
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GABSTRACT_STREAMING_EXECUTOR_HPP
|
||||
@@ -16,11 +16,7 @@
|
||||
#include "compiler/passes/passes.hpp"
|
||||
|
||||
cv::gimpl::GExecutor::GExecutor(std::unique_ptr<ade::Graph> &&g_model)
|
||||
: m_orig_graph(std::move(g_model))
|
||||
, m_island_graph(GModel::Graph(*m_orig_graph).metadata()
|
||||
.get<IslandModel>().model)
|
||||
, m_gm(*m_orig_graph)
|
||||
, m_gim(*m_island_graph)
|
||||
: GAbstractExecutor(std::move(g_model))
|
||||
{
|
||||
// NB: Right now GIslandModel is acyclic, so for a naive execution,
|
||||
// simple unrolling to a list of triggers is enough
|
||||
@@ -79,7 +75,7 @@ cv::gimpl::GExecutor::GExecutor(std::unique_ptr<ade::Graph> &&g_model)
|
||||
break;
|
||||
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
break;
|
||||
} // switch(kind)
|
||||
} // for(gim nodes)
|
||||
@@ -252,7 +248,7 @@ void cv::gimpl::GExecutor::initResource(const ade::NodeHandle & nh, const ade::N
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,11 +420,6 @@ void cv::gimpl::GExecutor::run(cv::gimpl::GRuntimeArgs &&args)
|
||||
}
|
||||
}
|
||||
|
||||
const cv::gimpl::GModel::Graph& cv::gimpl::GExecutor::model() const
|
||||
{
|
||||
return m_gm;
|
||||
}
|
||||
|
||||
bool cv::gimpl::GExecutor::canReshape() const
|
||||
{
|
||||
// FIXME: Introduce proper reshaping support on GExecutor level
|
||||
|
||||
@@ -8,58 +8,18 @@
|
||||
#ifndef OPENCV_GAPI_GEXECUTOR_HPP
|
||||
#define OPENCV_GAPI_GEXECUTOR_HPP
|
||||
|
||||
#include <memory> // unique_ptr, shared_ptr
|
||||
|
||||
#include <utility> // tuple, required by magazine
|
||||
#include <unordered_map> // required by magazine
|
||||
|
||||
#include <ade/graph.hpp>
|
||||
|
||||
#include "backends/common/gbackend.hpp"
|
||||
#include "executor/gabstractexecutor.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace gimpl {
|
||||
|
||||
// Graph-level executor interface.
|
||||
//
|
||||
// This class specifies API for a "super-executor" which orchestrates
|
||||
// the overall Island graph execution.
|
||||
//
|
||||
// Every Island (subgraph) execution is delegated to a particular
|
||||
// backend and is done opaquely to the GExecutor.
|
||||
//
|
||||
// Inputs to a GExecutor instance are:
|
||||
// - GIslandModel - a high-level graph model which may be seen as a
|
||||
// "procedure" to execute.
|
||||
// - GModel - a low-level graph of operations (from which a GIslandModel
|
||||
// is projected)
|
||||
// - GComputation runtime arguments - vectors of input/output objects
|
||||
//
|
||||
// Every GExecutor is responsible for
|
||||
// a. Maintaining non-island (intermediate) data objects within graph
|
||||
// b. Providing GIslandExecutables with input/output data according to
|
||||
// their protocols
|
||||
// c. Triggering execution of GIslandExecutables when task/data dependencies
|
||||
// are met.
|
||||
//
|
||||
// By default G-API stores all data on host, and cross-Island
|
||||
// exchange happens via host buffers (and CV data objects).
|
||||
//
|
||||
// Today's exchange data objects are:
|
||||
// - cv::Mat - for image buffers
|
||||
// - cv::Scalar - for single values (with up to four components inside)
|
||||
// - cv::detail::VectorRef - an untyped wrapper over std::vector<T>
|
||||
//
|
||||
|
||||
class GExecutor
|
||||
class GExecutor final: public GAbstractExecutor
|
||||
{
|
||||
protected:
|
||||
Mag m_res;
|
||||
std::unique_ptr<ade::Graph> m_orig_graph;
|
||||
std::shared_ptr<ade::Graph> m_island_graph;
|
||||
|
||||
cv::gimpl::GModel::Graph m_gm; // FIXME: make const?
|
||||
cv::gimpl::GIslandModel::Graph m_gim; // FIXME: make const?
|
||||
|
||||
// FIXME: Naive executor details are here for now
|
||||
// but then it should be moved to another place
|
||||
@@ -85,14 +45,12 @@ protected:
|
||||
|
||||
public:
|
||||
explicit GExecutor(std::unique_ptr<ade::Graph> &&g_model);
|
||||
void run(cv::gimpl::GRuntimeArgs &&args);
|
||||
void run(cv::gimpl::GRuntimeArgs &&args) override;
|
||||
|
||||
bool canReshape() const;
|
||||
void reshape(const GMetaArgs& inMetas, const GCompileArgs& args);
|
||||
bool canReshape() const override;
|
||||
void reshape(const GMetaArgs& inMetas, const GCompileArgs& args) override;
|
||||
|
||||
void prepareForNewStream();
|
||||
|
||||
const GModel::Graph& model() const; // FIXME: make it ConstGraph?
|
||||
void prepareForNewStream() override;
|
||||
};
|
||||
|
||||
} // namespace gimpl
|
||||
|
||||
@@ -157,7 +157,7 @@ void sync_data(cv::GRunArgs &results, cv::GRunArgsP &outputs)
|
||||
*cv::util::get<cv::MediaFrame*>(out_obj) = std::move(cv::util::get<cv::MediaFrame>(res_obj));
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false && "This value type is not supported!"); // ...maybe because of STANDALONE mode.
|
||||
GAPI_Error("This value type is not supported!"); // ...maybe because of STANDALONE mode.
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ void sync_data(cv::gimpl::stream::Result &r, cv::GOptRunArgsP &outputs)
|
||||
} break;
|
||||
default:
|
||||
// ...maybe because of STANDALONE mode.
|
||||
GAPI_Assert(false && "This value type is not supported!");
|
||||
GAPI_Error("This value type is not supported!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -446,7 +446,7 @@ cv::gimpl::StreamMsg QueueReader::getInputVector(std::vector<Q*> &in_queues,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported cmd type in getInputVector()");
|
||||
GAPI_Error("Unsupported cmd type in getInputVector()");
|
||||
}
|
||||
} // for(in_queues)
|
||||
|
||||
@@ -920,7 +920,7 @@ class StreamingOutput final: public cv::gimpl::GIslandExecutable::IOutput
|
||||
m_stops_sent++;
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false && "Unreachable code");
|
||||
GAPI_Error("Unreachable code");
|
||||
}
|
||||
|
||||
for (auto &&q : m_out_queues[out_idx])
|
||||
@@ -1115,7 +1115,7 @@ void collectorThread(std::vector<Q*> in_queues,
|
||||
out_queue.push(Cmd{cv::util::get<cv::gimpl::Exception>(result)});
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false && "Unreachable code");
|
||||
GAPI_Error("Unreachable code");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1288,13 +1288,7 @@ public:
|
||||
// proper graph reshape and islands recompilation
|
||||
cv::gimpl::GStreamingExecutor::GStreamingExecutor(std::unique_ptr<ade::Graph> &&g_model,
|
||||
const GCompileArgs &comp_args)
|
||||
: m_orig_graph(std::move(g_model))
|
||||
, m_island_graph(GModel::Graph(*m_orig_graph).metadata()
|
||||
.get<IslandModel>().model)
|
||||
, m_comp_args(comp_args)
|
||||
, m_gim(*m_island_graph)
|
||||
, m_desync(GModel::Graph(*m_orig_graph).metadata()
|
||||
.contains<Desynchronized>())
|
||||
: GAbstractStreamingExecutor(std::move(g_model), comp_args)
|
||||
{
|
||||
GModel::Graph gm(*m_orig_graph);
|
||||
// NB: Right now GIslandModel is acyclic, and all the below code assumes that.
|
||||
@@ -1485,7 +1479,7 @@ cv::gimpl::GStreamingExecutor::GStreamingExecutor(std::unique_ptr<ade::Graph> &&
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GAPI_Assert(false);
|
||||
GAPI_Error("InternalError");
|
||||
break;
|
||||
} // switch(kind)
|
||||
} // for(gim nodes)
|
||||
@@ -1826,9 +1820,9 @@ bool cv::gimpl::GStreamingExecutor::pull(cv::GRunArgsP &&outs)
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
GAPI_Assert(false && "Unsupported cmd type in pull");
|
||||
GAPI_Error("Unsupported cmd type in pull");
|
||||
}
|
||||
GAPI_Assert(false && "Unreachable code");
|
||||
GAPI_Error("Unreachable code");
|
||||
}
|
||||
|
||||
bool cv::gimpl::GStreamingExecutor::pull(cv::GOptRunArgsP &&outs)
|
||||
@@ -1859,10 +1853,10 @@ bool cv::gimpl::GStreamingExecutor::pull(cv::GOptRunArgsP &&outs)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
GAPI_Assert(false && "Unreachable code");
|
||||
GAPI_Error("Unreachable code");
|
||||
}
|
||||
|
||||
std::tuple<bool, cv::util::variant<cv::GRunArgs, cv::GOptRunArgs>> cv::gimpl::GStreamingExecutor::pull()
|
||||
cv::gimpl::GAbstractStreamingExecutor::PyPullResult cv::gimpl::GStreamingExecutor::pull()
|
||||
{
|
||||
using RunArgs = cv::util::variant<cv::GRunArgs, cv::GOptRunArgs>;
|
||||
bool is_over = false;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
// on concurrent_bounded_queue
|
||||
#endif
|
||||
|
||||
#include <memory> // unique_ptr, shared_ptr
|
||||
#include <thread> // thread
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
@@ -26,9 +25,7 @@ template<typename T> using QueueClass = cv::gapi::own::concurrent_bounded_queue<
|
||||
#endif // TBB
|
||||
#include "executor/last_value.hpp"
|
||||
|
||||
#include <ade/graph.hpp>
|
||||
|
||||
#include "backends/common/gbackend.hpp"
|
||||
#include "executor/gabstractstreamingexecutor.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace gimpl {
|
||||
@@ -104,7 +101,7 @@ public:
|
||||
// FIXME: Currently all GExecutor comments apply also
|
||||
// to this one. Please document it separately in the future.
|
||||
|
||||
class GStreamingExecutor final
|
||||
class GStreamingExecutor final: public GAbstractStreamingExecutor
|
||||
{
|
||||
protected:
|
||||
// GStreamingExecutor is a state machine described as follows
|
||||
@@ -131,15 +128,9 @@ protected:
|
||||
RUNNING,
|
||||
} state = State::STOPPED;
|
||||
|
||||
std::unique_ptr<ade::Graph> m_orig_graph;
|
||||
std::shared_ptr<ade::Graph> m_island_graph;
|
||||
cv::GCompileArgs m_comp_args;
|
||||
cv::GMetaArgs m_last_metas;
|
||||
util::optional<bool> m_reshapable;
|
||||
|
||||
cv::gimpl::GIslandModel::Graph m_gim; // FIXME: make const?
|
||||
const bool m_desync;
|
||||
|
||||
// FIXME: Naive executor details are here for now
|
||||
// but then it should be moved to another place
|
||||
struct OpDesc
|
||||
@@ -202,14 +193,14 @@ public:
|
||||
explicit GStreamingExecutor(std::unique_ptr<ade::Graph> &&g_model,
|
||||
const cv::GCompileArgs &comp_args);
|
||||
~GStreamingExecutor();
|
||||
void setSource(GRunArgs &&args);
|
||||
void start();
|
||||
bool pull(cv::GRunArgsP &&outs);
|
||||
bool pull(cv::GOptRunArgsP &&outs);
|
||||
std::tuple<bool, cv::util::variant<cv::GRunArgs, cv::GOptRunArgs>> pull();
|
||||
bool try_pull(cv::GRunArgsP &&outs);
|
||||
void stop();
|
||||
bool running() const;
|
||||
void setSource(GRunArgs &&args) override;
|
||||
void start() override;
|
||||
bool pull(cv::GRunArgsP &&outs) override;
|
||||
bool pull(cv::GOptRunArgsP &&outs) override;
|
||||
PyPullResult pull() override;
|
||||
bool try_pull(cv::GRunArgsP &&outs) override;
|
||||
void stop() override;
|
||||
bool running() const override;
|
||||
};
|
||||
|
||||
} // namespace gimpl
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
#ifndef TBB_SUPPRESS_DEPRECATED_MESSAGES // supress warning
|
||||
#ifndef TBB_SUPPRESS_DEPRECATED_MESSAGES
|
||||
#define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
|
||||
#endif
|
||||
#include <tbb/tbb.h>
|
||||
|
||||
@@ -40,7 +40,7 @@ GStreamerMediaAdapter::GStreamerMediaAdapter(const cv::GFrameDesc& frameDesc,
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
GAPI_Assert(false && "Non NV12 or GRAY Media format is not expected here");
|
||||
GAPI_Error("Non NV12 or GRAY Media format is not expected here");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ GStreamerMediaAdapter::GStreamerMediaAdapter(const cv::GFrameDesc& frameDesc,
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
GAPI_Assert(false && "Non NV12 or GRAY Media format is not expected here");
|
||||
GAPI_Error("Non NV12 or GRAY Media format is not expected here");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ cv::MediaFrame::View GStreamerMediaAdapter::access(cv::MediaFrame::Access access
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
GAPI_Assert(false && "Non NV12 or GRAY Media format is not expected here");
|
||||
GAPI_Error("Non NV12 or GRAY Media format is not expected here");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ cv::MediaFrame::View GStreamerMediaAdapter::access(cv::MediaFrame::Access access
|
||||
}
|
||||
|
||||
cv::util::any GStreamerMediaAdapter::blobParams() const {
|
||||
GAPI_Assert(false && "No implementation for GStreamerMediaAdapter::blobParams()");
|
||||
GAPI_Error("No implementation for GStreamerMediaAdapter::blobParams()");
|
||||
}
|
||||
|
||||
} // namespace gst
|
||||
|
||||
@@ -69,12 +69,12 @@ GStreamerEnv::~GStreamerEnv()
|
||||
|
||||
const GStreamerEnv& GStreamerEnv::init()
|
||||
{
|
||||
GAPI_Assert(false && "Built without GStreamer support!");
|
||||
GAPI_Error("Built without GStreamer support!");
|
||||
}
|
||||
|
||||
GStreamerEnv::GStreamerEnv()
|
||||
{
|
||||
GAPI_Assert(false && "Built without GStreamer support!");
|
||||
GAPI_Error("Built without GStreamer support!");
|
||||
}
|
||||
|
||||
GStreamerEnv::~GStreamerEnv()
|
||||
|
||||
@@ -73,7 +73,7 @@ GStreamerPipeline::Priv::~Priv() { }
|
||||
|
||||
GStreamerPipeline::Priv::Priv(const std::string&)
|
||||
{
|
||||
GAPI_Assert(false && "Built without GStreamer support!");
|
||||
GAPI_Error("Built without GStreamer support!");
|
||||
}
|
||||
|
||||
IStreamSource::Ptr GStreamerPipeline::Priv::getStreamingSource(const std::string&,
|
||||
|
||||
@@ -205,7 +205,7 @@ void GStreamerSource::Priv::prepareVideoMeta()
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
GAPI_Assert(false && "Unsupported GStreamerSource FRAME type.");
|
||||
GAPI_Error("Unsupported GStreamerSource FRAME type.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -317,7 +317,7 @@ bool GStreamerSource::Priv::retrieveFrame(cv::Mat& data)
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
GAPI_Assert(false && "retrieveFrame - unsupported GStreamerSource FRAME type.");
|
||||
GAPI_Error("retrieveFrame - unsupported GStreamerSource FRAME type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,13 +354,13 @@ GStreamerSource::Priv::~Priv() { }
|
||||
|
||||
GStreamerSource::Priv::Priv(const std::string&, const GStreamerSource::OutputType)
|
||||
{
|
||||
GAPI_Assert(false && "Built without GStreamer support!");
|
||||
GAPI_Error("Built without GStreamer support!");
|
||||
}
|
||||
|
||||
GStreamerSource::Priv::Priv(std::shared_ptr<GStreamerPipelineFacade>, const std::string&,
|
||||
const GStreamerSource::OutputType)
|
||||
{
|
||||
GAPI_Assert(false && "Built without GStreamer support!");
|
||||
GAPI_Error("Built without GStreamer support!");
|
||||
}
|
||||
|
||||
bool GStreamerSource::Priv::pull(cv::gapi::wip::Data&)
|
||||
|
||||
@@ -65,7 +65,7 @@ static surface_ptr_t create_surface_RGB4_(mfxFrameInfo frameInfo,
|
||||
", offset: " << out_buf_ptr_offset <<
|
||||
", W: " << surfW <<
|
||||
", H: " << surfH);
|
||||
GAPI_Assert(false && "Invalid offset");
|
||||
GAPI_Error("Invalid offset");
|
||||
}
|
||||
|
||||
std::unique_ptr<mfxFrameSurface1> handle(new mfxFrameSurface1);
|
||||
@@ -98,7 +98,7 @@ static surface_ptr_t create_surface_other_(mfxFrameInfo frameInfo,
|
||||
", offset: " << out_buf_ptr_offset <<
|
||||
", W: " << surfW <<
|
||||
", H: " << surfH);
|
||||
GAPI_Assert(false && "Invalid offset");
|
||||
GAPI_Error("Invalid offset");
|
||||
}
|
||||
|
||||
std::unique_ptr<mfxFrameSurface1> handle(new mfxFrameSurface1);
|
||||
@@ -209,7 +209,7 @@ VPLCPUAccelerationPolicy::create_surface_pool(size_t pool_size, size_t surface_s
|
||||
if (!pool_table.emplace(preallocated_pool_memory_ptr, std::move(pool)).second) {
|
||||
GAPI_LOG_WARNING(nullptr, "Cannot insert pool, table size: " + std::to_string(pool_table.size()) <<
|
||||
", key: " << preallocated_pool_memory_ptr << " exists");
|
||||
GAPI_Assert(false && "Cannot create pool in VPLCPUAccelerationPolicy");
|
||||
GAPI_Error("Cannot create pool in VPLCPUAccelerationPolicy");
|
||||
}
|
||||
|
||||
return preallocated_pool_memory_ptr;
|
||||
@@ -248,7 +248,7 @@ VPLCPUAccelerationPolicy::surface_weak_ptr_t VPLCPUAccelerationPolicy::get_free_
|
||||
if (pool_it == pool_table.end()) {
|
||||
GAPI_LOG_WARNING(nullptr, "key is not found, table size: " <<
|
||||
pool_table.size());
|
||||
GAPI_Assert(false && "Invalid surface key requested in VPLCPUAccelerationPolicy");
|
||||
GAPI_Error("Invalid surface key requested in VPLCPUAccelerationPolicy");
|
||||
}
|
||||
|
||||
pool_t& requested_pool = pool_it->second;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "logger.hpp"
|
||||
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
#pragma comment(lib,"d3d11.lib")
|
||||
|
||||
#define D3D11_NO_HELPERS
|
||||
#include <d3d11.h>
|
||||
@@ -153,7 +152,7 @@ VPLDX11AccelerationPolicy::surface_weak_ptr_t VPLDX11AccelerationPolicy::get_fre
|
||||
}
|
||||
|
||||
size_t VPLDX11AccelerationPolicy::get_free_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "get_free_surface_count() is not implemented");
|
||||
GAPI_Error("get_free_surface_count() is not implemented");
|
||||
}
|
||||
|
||||
size_t VPLDX11AccelerationPolicy::get_surface_count(pool_key_t key) const {
|
||||
@@ -449,39 +448,39 @@ namespace wip {
|
||||
namespace onevpl {
|
||||
VPLDX11AccelerationPolicy::VPLDX11AccelerationPolicy(device_selector_ptr_t selector) :
|
||||
VPLAccelerationPolicy(selector) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLDX11AccelerationPolicy::~VPLDX11AccelerationPolicy() = default;
|
||||
|
||||
void VPLDX11AccelerationPolicy::init(session_t ) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
void VPLDX11AccelerationPolicy::deinit(session_t) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLDX11AccelerationPolicy::pool_key_t VPLDX11AccelerationPolicy::create_surface_pool(const mfxFrameAllocRequest&,
|
||||
mfxFrameInfo&) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLDX11AccelerationPolicy::surface_weak_ptr_t VPLDX11AccelerationPolicy::get_free_surface(pool_key_t) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
size_t VPLDX11AccelerationPolicy::get_free_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
size_t VPLDX11AccelerationPolicy::get_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
cv::MediaFrame::AdapterPtr VPLDX11AccelerationPolicy::create_frame_adapter(pool_key_t,
|
||||
const FrameConstructorArgs &) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
|
||||
@@ -39,10 +39,17 @@ VPLVAAPIAccelerationPolicy::VPLVAAPIAccelerationPolicy(device_selector_ptr_t sel
|
||||
|
||||
va_handle = reinterpret_cast<VADisplay>(devices.begin()->second.get_ptr());
|
||||
#else // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
}
|
||||
#else // __linux__
|
||||
VPLVAAPIAccelerationPolicy::VPLVAAPIAccelerationPolicy(device_selector_ptr_t selector) :
|
||||
VPLAccelerationPolicy(selector) {
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
#endif // __linux__
|
||||
|
||||
#if defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
VPLVAAPIAccelerationPolicy::~VPLVAAPIAccelerationPolicy() {
|
||||
vaTerminate(va_handle);
|
||||
GAPI_LOG_INFO(nullptr, "destroyed");
|
||||
@@ -90,45 +97,40 @@ cv::MediaFrame::AdapterPtr VPLVAAPIAccelerationPolicy::create_frame_adapter(pool
|
||||
return cpu_dispatcher->create_frame_adapter(key, params);
|
||||
}
|
||||
|
||||
#else // __linux__
|
||||
|
||||
VPLVAAPIAccelerationPolicy::VPLVAAPIAccelerationPolicy(device_selector_ptr_t selector) :
|
||||
VPLAccelerationPolicy(selector) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
#else // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
|
||||
VPLVAAPIAccelerationPolicy::~VPLVAAPIAccelerationPolicy() = default;
|
||||
|
||||
void VPLVAAPIAccelerationPolicy::init(session_t ) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
void VPLVAAPIAccelerationPolicy::deinit(session_t) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLVAAPIAccelerationPolicy::pool_key_t VPLVAAPIAccelerationPolicy::create_surface_pool(const mfxFrameAllocRequest&,
|
||||
mfxFrameInfo&) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLVAAPIAccelerationPolicy::surface_weak_ptr_t VPLVAAPIAccelerationPolicy::get_free_surface(pool_key_t) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
size_t VPLVAAPIAccelerationPolicy::get_free_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
size_t VPLVAAPIAccelerationPolicy::get_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
cv::MediaFrame::AdapterPtr VPLVAAPIAccelerationPolicy::create_frame_adapter(pool_key_t,
|
||||
const FrameConstructorArgs &) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
#endif // __linux__
|
||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
|
||||
@@ -46,7 +46,7 @@ size_t LockAdapter::read_lock(mfxMemId mid, mfxFrameData &data) {
|
||||
// adapter will throw error if VPL frame allocator fails
|
||||
if (sts != MFX_ERR_NONE) {
|
||||
impl->unlock_shared();
|
||||
GAPI_Assert(false && "Cannot lock frame on READ using VPL allocator");
|
||||
GAPI_Error("Cannot lock frame on READ using VPL allocator");
|
||||
}
|
||||
|
||||
return prev_lock_count;
|
||||
@@ -76,7 +76,7 @@ void LockAdapter::write_lock(mfxMemId mid, mfxFrameData &data) {
|
||||
// adapter will throw error if VPL frame allocator fails
|
||||
if (sts != MFX_ERR_NONE) {
|
||||
impl->unlock();
|
||||
GAPI_Assert(false && "Cannot lock frame on WRITE using VPL allocator");
|
||||
GAPI_Error("Cannot lock frame on WRITE using VPL allocator");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,13 +199,13 @@ void DX11AllocationItem::on_first_in_impl(mfxFrameData *ptr) {
|
||||
err = shared_device_context->Map(get_staging_texture_ptr(), 0, mapType, mapFlags, &lockedRect);
|
||||
if (S_OK != err && DXGI_ERROR_WAS_STILL_DRAWING != err) {
|
||||
GAPI_LOG_WARNING(nullptr, "Cannot Map staging texture in device context, error: " << std::to_string(HRESULT_CODE(err)));
|
||||
GAPI_Assert(false && "Cannot Map staging texture in device context");
|
||||
GAPI_Error("Cannot Map staging texture in device context");
|
||||
}
|
||||
} while (DXGI_ERROR_WAS_STILL_DRAWING == err);
|
||||
|
||||
if (FAILED(err)) {
|
||||
GAPI_LOG_WARNING(nullptr, "Cannot lock frame");
|
||||
GAPI_Assert(false && "Cannot lock frame");
|
||||
GAPI_Error("Cannot lock frame");
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#pragma comment(lib,"d3d11.lib")
|
||||
|
||||
#define D3D11_NO_HELPERS
|
||||
#define NOMINMAX
|
||||
|
||||
@@ -65,7 +65,6 @@ MediaFrame::View VPLMediaFrameCPUAdapter::access(MediaFrame::Access) {
|
||||
|
||||
cv::util::any VPLMediaFrameCPUAdapter::blobParams() const {
|
||||
throw std::runtime_error("VPLMediaFrameCPUAdapter::blobParams() is not implemented");
|
||||
return {};
|
||||
}
|
||||
|
||||
void VPLMediaFrameCPUAdapter::serialize(cv::gapi::s11n::IOStream&) {
|
||||
|
||||
@@ -114,17 +114,24 @@ MediaFrame::View VPLMediaFrameDX11Adapter::access(MediaFrame::Access mode) {
|
||||
}
|
||||
}
|
||||
|
||||
cv::util::any VPLMediaFrameDX11Adapter::blobParams() const {
|
||||
/*GAPI_Assert(false && "VPLMediaFrameDX11Adapter::blobParams() is not fully integrated"
|
||||
"in OpenVINO InferenceEngine and would be temporary disable.");*/
|
||||
#ifdef HAVE_INF_ENGINE
|
||||
mfxHDLPair VPLMediaFrameDX11Adapter::getHandle() const {
|
||||
auto surface_ptr_copy = get_surface();
|
||||
Surface::data_t& data = surface_ptr_copy->get_data();
|
||||
const Surface::info_t& info = surface_ptr_copy->get_info();
|
||||
const Surface::data_t& data = surface_ptr_copy->get_data();
|
||||
NativeHandleAdapter* native_handle_getter = reinterpret_cast<NativeHandleAdapter*>(data.MemId);
|
||||
|
||||
mfxHDLPair handle{};
|
||||
native_handle_getter->get_handle(data.MemId, reinterpret_cast<mfxHDL&>(handle));
|
||||
return handle;
|
||||
}
|
||||
|
||||
cv::util::any VPLMediaFrameDX11Adapter::blobParams() const {
|
||||
/*GAPI_Error("VPLMediaFrameDX11Adapter::blobParams() is not fully integrated"
|
||||
"in OpenVINO InferenceEngine and would be temporary disable.");*/
|
||||
#ifdef HAVE_INF_ENGINE
|
||||
mfxHDLPair handle = getHandle();
|
||||
|
||||
auto surface_ptr_copy = get_surface();
|
||||
const Surface::info_t& info = surface_ptr_copy->get_info();
|
||||
|
||||
GAPI_Assert(frame_desc.fmt == MediaFormat::NV12 &&
|
||||
"blobParams() for VPLMediaFrameDX11Adapter supports NV12 only");
|
||||
@@ -155,16 +162,16 @@ cv::util::any VPLMediaFrameDX11Adapter::blobParams() const {
|
||||
return std::make_pair(std::make_pair(y_tdesc, y_params),
|
||||
std::make_pair(uv_tdesc, uv_params));
|
||||
#else
|
||||
GAPI_Assert(false && "VPLMediaFrameDX11Adapter::blobParams() is not implemented");
|
||||
GAPI_Error("VPLMediaFrameDX11Adapter::blobParams() is not implemented");
|
||||
#endif // HAVE_INF_ENGINE
|
||||
}
|
||||
|
||||
void VPLMediaFrameDX11Adapter::serialize(cv::gapi::s11n::IOStream&) {
|
||||
GAPI_Assert(false && "VPLMediaFrameDX11Adapter::serialize() is not implemented");
|
||||
GAPI_Error("VPLMediaFrameDX11Adapter::serialize() is not implemented");
|
||||
}
|
||||
|
||||
void VPLMediaFrameDX11Adapter::deserialize(cv::gapi::s11n::IIStream&) {
|
||||
GAPI_Assert(false && "VPLMediaFrameDX11Adapter::deserialize() is not implemented");
|
||||
GAPI_Error("VPLMediaFrameDX11Adapter::deserialize() is not implemented");
|
||||
}
|
||||
|
||||
DXGI_FORMAT VPLMediaFrameDX11Adapter::get_dx11_color_format(uint32_t mfx_fourcc) {
|
||||
|
||||
@@ -37,6 +37,11 @@ public:
|
||||
GAPI_EXPORTS ~VPLMediaFrameDX11Adapter();
|
||||
MediaFrame::View access(MediaFrame::Access) override;
|
||||
|
||||
// FIXME: Consider a better solution since this approach
|
||||
// is not easily extendable for other adapters (oclcore.cpp)
|
||||
// FIXME: Use with caution since the handle might become invalid
|
||||
// due to reference counting
|
||||
mfxHDLPair getHandle() const;
|
||||
// The default implementation does nothing
|
||||
cv::util::any blobParams() const override;
|
||||
void serialize(cv::gapi::s11n::IOStream&) override;
|
||||
|
||||
@@ -17,26 +17,23 @@
|
||||
|
||||
#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 <d3d11.h>
|
||||
#include <d3d11_4.h>
|
||||
#pragma comment(lib, "dxgi")
|
||||
#undef D3D11_NO_HELPERS
|
||||
#undef NOMINMAX
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
|
||||
#ifdef __linux__
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#if defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
#include "va/va.h"
|
||||
#include "va/va_drm.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
#endif // __linux__
|
||||
|
||||
@@ -247,10 +244,10 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(const CfgParams& cfg_params) :
|
||||
suggested_device = IDeviceSelector::create<Device>(va_handle, "GPU", AccelType::VAAPI);
|
||||
suggested_context = IDeviceSelector::create<Context>(nullptr, AccelType::VAAPI);
|
||||
#else // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current linux configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current linux configuration");
|
||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
#else // #ifdef __linux__
|
||||
GAPI_Assert(false && "MFX_IMPL_VIA_VAAPI is supported on linux only");
|
||||
GAPI_Error("MFX_IMPL_VIA_VAAPI is supported on linux only");
|
||||
#endif // #ifdef __linux__
|
||||
break;
|
||||
}
|
||||
@@ -338,10 +335,10 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(Device::Ptr device_ptr,
|
||||
suggested_device = IDeviceSelector::create<Device>(device_ptr, device_id, AccelType::VAAPI);
|
||||
suggested_context = IDeviceSelector::create<Context>(nullptr, AccelType::VAAPI);
|
||||
#else // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current linux configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current linux configuration");
|
||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
#else // #ifdef __linux__
|
||||
GAPI_Assert(false && "MFX_IMPL_VIA_VAAPI is supported on linux only");
|
||||
GAPI_Error("MFX_IMPL_VIA_VAAPI is supported on linux only");
|
||||
#endif // #ifdef __linux__
|
||||
break;
|
||||
}
|
||||
@@ -397,10 +394,10 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(const Device &device,
|
||||
case AccelType::VAAPI:
|
||||
#ifdef __linux__
|
||||
#if !defined(HAVE_VA) || !defined(HAVE_VA_INTEL)
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current linux configuration");
|
||||
GAPI_Error("VPLVAAPIAccelerationPolicy unavailable in current linux configuration");
|
||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
#else // #ifdef __linux__
|
||||
GAPI_Assert(false && "MFX_IMPL_VIA_VAAPI is supported on linux only");
|
||||
GAPI_Error("MFX_IMPL_VIA_VAAPI is supported on linux only");
|
||||
#endif // #ifdef __linux__
|
||||
break;
|
||||
case AccelType::HOST:
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
class PlatformSpecificParams;
|
||||
struct PlatformSpecificParams;
|
||||
std::vector<CfgParam> update_param_with_accel_type(std::vector<CfgParam> &¶m_array, AccelType type);
|
||||
|
||||
struct GAPI_EXPORTS CfgParamDeviceSelector final: public IDeviceSelector {
|
||||
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
return ret;
|
||||
}
|
||||
mfxVariant create_impl(const std::string&, const std::string&) {
|
||||
GAPI_Assert(false && "Something wrong: you should not create mfxVariant "
|
||||
GAPI_Error("Something wrong: you should not create mfxVariant "
|
||||
"from string directly - native type is lost in this case");
|
||||
}
|
||||
};
|
||||
@@ -173,7 +173,7 @@ void extract_optional_param_by_name(const std::string &name,
|
||||
[&out_param](int64_t value) { out_param = cv::util::make_optional(static_cast<size_t>(value)); },
|
||||
[&out_param](float_t value) { out_param = cv::util::make_optional(static_cast<size_t>(value)); },
|
||||
[&out_param](double_t value) { out_param = cv::util::make_optional(static_cast<size_t>(value)); },
|
||||
[&out_param](void*) { GAPI_Assert(false && "`void*` is unsupported type"); },
|
||||
[&out_param](void*) { GAPI_Error("`void*` is unsupported type"); },
|
||||
[&out_param](const std::string& value) {
|
||||
out_param = cv::util::make_optional(strtoull_or_throw(value.c_str()));
|
||||
}),
|
||||
@@ -189,7 +189,7 @@ unsigned long strtoul_or_throw(const char* str) {
|
||||
((ret == ULONG_MAX) && errno == ERANGE)) {
|
||||
// nothing parsed from the string, handle errors or exit
|
||||
GAPI_LOG_WARNING(nullptr, "strtoul failed for: " << str);
|
||||
GAPI_Assert(false && "strtoul_or_throw");
|
||||
GAPI_Error("strtoul_or_throw");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ size_t strtoull_or_throw(const char* str) {
|
||||
((ret == ULLONG_MAX) && errno == ERANGE)) {
|
||||
// nothing parsed from the string, handle errors or exit
|
||||
GAPI_LOG_WARNING(nullptr, "strtoull failed for: " << str);
|
||||
GAPI_Assert(false && "strtoull_or_throw");
|
||||
GAPI_Error("strtoull_or_throw");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ int64_t strtoll_or_throw(const char* str) {
|
||||
((ret == LONG_MAX || ret == LONG_MIN) && errno == ERANGE)) {
|
||||
// nothing parsed from the string, handle errors or exit
|
||||
GAPI_LOG_WARNING(nullptr, "strtoll failed for: " << str);
|
||||
GAPI_Assert(false && "strtoll_or_throw");
|
||||
GAPI_Error("strtoll_or_throw");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ struct IDataProvider::mfx_bitstream : public mfxBitstream {};
|
||||
#else // HAVE_ONEVPL
|
||||
struct IDataProvider::mfx_bitstream {
|
||||
mfx_bitstream() {
|
||||
GAPI_Assert(false && "Reject to create `mfxBitstream` because library compiled without VPL/MFX support");
|
||||
GAPI_Error("Reject to create `mfxBitstream` because library compiled without VPL/MFX support");
|
||||
}
|
||||
};
|
||||
#endif // HAVE_ONEVPL
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// 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) 2022 Intel Corporation
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include <opencv2/gapi/streaming/onevpl/default.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/cfg_params.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
|
||||
|
||||
#include "cfg_param_device_selector.hpp"
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
std::shared_ptr<IDeviceSelector> getDefaultDeviceSelector(const std::vector<CfgParam>& cfg_params) {
|
||||
std::shared_ptr<CfgParamDeviceSelector> default_accel_contex(new CfgParamDeviceSelector(cfg_params));
|
||||
|
||||
return default_accel_contex;
|
||||
}
|
||||
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#else // HAVE_ONEVPL
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
std::shared_ptr<IDeviceSelector> getDefaultDeviceSelector(const std::vector<CfgParam>&) {
|
||||
std::cerr << "Cannot utilize getDefaultVPLDeviceAndCtx without HAVE_ONEVPL enabled" << std::endl;
|
||||
util::throw_error(std::logic_error("Cannot utilize getDefaultVPLDeviceAndCtx without HAVE_ONEVPL enabled"));
|
||||
}
|
||||
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // HAVE_ONEVPL
|
||||
@@ -5,14 +5,6 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
#ifdef HAVE_ONEVPL
|
||||
#include <errno.h>
|
||||
#ifdef _WIN32
|
||||
|
||||
#pragma comment(lib, "Mf.lib")
|
||||
#pragma comment(lib, "Mfuuid.lib")
|
||||
#pragma comment(lib, "Mfplat.lib")
|
||||
#pragma comment(lib, "shlwapi.lib")
|
||||
#pragma comment(lib, "mfreadwrite.lib")
|
||||
#endif // _WIN32
|
||||
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
#include "streaming/onevpl/demux/async_mfp_demux_data_provider.hpp"
|
||||
@@ -753,7 +745,7 @@ bool MFPAsyncDemuxDataProvider::fetch_bitstream_data(std::shared_ptr<mfx_bitstre
|
||||
GAPI_LOG_WARNING(nullptr, "[" << this << "] " <<
|
||||
"cannot find appropriate dmux buffer by key: " <<
|
||||
static_cast<void*>(out_bitsream->Data));
|
||||
GAPI_Assert(false && "invalid bitstream key");
|
||||
GAPI_Error("invalid bitstream key");
|
||||
}
|
||||
if (it->second) {
|
||||
it->second->Unlock();
|
||||
@@ -796,20 +788,20 @@ bool MFPAsyncDemuxDataProvider::empty() const {
|
||||
#else // _WIN32
|
||||
|
||||
MFPAsyncDemuxDataProvider::MFPAsyncDemuxDataProvider(const std::string&) {
|
||||
GAPI_Assert(false && "Unsupported: Microsoft Media Foundation is not available");
|
||||
GAPI_Error("Unsupported: Microsoft Media Foundation is not available");
|
||||
}
|
||||
IDataProvider::mfx_codec_id_type MFPAsyncDemuxDataProvider::get_mfx_codec_id() const {
|
||||
GAPI_Assert(false && "Unsupported: Microsoft Media Foundation is not available");
|
||||
GAPI_Error("Unsupported: Microsoft Media Foundation is not available");
|
||||
return std::numeric_limits<mfx_codec_id_type>::max();
|
||||
}
|
||||
|
||||
bool MFPAsyncDemuxDataProvider::fetch_bitstream_data(std::shared_ptr<mfx_bitstream> &) {
|
||||
GAPI_Assert(false && "Unsupported: Microsoft Media Foundation is not available");
|
||||
GAPI_Error("Unsupported: Microsoft Media Foundation is not available");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MFPAsyncDemuxDataProvider::empty() const {
|
||||
GAPI_Assert(false && "Unsupported: Microsoft Media Foundation is not available");
|
||||
GAPI_Error("Unsupported: Microsoft Media Foundation is not available");
|
||||
return true;
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user