Commit 4cdb4652 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

parents dbb30134 183e4d50
......@@ -23,3 +23,4 @@ bin/
*.tlog
build
node_modules
CMakeSettings.json
......@@ -22,69 +22,70 @@
# sqfu@openailab.com
#
SET(TENGINE_VERSION "tengine-opencv")
SET(OCV_TENGINE_DSTDIRECTORY ${OpenCV_BINARY_DIR}/3rdparty/libtengine)
SET(DEFAULT_OPENCV_TENGINE_SOURCE_PATH ${OCV_TENGINE_DSTDIRECTORY}/Tengine-${TENGINE_VERSION})
SET(TENGINE_COMMIT_VERSION "2f3cd86217f3530c8e4a82f3ed5af14c7a4e3943")
SET(OCV_TENGINE_DIR "${OpenCV_BINARY_DIR}/3rdparty/libtengine")
SET(OCV_TENGINE_SOURCE_PATH "${OCV_TENGINE_DIR}/Tengine-${TENGINE_COMMIT_VERSION}")
IF(EXISTS ${DEFAULT_OPENCV_TENGINE_SOURCE_PATH})
MESSAGE(STATUS "Tengine is exist already .")
IF(EXISTS "${OCV_TENGINE_SOURCE_PATH}")
MESSAGE(STATUS "Tengine is exist already at: ${OCV_TENGINE_SOURCE_PATH}")
SET(Tengine_FOUND ON)
set(BUILD_TENGINE ON)
SET(BUILD_TENGINE ON)
ELSE()
SET(OCV_TENGINE_FILENAME "${TENGINE_VERSION}.zip")#name2
SET(OCV_TENGINE_FILENAME "${TENGINE_COMMIT_VERSION}.zip")#name2
SET(OCV_TENGINE_URL "https://github.com/OAID/Tengine/archive/") #url2
SET(tengine_md5sum 9c80d91dc8413911522ec80cde013ae2) #md5sum2
SET(tengine_md5sum 9124324b6e2b350012e46ae1db4bad7d) #md5sum2
MESSAGE(STATUS "**** TENGINE DOWNLOAD BEGIN ****")
#MESSAGE(STATUS "**** TENGINE DOWNLOAD BEGIN ****")
ocv_download(FILENAME ${OCV_TENGINE_FILENAME}
HASH ${tengine_md5sum}
URL
"${OPENCV_TENGINE_URL}"
"$ENV{OPENCV_TENGINE_URL}"
"${OCV_TENGINE_URL}"
DESTINATION_DIR ${OCV_TENGINE_DSTDIRECTORY}
DESTINATION_DIR "${OCV_TENGINE_DIR}"
ID TENGINE
STATUS res
UNPACK RELATIVE_URL)
if (NOT res)
MESSAGE(STATUS "TENGINE DOWNLOAD FAILED .Turning Tengine_FOUND off.")
MESSAGE(STATUS "TENGINE DOWNLOAD FAILED. Turning Tengine_FOUND off.")
SET(Tengine_FOUND OFF)
else ()
MESSAGE(STATUS "TENGINE DOWNLOAD success . ")
SET(Tengine_FOUND ON)
set(BUILD_TENGINE ON)
SET(BUILD_TENGINE ON)
endif()
ENDIF()
if (BUILD_TENGINE)
set(HAVE_TENGINE 1)
if(BUILD_TENGINE)
SET(HAVE_TENGINE 1)
# android system
if(ANDROID)
if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
set(CONFIG_ARCH_ARM32 ON)
SET(CONFIG_ARCH_ARM32 ON)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
set(CONFIG_ARCH_ARM64 ON)
SET(CONFIG_ARCH_ARM64 ON)
endif()
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
else()
# linux system
if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
SET(CONFIG_ARCH_ARM32 ON)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64
SET(CONFIG_ARCH_ARM64 ON)
endif()
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
endif()
# linux system
if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
set(CONFIG_ARCH_ARM32 ON)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64
set(CONFIG_ARCH_ARM64 ON)
endif()
SET(DEFAULT_OPENCV_TENGINE_SOURCE_PATH ${OCV_TENGINE_DSTDIRECTORY}/Tengine-${TENGINE_VERSION})
set(BUILT_IN_OPENCV ON) ## set for tengine compile discern .
set(Tengine_INCLUDE_DIR ${DEFAULT_OPENCV_TENGINE_SOURCE_PATH}/core/include)
set(Tengine_LIB ${CMAKE_BINARY_DIR}/lib/${ANDROID_ABI}/libtengine.a)
if ( IS_DIRECTORY ${DEFAULT_OPENCV_TENGINE_SOURCE_PATH})
add_subdirectory("${DEFAULT_OPENCV_TENGINE_SOURCE_PATH}" ${OCV_TENGINE_DSTDIRECTORY}/build)
SET(BUILT_IN_OPENCV ON) ## set for tengine compile discern .
SET(Tengine_INCLUDE_DIR "${OCV_TENGINE_SOURCE_PATH}/core/include" CACHE INTERNAL "")
if(EXISTS "${OCV_TENGINE_SOURCE_PATH}/CMakeLists.txt")
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()
endif()
......@@ -423,7 +423,7 @@ OCV_OPTION(WITH_ANDROID_MEDIANDK "Use Android Media NDK for Video I/O (Android)"
VISIBLE_IF ANDROID
VERIFY HAVE_ANDROID_MEDIANDK)
OCV_OPTION(WITH_TENGINE "Include Arm Inference Tengine support" OFF
VISIBLE_IF (ARM OR AARCH64) AND UNIX AND NOT ANDROID AND NOT IOS
VISIBLE_IF (ARM OR AARCH64) AND (UNIX OR ANDROID) AND NOT IOS
VERIFY HAVE_TENGINE)
# OpenCV build components
......
......@@ -21,25 +21,42 @@
#
# ----------------------------------------------------------------------------
# Path for Tengine modules
# Path for Tengine binaries
# ----------------------------------------------------------------------------
set(OPENCV_LIBTENGINE_ROOT_DIR "" CACHE PATH "Where to look for additional OpenCV modules (can be ;-separated list of paths)")
set(OPENCV_LIBTENGINE_ROOT_DIR "" CACHE PATH "Path to TENGINE binaries installation")
IF(OPENCV_LIBTENGINE_ROOT_DIR)
IF(OPENCV_LIBTENGINE_ROOT_DIR AND NOT BUILD_TENGINE)
MESSAGE(STATUS "TENGINE:-- Set tengine lib dir by user ")
MESSAGE(STATUS "TENGINE:-- Use binaries at ${OPENCV_LIBTENGINE_ROOT_DIR}")
SET(Tengine_FOUND ON)
set(BUILD_TENGINE OFF)
SET(Tengine_INCLUDE_DIR ${OPENCV_LIBTENGINE_ROOT_DIR}/include)
SET(Tengine_LIB ${OPENCV_LIBTENGINE_ROOT_DIR}/lib/libtengine.a)
SET(Tengine_INCLUDE_DIR "${OPENCV_LIBTENGINE_ROOT_DIR}/include" CACHE PATH "TENGINE include dir")
SET(Tengine_LIB "${OPENCV_LIBTENGINE_ROOT_DIR}/lib/libtengine.a" CACHE PATH "TENGINE library dir")
ELSE()
MESSAGE(STATUS "TENGINE:-- Auto download Tengine source code. ")
IF(ANDROID)
IF(OPENCV_TENGINE_FORCE_ANDROID)
# nothing, use Android
ELSEIF(OPENCV_TENGINE_SKIP_ANDROID)
set(Tengine_FOUND OFF)
set(HAVE_TENGINE FALSE)
return()
ELSEIF(NOT DEFINED ANDROID_NDK_REVISION)
MESSAGE(STATUS "Android NDK version Tengine not support: ANDROID_NDK_REVISION is not defined")
set(Tengine_FOUND OFF)
set(HAVE_TENGINE FALSE)
return()
ELSEIF(ANDROID_NDK_REVISION VERSION_LESS 14)
MESSAGE(STATUS "Android NDK version Tengine not support: ANDROID_NDK_REVISION=${ANDROID_NDK_REVISION}")
set(Tengine_FOUND OFF)
set(HAVE_TENGINE FALSE)
return()
ENDIF()
ENDIF()
MESSAGE(STATUS "TENGINE:-- Build Tengine from source code. ")
include("${OpenCV_SOURCE_DIR}/3rdparty/libtengine/tengine.cmake")
ENDIF()
IF(NOT Tengine_LIB)
......@@ -55,11 +72,7 @@ IF (Tengine_FOUND)
set(TENGINE_INCLUDE_DIRS ${Tengine_INCLUDE_DIR})
ENDIF (Tengine_FOUND)
MESSAGE(STATUS "Tengine include is:" ${Tengine_INCLUDE_DIR})
MESSAGE(STATUS "Tengine library is:" ${Tengine_LIB})
MARK_AS_ADVANCED(
Tengine_INCLUDE_DIR
Tengine_LIB
Tengine
)
......@@ -31,7 +31,7 @@ that should be used to find the match.
- We need two primary components:
-# **Source image (I):** The image in which we expect to find a match to the template image
-# **Template image (T):** The patch image which will be compared to the template image
-# **Template image (T):** The patch image which will be compared to the source image
our goal is to detect the highest matching area:
......@@ -61,7 +61,7 @@ that should be used to find the match.
- If masking is needed for the match, three components are required:
-# **Source image (I):** The image in which we expect to find a match to the template image
-# **Template image (T):** The patch image which will be compared to the template image
-# **Template image (T):** The patch image which will be compared to the source image
-# **Mask image (M):** The mask, a grayscale image that masks the template
......
......@@ -1269,6 +1269,8 @@ const _Tp& Mat::at(const Vec<int, n>& idx) const
template<typename _Tp> inline
MatConstIterator_<_Tp> Mat::begin() const
{
if (empty())
return MatConstIterator_<_Tp>();
CV_DbgAssert( elemSize() == sizeof(_Tp) );
return MatConstIterator_<_Tp>((const Mat_<_Tp>*)this);
}
......@@ -1276,6 +1278,8 @@ MatConstIterator_<_Tp> Mat::begin() const
template<typename _Tp> inline
MatConstIterator_<_Tp> Mat::end() const
{
if (empty())
return MatConstIterator_<_Tp>();
CV_DbgAssert( elemSize() == sizeof(_Tp) );
MatConstIterator_<_Tp> it((const Mat_<_Tp>*)this);
it += total();
......@@ -1285,6 +1289,8 @@ MatConstIterator_<_Tp> Mat::end() const
template<typename _Tp> inline
MatIterator_<_Tp> Mat::begin()
{
if (empty())
return MatIterator_<_Tp>();
CV_DbgAssert( elemSize() == sizeof(_Tp) );
return MatIterator_<_Tp>((Mat_<_Tp>*)this);
}
......@@ -1292,6 +1298,8 @@ MatIterator_<_Tp> Mat::begin()
template<typename _Tp> inline
MatIterator_<_Tp> Mat::end()
{
if (empty())
return MatIterator_<_Tp>();
CV_DbgAssert( elemSize() == sizeof(_Tp) );
MatIterator_<_Tp> it((Mat_<_Tp>*)this);
it += total();
......@@ -2640,6 +2648,7 @@ MatConstIterator::MatConstIterator(const Mat* _m)
{
if( m && m->isContinuous() )
{
CV_Assert(!m->empty());
sliceStart = m->ptr();
sliceEnd = sliceStart + m->total()*elemSize;
}
......@@ -2653,6 +2662,7 @@ MatConstIterator::MatConstIterator(const Mat* _m, int _row, int _col)
CV_Assert(m && m->dims <= 2);
if( m->isContinuous() )
{
CV_Assert(!m->empty());
sliceStart = m->ptr();
sliceEnd = sliceStart + m->total()*elemSize;
}
......@@ -2667,6 +2677,7 @@ MatConstIterator::MatConstIterator(const Mat* _m, Point _pt)
CV_Assert(m && m->dims <= 2);
if( m->isContinuous() )
{
CV_Assert(!m->empty());
sliceStart = m->ptr();
sliceEnd = sliceStart + m->total()*elemSize;
}
......
......@@ -2072,4 +2072,12 @@ TEST(Mat, regression_12943) // memory usage: ~4.5 Gb
cv::flip(src, dst, 0);
}
TEST(Mat, empty_iterator_16855)
{
cv::Mat m;
EXPECT_NO_THROW(m.begin<uchar>());
EXPECT_NO_THROW(m.end<uchar>());
EXPECT_TRUE(m.begin<uchar>() == m.end<uchar>());
}
}} // namespace
......@@ -1050,7 +1050,7 @@ CV__DNN_INLINE_NS_BEGIN
* @param eta a coefficient in adaptive threshold formula: \f$nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\f$.
* @param top_k if `>0`, keep at most @p top_k picked indices.
*/
CV_EXPORTS_W void NMSBoxes(const std::vector<Rect>& bboxes, const std::vector<float>& scores,
CV_EXPORTS void NMSBoxes(const std::vector<Rect>& bboxes, const std::vector<float>& scores,
const float score_threshold, const float nms_threshold,
CV_OUT std::vector<int>& indices,
const float eta = 1.f, const int top_k = 0);
......
......@@ -279,6 +279,12 @@ class dnn_test(NewOpenCVTests):
self.assertTrue(ret)
normAssert(self, refs[i], result, 'Index: %d' % i, 1e-10)
def test_nms(self):
confs = (1, 1)
rects = ((0, 0, 0.4, 0.4), (0, 0, 0.2, 0.4)) # 0.5 overlap
self.assertTrue(all(cv.dnn.NMSBoxes(rects, confs, 0, 0.6).ravel() == (0, 1)))
def test_custom_layer(self):
class CropLayer(object):
def __init__(self, params, blobs):
......
This diff is collapsed.
......@@ -57,8 +57,13 @@ public:
net.setPreferableBackend(backend);
net.setPreferableTarget(target);
std::vector<String> inputNames;
for (int i = 0; i < numInps; ++i)
net.setInput(inps[i], numInps > 1 ? format("%d", i) : "");
inputNames.push_back(format("%d", i));
net.setInputsNames(inputNames);
for (int i = 0; i < numInps; ++i)
net.setInput(inps[i], inputNames[i]);
Mat out = net.forward("");
if (useSoftmax)
......@@ -173,6 +178,11 @@ TEST_P(Test_ONNX_layers, Clip)
testONNXModels("clip", npy);
}
TEST_P(Test_ONNX_layers, Shape)
{
testONNXModels("shape_of_constant");
}
TEST_P(Test_ONNX_layers, ReduceMean)
{
testONNXModels("reduce_mean");
......@@ -371,6 +381,11 @@ TEST_P(Test_ONNX_layers, Broadcast)
testONNXModels("channel_broadcast", npy, 0, 0, false, true, 2);
}
TEST_P(Test_ONNX_layers, DynamicResize)
{
testONNXModels("dynamic_resize", npy, 0, 0, false, true, 2);
}
TEST_P(Test_ONNX_layers, Div)
{
const String model = _tf("models/div.onnx");
......@@ -400,10 +415,8 @@ TEST_P(Test_ONNX_layers, Div)
TEST_P(Test_ONNX_layers, DynamicReshape)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
{
if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
}
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
testONNXModels("dynamic_reshape");
testONNXModels("dynamic_reshape_opset_11");
testONNXModels("flatten_by_prod");
......@@ -443,6 +456,7 @@ TEST_P(Test_ONNX_layers, Slice)
testONNXModels("slice", npy, 0, 0, false, false);
#else
testONNXModels("slice");
testONNXModels("slice_opset_11");
#endif
}
......
......@@ -164,7 +164,12 @@ if(OPENCV_SKIP_PYTHON_LOADER)
endif()
else()
ocv_assert(DEFINED OPENCV_PYTHON_INSTALL_PATH)
set(__python_binary_install_path "${OPENCV_PYTHON_INSTALL_PATH}/${__python_loader_subdir}python-${${PYTHON}_VERSION_MAJOR}.${${PYTHON}_VERSION_MINOR}")
if(${PYTHON}_LIMITED_API)
set(__python_binary_subdir "python-${${PYTHON}_VERSION_MAJOR}")
else()
set(__python_binary_subdir "python-${${PYTHON}_VERSION_MAJOR}.${${PYTHON}_VERSION_MINOR}")
endif()
set(__python_binary_install_path "${OPENCV_PYTHON_INSTALL_PATH}/${__python_loader_subdir}${__python_binary_subdir}")
endif()
install(TARGETS ${the_module}
......@@ -192,7 +197,7 @@ if(NOT OPENCV_SKIP_PYTHON_LOADER)
set(CMAKE_PYTHON_EXTENSION_INSTALL_PATH_BASE "LOADER_DIR")
endif()
if(DEFINED ${PYTHON}_VERSION_MINOR)
if(DEFINED ${PYTHON}_VERSION_MINOR AND NOT ${PYTHON}_LIMITED_API)
set(__target_config "config-${${PYTHON}_VERSION_MAJOR}.${${PYTHON}_VERSION_MINOR}.py")
else()
set(__target_config "config-${${PYTHON}_VERSION_MAJOR}.py")
......
......@@ -189,7 +189,10 @@ int main( int argc, const char** argv )
const int EDGE_THRESHOLD_LOW = 50;
const int EDGE_THRESHOLD_HIGH = 100;
CommandLineParser parser(argc, argv, keys);
parser.about("\nThis program demonstrates implementation of 'intelligent scissors' algorithm\n"
parser.about("\nThis program demonstrates implementation of 'Intelligent Scissors' algorithm designed\n"
"by Eric N. Mortensen and William A. Barrett, and described in article\n"
"'Intelligent Scissors for Image Composition':\n"
"http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.138.3811&rep=rep1&type=pdf\n"
"To start drawing a new contour select a pixel, click LEFT mouse button.\n"
"To fix a path click LEFT mouse button again.\n"
"To finish drawing a contour click RIGHT mouse button.\n");
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment