From a0d227714e822fa1070cb5ed5cdf72f8cb9dc1d2 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 2 Sep 2019 15:35:35 +0300 Subject: [PATCH 1/8] dnn: use OpenVINO 2019R3 defines --- cmake/OpenCVDetectInferenceEngine.cmake | 4 ++-- modules/dnn/src/op_inf_engine.hpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/OpenCVDetectInferenceEngine.cmake b/cmake/OpenCVDetectInferenceEngine.cmake index 61bd2fa3b5..1e3d51dc57 100644 --- a/cmake/OpenCVDetectInferenceEngine.cmake +++ b/cmake/OpenCVDetectInferenceEngine.cmake @@ -80,9 +80,9 @@ endif() if(INF_ENGINE_TARGET) if(NOT INF_ENGINE_RELEASE) - message(WARNING "InferenceEngine version have not been set, 2019R2 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.") + message(WARNING "InferenceEngine version have not been set, 2019R3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.") endif() - set(INF_ENGINE_RELEASE "2019020000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)") + set(INF_ENGINE_RELEASE "2019030000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)") set_target_properties(${INF_ENGINE_TARGET} PROPERTIES INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}" ) diff --git a/modules/dnn/src/op_inf_engine.hpp b/modules/dnn/src/op_inf_engine.hpp index 4f195fdd37..c1340491aa 100644 --- a/modules/dnn/src/op_inf_engine.hpp +++ b/modules/dnn/src/op_inf_engine.hpp @@ -22,10 +22,11 @@ #define INF_ENGINE_RELEASE_2018R5 2018050000 #define INF_ENGINE_RELEASE_2019R1 2019010000 #define INF_ENGINE_RELEASE_2019R2 2019020000 +#define INF_ENGINE_RELEASE_2019R3 2019030000 #ifndef INF_ENGINE_RELEASE -#warning("IE version have not been provided via command-line. Using 2019R2 by default") -#define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2019R2 +#warning("IE version have not been provided via command-line. Using 2019R3 by default") +#define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2019R3 #endif #define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000)) From 84c3bbd9340d87b0117c5850016fa281087e0a6e Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 2 Sep 2019 15:35:52 +0300 Subject: [PATCH 2/8] OpenCV version '-openvino' --- modules/core/include/opencv2/core/version.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/version.hpp b/modules/core/include/opencv2/core/version.hpp index 483fb0bd54..95d2f67d9d 100644 --- a/modules/core/include/opencv2/core/version.hpp +++ b/modules/core/include/opencv2/core/version.hpp @@ -8,7 +8,7 @@ #define CV_VERSION_MAJOR 4 #define CV_VERSION_MINOR 1 #define CV_VERSION_REVISION 2 -#define CV_VERSION_STATUS "-pre" +#define CV_VERSION_STATUS "-openvino" #define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) From 8b42995e8b5ac498690ba59b8f541a64cdc4d5c0 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Thu, 5 Sep 2019 13:44:01 +0300 Subject: [PATCH 3/8] Add option to skip nested cmake structure on Windows --- cmake/OpenCVGenConfig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake index e8252a83ab..878d905376 100644 --- a/cmake/OpenCVGenConfig.cmake +++ b/cmake/OpenCVGenConfig.cmake @@ -122,7 +122,7 @@ endif() # Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages # -------------------------------------------------------------------------------------------- if(WIN32) - if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows) + if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows AND NOT OPENCV_SKIP_CMAKE_ROOT_CONFIG) ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" "${OPENCV_LIB_INSTALL_PATH}" "OpenCVConfig.root-WIN32.cmake.in") else() ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" "" "") From 08e4ffdf7978026b1848e753f82f9866e84c788d Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 5 Sep 2019 21:10:52 +0000 Subject: [PATCH 4/8] ffmpeg/4.x: update FFmpeg plugin ffmpeg: 4.1.3 -> 4.2.1 libvpx: 1.8.0 -> 1.8.1 --- 3rdparty/ffmpeg/ffmpeg.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/3rdparty/ffmpeg/ffmpeg.cmake b/3rdparty/ffmpeg/ffmpeg.cmake index b096a86041..5234479f79 100644 --- a/3rdparty/ffmpeg/ffmpeg.cmake +++ b/3rdparty/ffmpeg/ffmpeg.cmake @@ -1,9 +1,9 @@ -# Binaries branch name: ffmpeg/master_20190616 -# Binaries were created for OpenCV: 7b099e0fe2d929e55d6705b6ad510c2c9081606b -ocv_update(FFMPEG_BINARIES_COMMIT "998718df34e35ea0fa429724875fc3900faa266f") -ocv_update(FFMPEG_FILE_HASH_BIN32 "f03b47fb809edd2e06b6db135cbd3e49") -ocv_update(FFMPEG_FILE_HASH_BIN64 "5c4571459570c288d874704244c428b5") -ocv_update(FFMPEG_FILE_HASH_CMAKE "f710891525a04586d565d0e700e62a9c") +# Binaries branch name: ffmpeg/master_20190910 +# Binaries were created for OpenCV: bea2c7545243ba2dabce6badc94dd55894a8e5ca +ocv_update(FFMPEG_BINARIES_COMMIT "197f87f7e811a9ded35d989b37e50501ff6afaa4") +ocv_update(FFMPEG_FILE_HASH_BIN32 "ab380c9dde361f30dd3604f88eef6c48") +ocv_update(FFMPEG_FILE_HASH_BIN64 "90260a4da737fc045c9279567313ee9d") +ocv_update(FFMPEG_FILE_HASH_CMAKE "ad57c038ba34b868277ccbe6dd0f9602") function(download_win_ffmpeg script_var) set(${script_var} "" PARENT_SCOPE) From e98852a389b6d9835376003335ea253597d8c7c1 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Fri, 13 Sep 2019 13:11:35 +0300 Subject: [PATCH 5/8] AVFoundation: fix authorization request not being shown --- modules/videoio/src/cap_avfoundation_mac.mm | 26 +++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/videoio/src/cap_avfoundation_mac.mm b/modules/videoio/src/cap_avfoundation_mac.mm index 71df9245a0..0c61a08a65 100644 --- a/modules/videoio/src/cap_avfoundation_mac.mm +++ b/modules/videoio/src/cap_avfoundation_mac.mm @@ -339,10 +339,28 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) { } else if (status != AVAuthorizationStatusAuthorized) { - fprintf(stderr, "OpenCV: not authorized to capture video (status %ld), requesting...\n", status); - // TODO: doesn't work via ssh - [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL) { /* we don't care */}]; - // we do not wait for completion + if (!cv::utils::getConfigurationParameterBool("OPENCV_AVFOUNDATION_SKIP_AUTH", false)) + { + fprintf(stderr, "OpenCV: not authorized to capture video (status %ld), requesting...\n", status); + [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL) { /* we don't care */}]; + if ([NSThread isMainThread]) + { + // we run the main loop for 0.1 sec to show the message + [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; + } + else + { + fprintf(stderr, "OpenCV: can not spin main run loop from other thread, set " + "OPENCV_AVFOUNDATION_SKIP_AUTH=1 to disable authorization request " + "and perform it in your application.\n"); + } + } + else + { + fprintf(stderr, "OpenCV: not authorized to capture video (status %ld), set " + "OPENCV_AVFOUNDATION_SKIP_AUTH=0 to enable authorization request or " + "perform it in your application.\n", status); + } [localpool drain]; return 0; } From bd5d16ce36aeb70776b93f544829b26103160a64 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Fri, 13 Sep 2019 11:33:24 +0300 Subject: [PATCH 6/8] Fix DetectionModel in case of out of [0, 1] range detection prediction --- modules/dnn/src/model.cpp | 2 +- modules/dnn/test/test_model.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/dnn/src/model.cpp b/modules/dnn/src/model.cpp index 07965c485f..c903bac687 100644 --- a/modules/dnn/src/model.cpp +++ b/modules/dnn/src/model.cpp @@ -230,7 +230,7 @@ void DetectionModel::detect(InputArray frame, CV_OUT std::vector& classIds, int width = right - left + 1; int height = bottom - top + 1; - if (width * height <= 1) + if (width <= 2 || height <= 2) { left = data[j + 3] * frameWidth; top = data[j + 4] * frameHeight; diff --git a/modules/dnn/test/test_model.cpp b/modules/dnn/test/test_model.cpp index 8a333d9f6d..5bc5bd31fe 100644 --- a/modules/dnn/test/test_model.cpp +++ b/modules/dnn/test/test_model.cpp @@ -221,6 +221,28 @@ TEST_P(Test_Model, DetectionMobilenetSSD) scoreDiff, iouDiff, confThreshold, nmsThreshold, size, mean, scale); } +TEST_P(Test_Model, Detection_normalized) +{ + std::string img_path = _tf("grace_hopper_227.png"); + std::vector refClassIds = {15}; + std::vector refConfidences = {0.999222f}; + std::vector refBoxes = {Rect2d(0, 4, 227, 222)}; + + std::string weights_file = _tf("MobileNetSSD_deploy.caffemodel"); + std::string config_file = _tf("MobileNetSSD_deploy.prototxt"); + + Scalar mean = Scalar(127.5, 127.5, 127.5); + double scale = 1.0 / 127.5; + Size size{300, 300}; + + double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 5e-3 : 1e-5; + double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 1e-5; + float confThreshold = FLT_MIN; + double nmsThreshold = 0.0; + testDetectModel(weights_file, config_file, img_path, refClassIds, refConfidences, refBoxes, + scoreDiff, iouDiff, confThreshold, nmsThreshold, size, mean, scale); +} + TEST_P(Test_Model, Segmentation) { std::string inp = _tf("dog416.png"); From b8d4664e6e4ec509d2b6f8519d97608a7cdc6d5e Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Mon, 9 Sep 2019 19:24:54 +0300 Subject: [PATCH 7/8] 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 bad1e59b0d..dcf997d8a8 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -1619,7 +1619,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 6b4225b9d3..ea8ada4496 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -582,7 +582,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); @@ -591,6 +590,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 9fa6c2ac046f69a7c7c20895bfefd22164b51f19 Mon Sep 17 00:00:00 2001 From: Vitaly Tuzov Date: Tue, 17 Sep 2019 15:53:18 +0300 Subject: [PATCH 8/8] Fixed out of bound reading in DIS optical flow evaluation implementation --- modules/video/src/dis_flow.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/modules/video/src/dis_flow.cpp b/modules/video/src/dis_flow.cpp index 85400c71ca..a260b8726b 100644 --- a/modules/video/src/dis_flow.cpp +++ b/modules/video/src/dis_flow.cpp @@ -494,7 +494,6 @@ DISOpticalFlowImpl::PatchInverseSearch_ParBody::PatchInverseSearch_ParBody(DISOp v_float32x4 w10v = v_setall_f32(w10); \ v_float32x4 w11v = v_setall_f32(w11); \ \ - v_uint8x16 I0_row_16, I1_row_16, I1_row_shifted_16, I1_row_next_16, I1_row_next_shifted_16; \ v_uint16x8 I0_row_8, I1_row_8, I1_row_shifted_8, I1_row_next_8, I1_row_next_shifted_8, tmp; \ v_uint32x4 I0_row_4_left, I1_row_4_left, I1_row_shifted_4_left, I1_row_next_4_left, I1_row_next_shifted_4_left; \ v_uint32x4 I0_row_4_right, I1_row_4_right, I1_row_shifted_4_right, I1_row_next_4_right, \ @@ -502,29 +501,22 @@ DISOpticalFlowImpl::PatchInverseSearch_ParBody::PatchInverseSearch_ParBody(DISOp v_float32x4 I_diff_left, I_diff_right; \ \ /* Preload and expand the first row of I1: */ \ - I1_row_16 = v_load(I1_ptr); \ - I1_row_shifted_16 = v_extract<1>(I1_row_16, I1_row_16); \ - v_expand(I1_row_16, I1_row_8, tmp); \ - v_expand(I1_row_shifted_16, I1_row_shifted_8, tmp); \ + I1_row_8 = v_load_expand(I1_ptr); \ + I1_row_shifted_8 = v_load_expand(I1_ptr + 1); \ v_expand(I1_row_8, I1_row_4_left, I1_row_4_right); \ v_expand(I1_row_shifted_8, I1_row_shifted_4_left, I1_row_shifted_4_right); \ I1_ptr += I1_stride; #define HAL_PROCESS_BILINEAR_8x8_PATCH_EXTRACTION \ /* Load the next row of I1: */ \ - I1_row_next_16 = v_load(I1_ptr); \ - /* Circular shift left by 1 element: */ \ - I1_row_next_shifted_16 = v_extract<1>(I1_row_next_16, I1_row_next_16); \ - /* Expand to 8 ushorts (we only need the first 8 values): */ \ - v_expand(I1_row_next_16, I1_row_next_8, tmp); \ - v_expand(I1_row_next_shifted_16, I1_row_next_shifted_8, tmp); \ + I1_row_next_8 = v_load_expand(I1_ptr); \ + I1_row_next_shifted_8 = v_load_expand(I1_ptr + 1); \ /* Separate the left and right halves: */ \ v_expand(I1_row_next_8, I1_row_next_4_left, I1_row_next_4_right); \ v_expand(I1_row_next_shifted_8, I1_row_next_shifted_4_left, I1_row_next_shifted_4_right); \ \ /* Load current row of I0: */ \ - I0_row_16 = v_load(I0_ptr); \ - v_expand(I0_row_16, I0_row_8, tmp); \ + I0_row_8 = v_load_expand(I0_ptr); \ v_expand(I0_row_8, I0_row_4_left, I0_row_4_right); \ \ /* Compute diffs between I0 and bilinearly interpolated I1: */ \