mirror of
https://github.com/opencv/opencv.git
synced 2024-11-30 22:40:17 +08:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
commit
e3d502310f
8
3rdparty/libtengine/tengine.cmake
vendored
8
3rdparty/libtengine/tengine.cmake
vendored
@ -22,7 +22,7 @@
|
||||
# sqfu@openailab.com
|
||||
#
|
||||
|
||||
SET(TENGINE_COMMIT_VERSION "2f3cd86217f3530c8e4a82f3ed5af14c7a4e3943")
|
||||
SET(TENGINE_COMMIT_VERSION "8a4c58e0e05cd850f4bb0936a330edc86dc0e28c")
|
||||
SET(OCV_TENGINE_DIR "${OpenCV_BINARY_DIR}/3rdparty/libtengine")
|
||||
SET(OCV_TENGINE_SOURCE_PATH "${OCV_TENGINE_DIR}/Tengine-${TENGINE_COMMIT_VERSION}")
|
||||
|
||||
@ -34,7 +34,7 @@ IF(EXISTS "${OCV_TENGINE_SOURCE_PATH}")
|
||||
ELSE()
|
||||
SET(OCV_TENGINE_FILENAME "${TENGINE_COMMIT_VERSION}.zip")#name2
|
||||
SET(OCV_TENGINE_URL "https://github.com/OAID/Tengine/archive/") #url2
|
||||
SET(tengine_md5sum 9124324b6e2b350012e46ae1db4bad7d) #md5sum2
|
||||
SET(tengine_md5sum f51ca8f3963faeeff3f019a6f6edc206) #md5sum2
|
||||
|
||||
#MESSAGE(STATUS "**** TENGINE DOWNLOAD BEGIN ****")
|
||||
ocv_download(FILENAME ${OCV_TENGINE_FILENAME}
|
||||
@ -69,7 +69,6 @@ if(BUILD_TENGINE)
|
||||
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
|
||||
SET(CONFIG_ARCH_ARM64 ON)
|
||||
endif()
|
||||
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
|
||||
else()
|
||||
# linux system
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
|
||||
@ -77,7 +76,6 @@ if(BUILD_TENGINE)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64
|
||||
SET(CONFIG_ARCH_ARM64 ON)
|
||||
endif()
|
||||
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
SET(BUILT_IN_OPENCV ON) ## set for tengine compile discern .
|
||||
@ -86,6 +84,6 @@ if(BUILD_TENGINE)
|
||||
add_subdirectory("${OCV_TENGINE_SOURCE_PATH}" "${OCV_TENGINE_DIR}/build")
|
||||
else()
|
||||
message(WARNING "TENGINE: Missing 'CMakeLists.txt' in source code package: ${OCV_TENGINE_SOURCE_PATH}")
|
||||
SET(HAVE_TENGINE 1)
|
||||
endif()
|
||||
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
@ -48,11 +48,31 @@ if(CUDA_FOUND)
|
||||
endif()
|
||||
|
||||
if(WITH_NVCUVID)
|
||||
macro(SEARCH_NVCUVID_HEADER _filename _result)
|
||||
# place header file under CUDA_TOOLKIT_TARGET_DIR or CUDA_TOOLKIT_ROOT_DIR
|
||||
find_path(_header_result
|
||||
${_filename}
|
||||
PATHS "${CUDA_TOOLKIT_TARGET_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}"
|
||||
ENV CUDA_PATH
|
||||
ENV CUDA_INC_PATH
|
||||
PATH_SUFFIXES include
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if("x${_header_result}" STREQUAL "x_header_result-NOTFOUND")
|
||||
set(${_result} 0)
|
||||
else()
|
||||
set(${_result} 1)
|
||||
endif()
|
||||
unset(_header_result CACHE)
|
||||
endmacro()
|
||||
SEARCH_NVCUVID_HEADER("nvcuvid.h" HAVE_NVCUVID_HEADER)
|
||||
SEARCH_NVCUVID_HEADER("dynlink_nvcuvid.h" HAVE_DYNLINK_NVCUVID_HEADER)
|
||||
find_cuda_helper_libs(nvcuvid)
|
||||
if(WIN32)
|
||||
find_cuda_helper_libs(nvcuvenc)
|
||||
endif()
|
||||
if(CUDA_nvcuvid_LIBRARY)
|
||||
if(CUDA_nvcuvid_LIBRARY AND (${HAVE_NVCUVID_HEADER} OR ${HAVE_DYNLINK_NVCUVID_HEADER}))
|
||||
# make sure to have both header and library before enabling
|
||||
set(HAVE_NVCUVID 1)
|
||||
endif()
|
||||
if(CUDA_nvcuvenc_LIBRARY)
|
||||
@ -98,7 +118,7 @@ if(CUDA_FOUND)
|
||||
else()
|
||||
set(CC_LIST ${ARGN})
|
||||
foreach(target_arch ${CC_LIST})
|
||||
string(REPLACE "." "" target_arch_short ${target_arch})
|
||||
string(REPLACE "." "" target_arch_short "${target_arch}")
|
||||
set(NVCC_OPTION "-gencode;arch=compute_${target_arch_short},code=sm_${target_arch_short}")
|
||||
execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" ${NVCC_OPTION} "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu"
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
|
||||
@ -108,7 +128,7 @@ if(CUDA_FOUND)
|
||||
set(${result_list} "${${result_list}} ${target_arch}")
|
||||
endif()
|
||||
endforeach()
|
||||
string(STRIP ${${result_list}} ${result_list})
|
||||
string(STRIP "${${result_list}}" ${result_list})
|
||||
set(CUDA_SUPPORTED_CC ${${result_list}} CACHE INTERNAL "List of supported compute capability")
|
||||
endif()
|
||||
endmacro()
|
||||
@ -122,7 +142,7 @@ if(CUDA_FOUND)
|
||||
endmacro()
|
||||
|
||||
macro(ocv_wipeout_deprecated _arch_bin_list)
|
||||
string(REPLACE "2.1" "2.1(2.0)" ${_arch_bin_list} ${${_arch_bin_list}})
|
||||
string(REPLACE "2.1" "2.1(2.0)" ${_arch_bin_list} "${${_arch_bin_list}}")
|
||||
endmacro()
|
||||
|
||||
set(__cuda_arch_ptx "")
|
||||
|
@ -88,7 +88,7 @@ FOREACH(SEARCH_PATH ${SEARCH_PATHS})
|
||||
ocv_find_openexr("-${OPENEXR_VERSION}")
|
||||
ocv_find_openexr("-${OPENEXR_VERSION}_s")
|
||||
ocv_find_openexr("-${OPENEXR_VERSION}_d")
|
||||
ocv_find_openexr("-${OPEXEXR_VERSION}_s_d")
|
||||
ocv_find_openexr("-${OPENEXR_VERSION}_s_d")
|
||||
ocv_find_openexr("")
|
||||
ocv_find_openexr("_s")
|
||||
ocv_find_openexr("_d")
|
||||
|
@ -95,6 +95,8 @@
|
||||
|
||||
/* NVIDIA Video Decoding API*/
|
||||
#cmakedefine HAVE_NVCUVID
|
||||
#cmakedefine HAVE_NVCUVID_HEADER
|
||||
#cmakedefine HAVE_DYNLINK_NVCUVID_HEADER
|
||||
|
||||
/* NVIDIA Video Encoding API*/
|
||||
#cmakedefine HAVE_NVCUVENC
|
||||
|
@ -101,6 +101,20 @@ namespace cv { namespace cuda
|
||||
cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
|
||||
cudaSafeCall( cudaBindTexture2D(0, tex, img.ptr(), &desc, img.cols, img.rows, img.step) );
|
||||
}
|
||||
|
||||
template<class T> inline void createTextureObjectPitch2D(cudaTextureObject_t* tex, PtrStepSz<T>& img, const cudaTextureDesc& texDesc)
|
||||
{
|
||||
cudaResourceDesc resDesc;
|
||||
memset(&resDesc, 0, sizeof(resDesc));
|
||||
resDesc.resType = cudaResourceTypePitch2D;
|
||||
resDesc.res.pitch2D.devPtr = static_cast<void*>(img.ptr());
|
||||
resDesc.res.pitch2D.height = img.rows;
|
||||
resDesc.res.pitch2D.width = img.cols;
|
||||
resDesc.res.pitch2D.pitchInBytes = img.step;
|
||||
resDesc.res.pitch2D.desc = cudaCreateChannelDesc<T>();
|
||||
|
||||
cudaSafeCall( cudaCreateTextureObject(tex, &resDesc, &texDesc, NULL) );
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
|
@ -51,18 +51,19 @@
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#define NOMINMAX // fix https://github.com/opencv/opencv/issues/17548
|
||||
#pragma warning( disable: 4714 ) //__forceinline is not inlined
|
||||
#pragma warning( disable: 4127 ) //conditional expression is constant
|
||||
#pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data
|
||||
#endif
|
||||
|
||||
#if EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3 \
|
||||
&& defined(CV_CXX11) && defined(CV_CXX_STD_ARRAY)
|
||||
#include <unsupported/Eigen/CXX11/Tensor>
|
||||
#define OPENCV_EIGEN_TENSOR_SUPPORT
|
||||
#endif // EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4714 ) //__forceinline is not inlined
|
||||
#pragma warning( disable: 4127 ) //conditional expression is constant
|
||||
#pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
|
@ -25,9 +25,26 @@ String dumpInputArray(InputArray argument)
|
||||
break; // done
|
||||
}
|
||||
ss << cv::format(" total(-1)=%lld", (long long int)argument.total(-1));
|
||||
ss << cv::format(" dims(-1)=%d", argument.dims(-1));
|
||||
Size size = argument.size(-1);
|
||||
ss << cv::format(" size(-1)=%dx%d", size.width, size.height);
|
||||
int dims = argument.dims(-1);
|
||||
ss << cv::format(" dims(-1)=%d", dims);
|
||||
if (dims <= 2)
|
||||
{
|
||||
Size size = argument.size(-1);
|
||||
ss << cv::format(" size(-1)=%dx%d", size.width, size.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
int sz[CV_MAX_DIM] = {0};
|
||||
argument.sizend(sz, -1);
|
||||
ss << " size(-1)=[";
|
||||
for (int i = 0; i < dims; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
ss << ' ';
|
||||
ss << sz[i];
|
||||
}
|
||||
ss << "]";
|
||||
}
|
||||
ss << " type(-1)=" << cv::typeToString(argument.type(-1));
|
||||
} while (0);
|
||||
}
|
||||
@ -61,10 +78,26 @@ CV_EXPORTS_W String dumpInputArrayOfArrays(InputArrayOfArrays argument)
|
||||
if (argument.total(-1) > 0)
|
||||
{
|
||||
ss << " type(0)=" << cv::typeToString(argument.type(0));
|
||||
ss << cv::format(" dims(0)=%d", argument.dims(0));
|
||||
size = argument.size(0);
|
||||
ss << cv::format(" size(0)=%dx%d", size.width, size.height);
|
||||
ss << " type(0)=" << cv::typeToString(argument.type(0));
|
||||
int dims = argument.dims(0);
|
||||
ss << cv::format(" dims(0)=%d", dims);
|
||||
if (dims <= 2)
|
||||
{
|
||||
Size size0 = argument.size(0);
|
||||
ss << cv::format(" size(0)=%dx%d", size0.width, size0.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
int sz[CV_MAX_DIM] = {0};
|
||||
argument.sizend(sz, 0);
|
||||
ss << " size(0)=[";
|
||||
for (int i = 0; i < dims; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
ss << ' ';
|
||||
ss << sz[i];
|
||||
}
|
||||
ss << "]";
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
@ -92,9 +125,26 @@ CV_EXPORTS_W String dumpInputOutputArray(InputOutputArray argument)
|
||||
break; // done
|
||||
}
|
||||
ss << cv::format(" total(-1)=%lld", (long long int)argument.total(-1));
|
||||
ss << cv::format(" dims(-1)=%d", argument.dims(-1));
|
||||
Size size = argument.size(-1);
|
||||
ss << cv::format(" size(-1)=%dx%d", size.width, size.height);
|
||||
int dims = argument.dims(-1);
|
||||
ss << cv::format(" dims(-1)=%d", dims);
|
||||
if (dims <= 2)
|
||||
{
|
||||
Size size = argument.size(-1);
|
||||
ss << cv::format(" size(-1)=%dx%d", size.width, size.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
int sz[CV_MAX_DIM] = {0};
|
||||
argument.sizend(sz, -1);
|
||||
ss << " size(-1)=[";
|
||||
for (int i = 0; i < dims; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
ss << ' ';
|
||||
ss << sz[i];
|
||||
}
|
||||
ss << "]";
|
||||
}
|
||||
ss << " type(-1)=" << cv::typeToString(argument.type(-1));
|
||||
} while (0);
|
||||
}
|
||||
@ -128,10 +178,26 @@ CV_EXPORTS_W String dumpInputOutputArrayOfArrays(InputOutputArrayOfArrays argume
|
||||
if (argument.total(-1) > 0)
|
||||
{
|
||||
ss << " type(0)=" << cv::typeToString(argument.type(0));
|
||||
ss << cv::format(" dims(0)=%d", argument.dims(0));
|
||||
size = argument.size(0);
|
||||
ss << cv::format(" size(0)=%dx%d", size.width, size.height);
|
||||
ss << " type(0)=" << cv::typeToString(argument.type(0));
|
||||
int dims = argument.dims(0);
|
||||
ss << cv::format(" dims(0)=%d", dims);
|
||||
if (dims <= 2)
|
||||
{
|
||||
Size size0 = argument.size(0);
|
||||
ss << cv::format(" size(0)=%dx%d", size0.width, size0.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
int sz[CV_MAX_DIM] = {0};
|
||||
argument.sizend(sz, 0);
|
||||
ss << " size(0)=[";
|
||||
for (int i = 0; i < dims; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
ss << ' ';
|
||||
ss << sz[i];
|
||||
}
|
||||
ss << "]";
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
@ -479,12 +479,12 @@ public:
|
||||
auto scale_x_y_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, ngraph::Shape{1}, &scale_x_y);
|
||||
auto shift_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, ngraph::Shape{1}, std::vector<float>{0.5});
|
||||
|
||||
auto axis = ngraph::op::Constant::create<int64_t>(ngraph::element::i64, ngraph::Shape{}, {0});
|
||||
auto splits = ngraph::op::Constant::create<int64_t>(ngraph::element::i64, ngraph::Shape{5}, {1, 1, 1, 1, rows - 4});
|
||||
auto split = std::make_shared<ngraph::op::v1::VariadicSplit>(input2d, axis, splits);
|
||||
std::shared_ptr<ngraph::Node> box_x;
|
||||
{
|
||||
auto lower_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{0, 0});
|
||||
auto upper_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{1, cols});
|
||||
box_x = std::make_shared<ngraph::op::v1::StridedSlice>(input2d, lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
box_x = std::make_shared<ngraph::op::Sigmoid>(box_x);
|
||||
box_x = std::make_shared<ngraph::op::Sigmoid>(split->output(0));
|
||||
box_x = std::make_shared<ngraph::op::v1::Subtract>(box_x, shift_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
box_x = std::make_shared<ngraph::op::v1::Multiply>(box_x, scale_x_y_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
box_x = std::make_shared<ngraph::op::v1::Add>(box_x, shift_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
@ -510,10 +510,7 @@ public:
|
||||
|
||||
std::shared_ptr<ngraph::Node> box_y;
|
||||
{
|
||||
auto lower_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{1, 0});
|
||||
auto upper_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{2, cols});
|
||||
box_y = std::make_shared<ngraph::op::v1::StridedSlice>(input2d, lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
box_y = std::make_shared<ngraph::op::Sigmoid>(box_y);
|
||||
box_y = std::make_shared<ngraph::op::Sigmoid>(split->output(1));
|
||||
box_y = std::make_shared<ngraph::op::v1::Subtract>(box_y, shift_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
box_y = std::make_shared<ngraph::op::v1::Multiply>(box_y, scale_x_y_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
box_y = std::make_shared<ngraph::op::v1::Add>(box_y, shift_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
@ -566,45 +563,32 @@ public:
|
||||
std::copy(bias_h.begin(), bias_h.begin() + h * anchors, bias_h.begin() + i * h * anchors);
|
||||
}
|
||||
|
||||
auto lower_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{2, 0});
|
||||
auto upper_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{3, cols});
|
||||
box_w = std::make_shared<ngraph::op::v1::StridedSlice>(input2d, lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
box_w = std::make_shared<ngraph::op::v0::Exp>(box_w);
|
||||
box_w = std::make_shared<ngraph::op::v0::Exp>(split->output(2));
|
||||
box_w = std::make_shared<ngraph::op::v1::Reshape>(box_w, shape_3d, true);
|
||||
auto anchor_w_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, box_broad_shape, bias_w.data());
|
||||
box_w = std::make_shared<ngraph::op::v1::Multiply>(box_w, anchor_w_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
|
||||
lower_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{3, 0});
|
||||
upper_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{4, cols});
|
||||
box_h = std::make_shared<ngraph::op::v1::StridedSlice>(input2d, lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
box_h = std::make_shared<ngraph::op::v0::Exp>(box_h);
|
||||
box_h = std::make_shared<ngraph::op::v0::Exp>(split->output(3));
|
||||
box_h = std::make_shared<ngraph::op::v1::Reshape>(box_h, shape_3d, true);
|
||||
auto anchor_h_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, box_broad_shape, bias_h.data());
|
||||
box_h = std::make_shared<ngraph::op::v1::Multiply>(box_h, anchor_h_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
}
|
||||
|
||||
auto region_splits = ngraph::op::Constant::create<int64_t>(ngraph::element::i64, ngraph::Shape{3}, {4, 1, rows - 5});
|
||||
auto region_split = std::make_shared<ngraph::op::v1::VariadicSplit>(region, axis, region_splits);
|
||||
|
||||
std::shared_ptr<ngraph::Node> scale;
|
||||
{
|
||||
auto lower_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{4, 0});
|
||||
auto upper_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{5, cols});
|
||||
scale = std::make_shared<ngraph::op::v1::StridedSlice>(region, lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
|
||||
if (classfix == -1)
|
||||
{
|
||||
auto thresh_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, ngraph::Shape{1}, std::vector<float>{0.5});
|
||||
auto mask = std::make_shared<ngraph::op::v1::Less>(scale, thresh_node);
|
||||
auto zero_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, mask->get_shape(), std::vector<float>(b * cols, 0));
|
||||
scale = std::make_shared<ngraph::op::v1::Select>(mask, scale, zero_node);
|
||||
}
|
||||
float thr = classfix == -1 ? 0.5 : 0;
|
||||
auto thresh_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, ngraph::Shape{1}, std::vector<float>{thr});
|
||||
auto mask = std::make_shared<ngraph::op::v1::Less>(region_split->output(1), thresh_node);
|
||||
auto zero_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, mask->get_shape(), std::vector<float>(cols, 0));
|
||||
scale = std::make_shared<ngraph::op::v1::Select>(mask, zero_node, region_split->output(1));
|
||||
}
|
||||
|
||||
std::shared_ptr<ngraph::Node> probs;
|
||||
{
|
||||
auto lower_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{5, 0});
|
||||
auto upper_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{rows, cols});
|
||||
auto classes = std::make_shared<ngraph::op::v1::StridedSlice>(region, lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
probs = std::make_shared<ngraph::op::v1::Multiply>(classes, scale, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
|
||||
probs = std::make_shared<ngraph::op::v1::Multiply>(region_split->output(2), scale, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
auto thresh_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, ngraph::Shape{1}, &thresh);
|
||||
auto mask = std::make_shared<ngraph::op::v1::Greater>(probs, thresh_node);
|
||||
auto zero_node = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, mask->get_shape(), std::vector<float>((rows - 5) * cols, 0));
|
||||
|
@ -347,16 +347,16 @@ struct RGB2YCrCb_i<ushort>
|
||||
sr0 = sr0 - sy0; sr1 = sr1 - sy1;
|
||||
sb0 = sb0 - sy0; sb1 = sb1 - sy1;
|
||||
|
||||
v_int32 scr0, scr1, scb0, scb1;
|
||||
v_int32 v_scr0, v_scr1, v_scb0, v_scb1;
|
||||
|
||||
scr0 = (sr0*vc3 + vdd) >> shift;
|
||||
scr1 = (sr1*vc3 + vdd) >> shift;
|
||||
scb0 = (sb0*vc4 + vdd) >> shift;
|
||||
scb1 = (sb1*vc4 + vdd) >> shift;
|
||||
v_scr0 = (sr0*vc3 + vdd) >> shift;
|
||||
v_scr1 = (sr1*vc3 + vdd) >> shift;
|
||||
v_scb0 = (sb0*vc4 + vdd) >> shift;
|
||||
v_scb1 = (sb1*vc4 + vdd) >> shift;
|
||||
|
||||
// saturate and pack
|
||||
cr = v_pack_u(scr0, scr1);
|
||||
cb = v_pack_u(scb0, scb1);
|
||||
cr = v_pack_u(v_scr0, v_scr1);
|
||||
cb = v_pack_u(v_scb0, v_scb1);
|
||||
|
||||
if(yuvOrder)
|
||||
{
|
||||
@ -781,36 +781,36 @@ struct YCrCb2RGB_i<uchar>
|
||||
v_int8 scr = v_reinterpret_as_s8(cr);
|
||||
v_int8 scb = v_reinterpret_as_s8(cb);
|
||||
|
||||
v_int16 scr0, scr1, scb0, scb1;
|
||||
v_expand(scr, scr0, scr1);
|
||||
v_expand(scb, scb0, scb1);
|
||||
v_int16 v_scr0, v_scr1, v_scb0, v_scb1;
|
||||
v_expand(scr, v_scr0, v_scr1);
|
||||
v_expand(scb, v_scb0, v_scb1);
|
||||
|
||||
v_int32 b00, b01, b10, b11;
|
||||
v_int32 g00, g01, g10, g11;
|
||||
v_int32 r00, r01, r10, r11;
|
||||
|
||||
v_mul_expand(scb0, vc3, b00, b01);
|
||||
v_mul_expand(scb1, vc3, b10, b11);
|
||||
v_mul_expand(v_scb0, vc3, b00, b01);
|
||||
v_mul_expand(v_scb1, vc3, b10, b11);
|
||||
if(yuvOrder)
|
||||
{
|
||||
// if YUV then C3 > 2^15
|
||||
// so we fix the multiplication
|
||||
v_int32 cb00, cb01, cb10, cb11;
|
||||
v_expand(scb0, cb00, cb01);
|
||||
v_expand(scb1, cb10, cb11);
|
||||
v_expand(v_scb0, cb00, cb01);
|
||||
v_expand(v_scb1, cb10, cb11);
|
||||
b00 += cb00 << 15; b01 += cb01 << 15;
|
||||
b10 += cb10 << 15; b11 += cb11 << 15;
|
||||
}
|
||||
|
||||
v_int32 t00, t01, t10, t11;
|
||||
v_mul_expand(scb0, vc2, t00, t01);
|
||||
v_mul_expand(scb1, vc2, t10, t11);
|
||||
v_mul_expand(scr0, vc1, g00, g01);
|
||||
v_mul_expand(scr1, vc1, g10, g11);
|
||||
v_mul_expand(v_scb0, vc2, t00, t01);
|
||||
v_mul_expand(v_scb1, vc2, t10, t11);
|
||||
v_mul_expand(v_scr0, vc1, g00, g01);
|
||||
v_mul_expand(v_scr1, vc1, g10, g11);
|
||||
g00 += t00; g01 += t01;
|
||||
g10 += t10; g11 += t11;
|
||||
v_mul_expand(scr0, vc0, r00, r01);
|
||||
v_mul_expand(scr1, vc0, r10, r11);
|
||||
v_mul_expand(v_scr0, vc0, r00, r01);
|
||||
v_mul_expand(v_scr1, vc0, r10, r11);
|
||||
|
||||
b00 = (b00 + vdescale) >> shift; b01 = (b01 + vdescale) >> shift;
|
||||
b10 = (b10 + vdescale) >> shift; b11 = (b11 + vdescale) >> shift;
|
||||
|
@ -105,22 +105,35 @@ class Arguments(NewOpenCVTests):
|
||||
a = np.array([[[1, 2]], [[3, 4]], [[5, 6]]], dtype=float)
|
||||
res5 = cv.utils.dumpInputArray(a) # 64FC2
|
||||
self.assertEqual(res5, "InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=3 dims(-1)=2 size(-1)=1x3 type(-1)=CV_64FC2")
|
||||
a = np.zeros((2,3,4), dtype='f')
|
||||
res6 = cv.utils.dumpInputArray(a)
|
||||
self.assertEqual(res6, "InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=6 dims(-1)=2 size(-1)=3x2 type(-1)=CV_32FC4")
|
||||
a = np.zeros((2,3,4,5), dtype='f')
|
||||
res7 = cv.utils.dumpInputArray(a)
|
||||
self.assertEqual(res7, "InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=120 dims(-1)=4 size(-1)=[2 3 4 5] type(-1)=CV_32FC1")
|
||||
|
||||
def test_InputArrayOfArrays(self):
|
||||
res1 = cv.utils.dumpInputArrayOfArrays(None)
|
||||
# self.assertEqual(res1, "InputArray: noArray()") # not supported
|
||||
self.assertEqual(res1, "InputArrayOfArrays: empty()=true kind=0x00050000 flags=0x01050000 total(-1)=0 dims(-1)=1 size(-1)=0x0")
|
||||
res2_1 = cv.utils.dumpInputArrayOfArrays((1, 2)) # { Scalar:all(1), Scalar::all(2) }
|
||||
self.assertEqual(res2_1, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_64FC1 dims(0)=2 size(0)=1x4 type(0)=CV_64FC1")
|
||||
self.assertEqual(res2_1, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_64FC1 dims(0)=2 size(0)=1x4")
|
||||
res2_2 = cv.utils.dumpInputArrayOfArrays([1.5])
|
||||
self.assertEqual(res2_2, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=1 dims(-1)=1 size(-1)=1x1 type(0)=CV_64FC1 dims(0)=2 size(0)=1x4 type(0)=CV_64FC1")
|
||||
self.assertEqual(res2_2, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=1 dims(-1)=1 size(-1)=1x1 type(0)=CV_64FC1 dims(0)=2 size(0)=1x4")
|
||||
a = np.array([[1, 2], [3, 4], [5, 6]])
|
||||
b = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
|
||||
res3 = cv.utils.dumpInputArrayOfArrays([a, b])
|
||||
self.assertEqual(res3, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_32SC1 dims(0)=2 size(0)=2x3 type(0)=CV_32SC1")
|
||||
self.assertEqual(res3, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_32SC1 dims(0)=2 size(0)=2x3")
|
||||
c = np.array([[[1, 2], [3, 4], [5, 6]]], dtype='f')
|
||||
res4 = cv.utils.dumpInputArrayOfArrays([c, a, b])
|
||||
self.assertEqual(res4, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=3 dims(-1)=1 size(-1)=3x1 type(0)=CV_32FC2 dims(0)=2 size(0)=3x1 type(0)=CV_32FC2")
|
||||
self.assertEqual(res4, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=3 dims(-1)=1 size(-1)=3x1 type(0)=CV_32FC2 dims(0)=2 size(0)=3x1")
|
||||
a = np.zeros((2,3,4), dtype='f')
|
||||
res5 = cv.utils.dumpInputArrayOfArrays([a, b])
|
||||
self.assertEqual(res5, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_32FC4 dims(0)=2 size(0)=3x2")
|
||||
# TODO: fix conversion error
|
||||
#a = np.zeros((2,3,4,5), dtype='f')
|
||||
#res6 = cv.utils.dumpInputArray([a, b])
|
||||
#self.assertEqual(res6, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_32FC1 dims(0)=4 size(0)=[2 3 4 5]")
|
||||
|
||||
def test_parse_to_bool_convertible(self):
|
||||
try_to_convert = partial(self._try_to_convert, cv.utils.dumpBool)
|
||||
|
@ -59,6 +59,8 @@ def check_executable(cmd):
|
||||
try:
|
||||
log.debug("Executing: %s" % cmd)
|
||||
result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
||||
if not isinstance(result, str):
|
||||
result = result.decode("utf-8")
|
||||
log.debug("Result: %s" % (result+'\n').split('\n')[0])
|
||||
return True
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user