From d974d4c6ce47d36341d92ba5930fc1641fbddca4 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Wed, 4 Sep 2019 11:20:12 +0300 Subject: [PATCH 1/9] cmake: download tries, customizable download parameters --- cmake/OpenCVDownload.cmake | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake index cdc47ad2cb..56c31b2787 100644 --- a/cmake/OpenCVDownload.cmake +++ b/cmake/OpenCVDownload.cmake @@ -22,6 +22,9 @@ set(OPENCV_DOWNLOAD_PATH "${OpenCV_SOURCE_DIR}/.cache" CACHE PATH "${HELP_OPENCV set(OPENCV_DOWNLOAD_LOG "${OpenCV_BINARY_DIR}/CMakeDownloadLog.txt") set(OPENCV_DOWNLOAD_WITH_CURL "${OpenCV_BINARY_DIR}/download_with_curl.sh") set(OPENCV_DOWNLOAD_WITH_WGET "${OpenCV_BINARY_DIR}/download_with_wget.sh") +set(OPENCV_DOWNLOAD_TRIES_LIST 1 CACHE STRING "List of download tries") # a list +set(OPENCV_DOWNLOAD_PARAMS INACTIVITY_TIMEOUT 60 TIMEOUT 600 CACHE STRING "Download parameters to be passed to file(DOWNLAOD ...)") +mark_as_advanced(OPENCV_DOWNLOAD_TRIES_LIST OPENCV_DOWNLOAD_PARAMS) # Init download cache directory and log file and helper scripts if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}") @@ -154,11 +157,17 @@ function(ocv_download) # Download if(NOT EXISTS "${CACHE_CANDIDATE}") ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"") - file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}" - INACTIVITY_TIMEOUT 60 - TIMEOUT 600 - STATUS status - LOG __log) + foreach(try ${OPENCV_DOWNLOAD_TRIES_LIST}) + ocv_download_log("#try ${try}") + file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}" + STATUS status + LOG __log + ${OPENCV_DOWNLOAD_PARAMS}) + if(status EQUAL 0) + break() + endif() + message(STATUS "Try ${try} failed") + endforeach() if(NOT OPENCV_SKIP_FILE_DOWNLOAD_DUMP) # workaround problem with old CMake versions: "Invalid escape sequence" string(LENGTH "${__log}" __log_length) if(__log_length LESS 65536) From 9d4f01626c48910ab99675f5cdd2fbf98ac09600 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Wed, 4 Sep 2019 13:59:28 +0300 Subject: [PATCH 2/9] cmake: add directory creation to download helper scripts --- cmake/OpenCVDownload.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake index 56c31b2787..63cf6d3238 100644 --- a/cmake/OpenCVDownload.cmake +++ b/cmake/OpenCVDownload.cmake @@ -204,8 +204,8 @@ For details please refer to the download log file: ${OPENCV_DOWNLOAD_LOG} ") # write helper scripts for failed downloads - file(APPEND "${OPENCV_DOWNLOAD_WITH_CURL}" "curl --output \"${CACHE_CANDIDATE}\" \"${DL_URL}\"\n") - file(APPEND "${OPENCV_DOWNLOAD_WITH_WGET}" "wget -O \"${CACHE_CANDIDATE}\" \"${DL_URL}\"\n") + file(APPEND "${OPENCV_DOWNLOAD_WITH_CURL}" "curl --create-dirs --output \"${CACHE_CANDIDATE}\" \"${DL_URL}\"\n") + file(APPEND "${OPENCV_DOWNLOAD_WITH_WGET}" "mkdir -p $(dirname ${CACHE_CANDIDATE}) && wget -O \"${CACHE_CANDIDATE}\" \"${DL_URL}\"\n") return() endif() From e7b6753a10857e1bc4d6b6cc2334e10a63acbb51 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 5 Sep 2019 15:41:11 +0300 Subject: [PATCH 3/9] imgproc: avoid manual memory allocation in connectedcomponents.cpp --- modules/imgproc/src/connectedcomponents.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/imgproc/src/connectedcomponents.cpp b/modules/imgproc/src/connectedcomponents.cpp index 9241c6c09e..7b815d6345 100644 --- a/modules/imgproc/src/connectedcomponents.cpp +++ b/modules/imgproc/src/connectedcomponents.cpp @@ -2543,10 +2543,10 @@ namespace cv{ //Array used to store info and labeled pixel by each thread. //Different threads affect different memory location of chunksSizeAndLabels const int chunksSizeAndLabelsSize = h + 1; - int *chunksSizeAndLabels = (int *)cv::fastMalloc(chunksSizeAndLabelsSize * sizeof(int)); + cv::AutoBuffer chunksSizeAndLabels(chunksSizeAndLabelsSize); //Tree of labels - LabelT *P = (LabelT *)cv::fastMalloc(Plength * sizeof(LabelT)); + cv::AutoBuffer P(Plength); //First label is for background P[0] = 0; @@ -2555,30 +2555,27 @@ namespace cv{ //First scan, each thread works with chunk of img.rows/nThreads rows //e.g. 300 rows, 4 threads -> each chunks is composed of 75 rows - cv::parallel_for_(range, FirstScan(img, imgLabels, P, chunksSizeAndLabels), nParallelStripes); + cv::parallel_for_(range, FirstScan(img, imgLabels, P.data(), chunksSizeAndLabels.data()), nParallelStripes); //merge labels of different chunks - mergeLabels(img, imgLabels, P, chunksSizeAndLabels); + mergeLabels(img, imgLabels, P.data(), chunksSizeAndLabels.data()); LabelT nLabels = 1; for (int i = 0; i < h; i = chunksSizeAndLabels[i]){ CV_Assert(i + 1 < chunksSizeAndLabelsSize); - flattenL(P, LabelT((i + 1) / 2) * LabelT((w + 1) / 2) + 1, chunksSizeAndLabels[i + 1], nLabels); + flattenL(P.data(), LabelT((i + 1) / 2) * LabelT((w + 1) / 2) + 1, chunksSizeAndLabels[i + 1], nLabels); } //Array for statistics data - StatsOp *sopArray = new StatsOp[h]; + cv::AutoBuffer sopArray(h); sop.init(nLabels); //Second scan - cv::parallel_for_(range, SecondScan(img, imgLabels, P, sop, sopArray, nLabels), nParallelStripes); + cv::parallel_for_(range, SecondScan(img, imgLabels, P.data(), sop, sopArray.data(), nLabels), nParallelStripes); - StatsOp::mergeStats(imgLabels, sopArray, sop, nLabels); + StatsOp::mergeStats(imgLabels, sopArray.data(), sop, nLabels); sop.finish(); - delete[] sopArray; - cv::fastFree(chunksSizeAndLabels); - cv::fastFree(P); return nLabels; } };//End struct LabelingGranaParallel From 6a49887695090092fd7c338f00714dfabd61ea81 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 5 Sep 2019 20:52:46 +0000 Subject: [PATCH 4/9] ffmpeg/3.4: update FFmpeg wrapper --- 3rdparty/ffmpeg/ffmpeg.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/3rdparty/ffmpeg/ffmpeg.cmake b/3rdparty/ffmpeg/ffmpeg.cmake index cba56b8688..ce73758696 100644 --- a/3rdparty/ffmpeg/ffmpeg.cmake +++ b/3rdparty/ffmpeg/ffmpeg.cmake @@ -1,8 +1,8 @@ -# Binaries branch name: ffmpeg/3.4_20190612 -# Binaries were created for OpenCV: 1c661e754812d3423e8c15ccb9cdab57fc122c44 -ocv_update(FFMPEG_BINARIES_COMMIT "d284fd09e76966e95f08e1ac3a1a28b227447501") -ocv_update(FFMPEG_FILE_HASH_BIN32 "a7032bf6cc1cb010dc055f352277792c") -ocv_update(FFMPEG_FILE_HASH_BIN64 "40d1a38b83a0413a3fcf9df1044fff2a") +# Binaries branch name: ffmpeg/3.4_20190905 +# Binaries were created for OpenCV: fafada28ebc0f2e5423a7d8ece425574ef01ff60 +ocv_update(FFMPEG_BINARIES_COMMIT "bf1730f4c4ba1996bed1fe268b52e4e942151cd6") +ocv_update(FFMPEG_FILE_HASH_BIN32 "6899624f88cb4cbb1604edc5e12b18ab") +ocv_update(FFMPEG_FILE_HASH_BIN64 "4729c052cb0c53ab56e9a0eed91559df") ocv_update(FFMPEG_FILE_HASH_CMAKE "3b90f67f4b429e77d3da36698cef700c") function(download_win_ffmpeg script_var) From bdf23ce8554486425307364464cc3693a27907d8 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 6 Sep 2019 17:48:24 +0300 Subject: [PATCH 5/9] ts: eliminate -Warray-bounds warning --- modules/ts/src/ts_func.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ts/src/ts_func.cpp b/modules/ts/src/ts_func.cpp index 60c88a7e65..928411d996 100644 --- a/modules/ts/src/ts_func.cpp +++ b/modules/ts/src/ts_func.cpp @@ -2703,7 +2703,7 @@ static void calcSobelKernel1D( int order, int _aperture_size, int size, vector Date: Fri, 6 Sep 2019 12:56:16 -0300 Subject: [PATCH 6/9] js docker build docs emcc latest warning --- .../js_setup/js_setup/js_setup.markdown | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/doc/js_tutorials/js_setup/js_setup/js_setup.markdown b/doc/js_tutorials/js_setup/js_setup/js_setup.markdown index 5036fd1d97..72a5683fe1 100644 --- a/doc/js_tutorials/js_setup/js_setup/js_setup.markdown +++ b/doc/js_tutorials/js_setup/js_setup/js_setup.markdown @@ -117,14 +117,41 @@ So, make sure [docker](https://www.docker.com/) is installed in your system and @code{.bash} git clone https://github.com/opencv/opencv.git cd opencv -docker run --rm --workdir /code -v "$PWD":/code "trzeci/emscripten:latest" python ./platforms/js/build_js.py build_js +docker run --rm --workdir /code -v "$PWD":/code "trzeci/emscripten:latest" python ./platforms/js/build_js.py build @endcode In Windows use the following PowerShell command: @code{.bash} -docker run --rm --workdir /code -v "$(get-location):/code" "trzeci/emscripten:latest" python ./platforms/js/build_js.py build_js +docker run --rm --workdir /code -v "$(get-location):/code" "trzeci/emscripten:latest" python ./platforms/js/build_js.py build @endcode -@note -The example uses latest version of [trzeci/emscripten](https://hub.docker.com/r/trzeci/emscripten) docker container. At this time, the latest version works fine and is `trzeci/emscripten:sdk-tag-1.38.32-64bit` +@warning +The example uses latest version of emscripten. If the build fails you should try a version that is known to work fine which is `1.38.32` using the following command: + +@code{.bash} +docker run --rm --workdir /code -v "$PWD":/code "trzeci/emscripten:sdk-tag-1.38.32-64bit" python ./platforms/js/build_js.py build +@endcode + +### Building the documentation with Docker + +To build the documentation `doxygen` needs to be installed. Create a file named `Dockerfile` with the following content: + +``` +FROM trzeci/emscripten:sdk-tag-1.38.32-64bit + +RUN apt-get update -y +RUN apt-get install -y doxygen +``` + +Then we build the docker image and name it `opencv-js-doc` with the following command (that needs to be run only once): + +@code{.bash} +docker build . -t opencv-js-doc +@endcode + +Now run the build command again, this time using the new image and passing `--build_doc`: + +@code{.bash} +docker run --rm --workdir /code -v "$PWD":/code "opencv-js-doc" python ./platforms/js/build_js.py build --build_doc +@endcode From b465c826963f9ea01d466f0281b568196e6ef933 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Thu, 12 Sep 2019 09:45:56 -0500 Subject: [PATCH 7/9] core: workaround old gcc vec_mul{e,o} (Issue #15506) ISA 2.07 (aka POWER8) effectively extended the expanding multiply operation to word types. The altivec intrinsics prior to gcc 8 did not get the update. Workaround this deficiency similar to other fixes. This was exposed by commit 33fb253a66275abaa5060ef318c9a5cc87c5fd6e which leverages the int -> dword expanding multiply. This fixes Issue #15506 --- .../core/include/opencv2/core/vsx_utils.hpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/modules/core/include/opencv2/core/vsx_utils.hpp b/modules/core/include/opencv2/core/vsx_utils.hpp index c60da3cbbc..0f1029de83 100644 --- a/modules/core/include/opencv2/core/vsx_utils.hpp +++ b/modules/core/include/opencv2/core/vsx_utils.hpp @@ -124,6 +124,33 @@ VSX_FINLINE(rt) fnm(const rg& a, const rg& b) \ #define VSX_IMPL_2VRG(rt, rg, opc, fnm) VSX_IMPL_2VRG_F(rt, rg, #opc" %0,%1,%2", fnm) +#if __GNUG__ < 8 + + // Support for int4 -> dword2 expanding multiply was added in GCC 8. + #ifdef vec_mule + #undef vec_mule + #endif + #ifdef vec_mulo + #undef vec_mulo + #endif + + VSX_REDIRECT_2RG(vec_ushort8, vec_uchar16, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_short8, vec_char16, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_int4, vec_short8, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_uint4, vec_ushort8, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_ushort8, vec_uchar16, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_short8, vec_char16, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_int4, vec_short8, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_uint4, vec_ushort8, vec_mulo, __builtin_vec_mulo) + + // dword2 support arrived in ISA 2.07 and GCC 8+ + VSX_IMPL_2VRG(vec_dword2, vec_int4, vmulesw, vec_mule) + VSX_IMPL_2VRG(vec_udword2, vec_uint4, vmuleuw, vec_mule) + VSX_IMPL_2VRG(vec_dword2, vec_int4, vmulosw, vec_mulo) + VSX_IMPL_2VRG(vec_udword2, vec_uint4, vmulouw, vec_mulo) + +#endif + #if __GNUG__ < 7 // up to GCC 6 vec_mul only supports precisions and llong # ifdef vec_mul From 0428f60d66618cc69fc9b435c3119d1ed2cf8e97 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Mon, 9 Sep 2019 19:24:54 +0300 Subject: [PATCH 8/9] Fix OpenVINO 2019R1 compilation --- modules/dnn/src/dnn.cpp | 3 ++- modules/dnn/src/op_inf_engine.cpp | 3 ++- modules/dnn/test/test_darknet_importer.cpp | 2 ++ modules/dnn/test/test_tf_importer.cpp | 5 ++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index d8045242cc..c95a1a2f2b 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -1556,7 +1556,8 @@ struct Net::Impl Ptr layer = ld.layerInstance; if (!fused && !layer->supportBackend(preferableBackend)) { - bool customizable = ld.id != 0 && ld.outputBlobs.size() == 1; + bool customizable = ld.id != 0 && ld.outputBlobs.size() == 1 && + INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2019R2); // TODO: there is a bug in Myriad plugin with custom layers shape infer. if (preferableTarget == DNN_TARGET_MYRIAD) { diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index 2a52f3b826..fd937657d1 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -581,7 +581,6 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::CNNNetwork& net) try { AutoLock lock(getInitializationMutex()); - InferenceEngine::Core& ie = getCore(); #if INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1) auto& sharedPlugins = getSharedPlugins(); auto pluginIt = sharedPlugins.find(device_name); @@ -590,6 +589,8 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::CNNNetwork& net) enginePtr = pluginIt->second; } else +#else + InferenceEngine::Core& ie = getCore(); #endif { #if INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1) diff --git a/modules/dnn/test/test_darknet_importer.cpp b/modules/dnn/test/test_darknet_importer.cpp index 10fb8fdb2e..e038652e2f 100644 --- a/modules/dnn/test/test_darknet_importer.cpp +++ b/modules/dnn/test/test_darknet_importer.cpp @@ -334,6 +334,8 @@ static const std::chrono::milliseconds async_timeout(500); typedef testing::TestWithParam > Test_Darknet_nets_async; TEST_P(Test_Darknet_nets_async, Accuracy) { + if (INF_ENGINE_VER_MAJOR_LT(2019020000)) + applyTestTag(CV_TEST_TAG_DNN_SKIP_IE); applyTestTag(CV_TEST_TAG_MEMORY_512MB); std::string prefix = get<0>(GetParam()); diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index 2a8fd88efe..436256f991 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -481,8 +481,11 @@ TEST_P(Test_TensorFlow_nets, Faster_RCNN) "faster_rcnn_resnet50_coco_2018_01_28"}; checkBackend(); - if (backend == DNN_BACKEND_INFERENCE_ENGINE && target != DNN_TARGET_CPU) +#ifdef INF_ENGINE_RELEASE + if (backend == DNN_BACKEND_INFERENCE_ENGINE && + (INF_ENGINE_VER_MAJOR_LT(2019020000) || target != DNN_TARGET_CPU)) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE); +#endif if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16); From 5c0502b470bbb51ef52e86e892b31268fc8d0563 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Fri, 13 Sep 2019 15:23:59 +0300 Subject: [PATCH 9/9] Fixed OSX build with Qt --- modules/highgui/src/window.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index 80c449612d..877d6751c9 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -85,12 +85,12 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu break; case cv::WND_PROP_TOPMOST: - #if defined(HAVE_WIN32UI) + #if defined (HAVE_QT) + // nothing + #elif defined(HAVE_WIN32UI) cvSetPropTopmost_W32(name, (prop_value != 0 ? true : false)); #elif defined(HAVE_COCOA) cvSetPropTopmost_COCOA(name, (prop_value != 0 ? true : false)); - #else - CV_LOG_WARNING(NULL, "Property WND_PROP_TOPMOST is not supported on current GUI backend"); #endif break; @@ -175,12 +175,13 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id) break; case cv::WND_PROP_TOPMOST: - #if defined(HAVE_WIN32UI) + #if defined (HAVE_QT) + return -1; + #elif defined(HAVE_WIN32UI) return cvGetPropTopmost_W32(name); #elif defined(HAVE_COCOA) return cvGetPropTopmost_COCOA(name); #else - CV_LOG_WARNING(NULL, "Property WND_PROP_TOPMOST is not supported on current GUI backend"); return -1; #endif break;