From 39aba80957e10b66a6c8f3f590c2d90e8238ca75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Do=C5=82bniak?= Date: Tue, 2 Aug 2022 20:01:26 +0200 Subject: [PATCH] OpenCV build switched off by default [2022/1.1] (#12358) * OCV build off by default * OCV on in the Linux Azure pipeline * Copy of OCV in the linux pipeline --- .ci/azure/android_arm64.yml | 1 - .ci/azure/linux.yml | 1 + .ci/azure/linux_arm64.yml | 1 - .ci/azure/linux_onnxruntime.yml | 1 - .ci/azure/mac.yml | 1 - .ci/azure/windows.yml | 2 +- .ci/openvino-onnx/Dockerfile | 1 - cmake/features.cmake | 2 +- src/bindings/c/tests/CMakeLists.txt | 10 +--- src/bindings/c/tests/ie_c_api_test.cpp | 83 ++++++++++++-------------- src/bindings/python/BUILDING.md | 2 - 11 files changed, 43 insertions(+), 62 deletions(-) diff --git a/.ci/azure/android_arm64.yml b/.ci/azure/android_arm64.yml index 0a58a656c7d..947dc98588f 100644 --- a/.ci/azure/android_arm64.yml +++ b/.ci/azure/android_arm64.yml @@ -110,7 +110,6 @@ jobs: -DANDROID_ABI=$(ANDROID_ABI_CONFIG) -DANDROID_STL=c++_shared -DANDROID_PLATFORM=$(ANDROID_SDK_VERSION) - -DENABLE_OPENCV=OFF -DENABLE_TESTS=ON -DENABLE_SAMPLES=ON -DENABLE_INTEL_MYRIAD=OFF diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index da72a39c50d..54f8206ca68 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -157,6 +157,7 @@ jobs: -DENABLE_FASTER_BUILD=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_REQUIREMENTS_INSTALL=OFF + -DENABLE_OPENCV=ON -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache diff --git a/.ci/azure/linux_arm64.yml b/.ci/azure/linux_arm64.yml index a1afb8a6d76..a01e66be404 100644 --- a/.ci/azure/linux_arm64.yml +++ b/.ci/azure/linux_arm64.yml @@ -127,7 +127,6 @@ jobs: -GNinja -DVERBOSE_BUILD=ON -DOpenCV_DIR=$(INSTALL_OPENCV)/cmake - -DENABLE_OPENCV=OFF -DPYTHON_INCLUDE_DIRS=$(INSTALL_PYTHON)/include/python3.8 -DPYTHON_LIBRARY=$(INSTALL_PYTHON)/lib/libpython3.8.so -DENABLE_PYTHON=ON diff --git a/.ci/azure/linux_onnxruntime.yml b/.ci/azure/linux_onnxruntime.yml index f35d5a669b5..85e39aa6cb6 100644 --- a/.ci/azure/linux_onnxruntime.yml +++ b/.ci/azure/linux_onnxruntime.yml @@ -95,7 +95,6 @@ jobs: -DPYTHON_EXECUTABLE=/usr/bin/python3.8 -DENABLE_INTEL_MYRIAD_COMMON=OFF -DENABLE_INTEL_GNA=OFF - -DENABLE_OPENCV=OFF -DENABLE_CPPLINT=OFF -DENABLE_TESTS=OFF -DENABLE_INTEL_CPU=ON diff --git a/.ci/azure/mac.yml b/.ci/azure/mac.yml index 2fa298a06a8..4e2adbf0cd5 100644 --- a/.ci/azure/mac.yml +++ b/.ci/azure/mac.yml @@ -145,7 +145,6 @@ jobs: set -e mkdir -p $(INSTALL_DIR)/opencv/ cmake -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake - cp -R $(REPO_DIR)/temp/opencv_4.5.2_osx/opencv/* $(INSTALL_DIR)/opencv/ workingDirectory: $(BUILD_DIR) displayName: 'Install tests' diff --git a/.ci/azure/windows.yml b/.ci/azure/windows.yml index 58078f17f73..50d376c4799 100644 --- a/.ci/azure/windows.yml +++ b/.ci/azure/windows.yml @@ -169,7 +169,7 @@ jobs: workingDirectory: $(BUILD_SAMPLES_TESTS_DIR) displayName: 'Install Samples Tests' - - script: $(CMAKE_CMD) -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake && xcopy $(REPO_DIR)\temp\opencv_4.5.2\opencv\* $(INSTALL_DIR)\opencv\ /e /h /y + - script: $(CMAKE_CMD) -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake workingDirectory: $(BUILD_DIR) displayName: 'Install tests' diff --git a/.ci/openvino-onnx/Dockerfile b/.ci/openvino-onnx/Dockerfile index dfa2a5de3d0..87ea41736e0 100644 --- a/.ci/openvino-onnx/Dockerfile +++ b/.ci/openvino-onnx/Dockerfile @@ -59,7 +59,6 @@ RUN cmake .. \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DENABLE_INTEL_MYRIAD_COMMON=OFF \ -DENABLE_INTEL_GNA=OFF \ - -DENABLE_OPENCV=OFF \ -DENABLE_CPPLINT=OFF \ -DENABLE_NCC_STYLE=OFF \ -DENABLE_TESTS=OFF \ diff --git a/cmake/features.cmake b/cmake/features.cmake index 5f05d911cef..195df65eec1 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -126,7 +126,7 @@ ie_dependent_option (ENABLE_FUNCTIONAL_TESTS "functional tests" ON "ENABLE_TESTS ie_dependent_option (ENABLE_SAMPLES "console samples are part of inference engine package" ON "NOT MINGW" OFF) -ie_option (ENABLE_OPENCV "enables OpenCV" ON) +ie_option (ENABLE_OPENCV "enables OpenCV" OFF) ie_option (ENABLE_V7_SERIALIZE "enables serialization to IR v7" OFF) diff --git a/src/bindings/c/tests/CMakeLists.txt b/src/bindings/c/tests/CMakeLists.txt index 94bbe1f53b2..c5405505f1e 100644 --- a/src/bindings/c/tests/CMakeLists.txt +++ b/src/bindings/c/tests/CMakeLists.txt @@ -4,17 +4,9 @@ set(TARGET_NAME "InferenceEngineCAPITests") -# Find OpenCV components if exist -find_package(OpenCV COMPONENTS core imgproc imgcodecs QUIET) -if(NOT OpenCV_FOUND) - message(WARNING "OPENCV is disabled or not found, ${TARGET_NAME} is disabled") - return() -endif() - add_executable(${TARGET_NAME} ie_c_api_test.cpp test_model_repo.hpp) -target_link_libraries(${TARGET_NAME} PRIVATE openvino_c ${OpenCV_LIBRARIES} - commonTestUtils gtest_main) +target_link_libraries(${TARGET_NAME} PRIVATE openvino_c commonTestUtils gtest_main) target_compile_definitions(${TARGET_NAME} PRIVATE diff --git a/src/bindings/c/tests/ie_c_api_test.cpp b/src/bindings/c/tests/ie_c_api_test.cpp index b159589158a..be6dafad2c6 100644 --- a/src/bindings/c/tests/ie_c_api_test.cpp +++ b/src/bindings/c/tests/ie_c_api_test.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -15,12 +14,10 @@ std::string xml_std = TestDataHelpers::generate_model_path("test_model", "test_model_fp32.xml"), bin_std = TestDataHelpers::generate_model_path("test_model", "test_model_fp32.bin"), - input_image_std = TestDataHelpers::generate_image_path("224x224", "dog.bmp"), input_image_nv12_std = TestDataHelpers::generate_image_path("224x224", "dog6.yuv"); const char* xml = xml_std.c_str(); const char* bin = bin_std.c_str(); -const char* input_image = input_image_std.c_str(); const char* input_image_nv12 = input_image_nv12_std.c_str(); std::mutex m; @@ -58,29 +55,6 @@ size_t read_image_from_file(const char* img_path, unsigned char *img_data, size_ return read_size; } -void Mat2Blob(const cv::Mat& img, ie_blob_t *blob) -{ - dimensions_t dimenison; - IE_EXPECT_OK(ie_blob_get_dims(blob, &dimenison)); - size_t channels = dimenison.dims[1]; - size_t width = dimenison.dims[3]; - size_t height = dimenison.dims[2]; - ie_blob_buffer_t buffer; - IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer)); - uint8_t *blob_data = (uint8_t *)(buffer.buffer); - cv::Mat resized_image; - cv::resize(img, resized_image, cv::Size(width, height)); - - for (size_t c = 0; c < channels; c++) { - for (size_t h = 0; h < height; h++) { - for (size_t w = 0; w < width; w++) { - blob_data[c * width * height + h * width + w] = - resized_image.at(h, w)[c]; - } - } - } -} - size_t find_device(ie_available_devices_t avai_devices, const char *device_name) { for (size_t i = 0; i < avai_devices.num_devices; ++i) { if (strstr(avai_devices.devices[i], device_name)) @@ -363,7 +337,7 @@ TEST(ie_core_import_network_from_memory, importNetworkFromMem) { std::string export_path = TestDataHelpers::generate_model_path("test_model", "exported_model.blob"); IE_EXPECT_OK(ie_core_export_network(exe_network, export_path.c_str())); - std::vector buffer(content_from_file(export_path.c_str(), true)); + std::vector buffer(content_from_file(export_path.c_str(), true)); ie_executable_network_t *network = nullptr; IE_EXPECT_OK(ie_core_import_network_from_memory(core, buffer.data(), buffer.size(), "HETERO:CPU", nullptr, &network)); @@ -1189,9 +1163,14 @@ TEST(ie_infer_request_infer, infer) { ie_blob_t *blob = nullptr; IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob)); + dimensions_t dims; + IE_EXPECT_OK(ie_blob_get_dims(blob, &dims)); + const size_t blob_elems_count = dims.dims[0] * dims.dims[1] * dims.dims[2] * dims.dims[3]; - cv::Mat image = cv::imread(input_image); - Mat2Blob(image, blob); + ie_blob_buffer_t buffer; + IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer)); + auto* blob_internal_buffer = (uint8_t*)buffer.buffer; + std::fill(blob_internal_buffer, blob_internal_buffer + blob_elems_count, uint8_t{0}); IE_EXPECT_OK(ie_infer_request_infer(infer_request)); @@ -1202,9 +1181,9 @@ TEST(ie_infer_request_infer, infer) { EXPECT_EQ(dim_res.ranks, 2); EXPECT_EQ(dim_res.dims[1], 10); - ie_blob_buffer_t buffer; - IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer)); - float *output_data = (float *)(buffer.buffer); + ie_blob_buffer_t out_buffer; + IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &out_buffer)); + float *output_data = (float *)(out_buffer.buffer); EXPECT_NEAR(output_data[9], 0.f, 1.e-5); ie_blob_free(&output_blob); @@ -1239,9 +1218,14 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitFinish) { ie_blob_t *blob = nullptr; IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob)); + dimensions_t dims; + IE_EXPECT_OK(ie_blob_get_dims(blob, &dims)); + const size_t blob_elems_count = dims.dims[0] * dims.dims[1] * dims.dims[2] * dims.dims[3]; - cv::Mat image = cv::imread(input_image); - Mat2Blob(image, blob); + ie_blob_buffer_t buffer; + IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer)); + auto* blob_internal_buffer = (uint8_t*)buffer.buffer; + std::fill(blob_internal_buffer, blob_internal_buffer + blob_elems_count, uint8_t{0}); IE_EXPECT_OK(ie_infer_request_infer_async(infer_request)); @@ -1252,9 +1236,9 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitFinish) { IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob)); EXPECT_NE(nullptr, output_blob); - ie_blob_buffer_t buffer; - IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer)); - float *output_data = (float *)(buffer.buffer); + ie_blob_buffer_t out_buffer; + IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &out_buffer)); + float *output_data = (float *)(out_buffer.buffer); EXPECT_NEAR(output_data[9], 0.f, 1.e-5); } @@ -1291,9 +1275,14 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitTime) { IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob)); EXPECT_NE(nullptr, blob); + dimensions_t dims; + IE_EXPECT_OK(ie_blob_get_dims(blob, &dims)); + const size_t blob_elems_count = dims.dims[0] * dims.dims[1] * dims.dims[2] * dims.dims[3]; - cv::Mat image = cv::imread(input_image); - Mat2Blob(image, blob); + ie_blob_buffer_t buffer; + IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer)); + auto* blob_internal_buffer = (uint8_t*)buffer.buffer; + std::fill(blob_internal_buffer, blob_internal_buffer + blob_elems_count, uint8_t{0}); IE_EXPECT_OK(ie_infer_request_infer_async(infer_request)); @@ -1307,9 +1296,9 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitTime) { IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob)); - ie_blob_buffer_t buffer; - IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer)); - float *output_data = (float *)(buffer.buffer); + ie_blob_buffer_t out_buffer; + IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &out_buffer)); + float *output_data = (float *)(out_buffer.buffer); EXPECT_NEAR(output_data[9], 0.f, 1.e-5); } @@ -1654,8 +1643,14 @@ TEST(ie_infer_set_completion_callback, setCallback) { ie_blob_t *blob = nullptr; IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob)); - cv::Mat image = cv::imread(input_image); - Mat2Blob(image, blob); + dimensions_t dims; + IE_EXPECT_OK(ie_blob_get_dims(blob, &dims)); + const size_t blob_elems_count = dims.dims[0] * dims.dims[1] * dims.dims[2] * dims.dims[3]; + + ie_blob_buffer_t buffer; + IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer)); + auto* blob_internal_buffer = (uint8_t*)buffer.buffer; + std::fill(blob_internal_buffer, blob_internal_buffer + blob_elems_count, uint8_t{0}); ie_complete_call_back_t callback; callback.completeCallBackFunc = completion_callback; diff --git a/src/bindings/python/BUILDING.md b/src/bindings/python/BUILDING.md index ace71d1d311..368f3604990 100644 --- a/src/bindings/python/BUILDING.md +++ b/src/bindings/python/BUILDING.md @@ -45,7 +45,6 @@ set the mentioned flags to `ON`. Note the `CMAKE_INSTALL_PREFIX`, which defaults cmake .. \ -DENABLE_INTEL_GPU=OFF \ - -DENABLE_OPENCV=OFF \ -DENABLE_INTEL_MYRIAD_COMMON=OFF \ -DENABLE_PYTHON=ON \ -DENABLE_OV_ONNX_FRONTEND=ON \ @@ -108,7 +107,6 @@ cmake .. ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_INSTALL_PREFIX="%OPENVINO_BASEDIR%/openvino_dist" ^ -DENABLE_INTEL_GPU=OFF ^ - -DENABLE_OPENCV=OFF ^ -DENABLE_INTEL_MYRIAD_COMMON=OFF ^ -DENABLE_OV_ONNX_FRONTEND=ON ^ -DENABLE_PYTHON=ON ^