Skip to content

Commit

Permalink
OpenCV build switched off by default [2022/1.1] (#12358)
Browse files Browse the repository at this point in the history
* OCV build off by default

* OCV on in the Linux Azure pipeline

* Copy of OCV in the linux pipeline
  • Loading branch information
Tomasz Dołbniak authored Aug 2, 2022
1 parent c62251c commit 39aba80
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 62 deletions.
1 change: 0 additions & 1 deletion .ci/azure/android_arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .ci/azure/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .ci/azure/linux_arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .ci/azure/linux_onnxruntime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .ci/azure/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion .ci/azure/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
1 change: 0 additions & 1 deletion .ci/openvino-onnx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion cmake/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 1 addition & 9 deletions src/bindings/c/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
83 changes: 39 additions & 44 deletions src/bindings/c/tests/ie_c_api_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <gtest/gtest.h>
#include <stdio.h>
#include <stdlib.h>
#include <opencv2/opencv.hpp>
#include <condition_variable>
#include <mutex>
#include <c_api/ie_c_api.h>
Expand All @@ -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;
Expand Down Expand Up @@ -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<cv::Vec3b>(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))
Expand Down Expand Up @@ -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<uchar> buffer(content_from_file(export_path.c_str(), true));
std::vector<uint8_t> 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));
Expand Down Expand Up @@ -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));

Expand All @@ -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);
Expand Down Expand Up @@ -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));

Expand All @@ -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);
}

Expand Down Expand Up @@ -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));

Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/bindings/python/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 ^
Expand Down

0 comments on commit 39aba80

Please sign in to comment.