Skip to content

Commit 39aba80

Browse files
author
Tomasz Dołbniak
authored
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
1 parent c62251c commit 39aba80

File tree

11 files changed

+43
-62
lines changed

11 files changed

+43
-62
lines changed

.ci/azure/android_arm64.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ jobs:
110110
-DANDROID_ABI=$(ANDROID_ABI_CONFIG)
111111
-DANDROID_STL=c++_shared
112112
-DANDROID_PLATFORM=$(ANDROID_SDK_VERSION)
113-
-DENABLE_OPENCV=OFF
114113
-DENABLE_TESTS=ON
115114
-DENABLE_SAMPLES=ON
116115
-DENABLE_INTEL_MYRIAD=OFF

.ci/azure/linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ jobs:
157157
-DENABLE_FASTER_BUILD=ON
158158
-DENABLE_STRICT_DEPENDENCIES=OFF
159159
-DENABLE_REQUIREMENTS_INSTALL=OFF
160+
-DENABLE_OPENCV=ON
160161
-DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules
161162
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
162163
-DCMAKE_C_COMPILER_LAUNCHER=ccache

.ci/azure/linux_arm64.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ jobs:
127127
-GNinja
128128
-DVERBOSE_BUILD=ON
129129
-DOpenCV_DIR=$(INSTALL_OPENCV)/cmake
130-
-DENABLE_OPENCV=OFF
131130
-DPYTHON_INCLUDE_DIRS=$(INSTALL_PYTHON)/include/python3.8
132131
-DPYTHON_LIBRARY=$(INSTALL_PYTHON)/lib/libpython3.8.so
133132
-DENABLE_PYTHON=ON

.ci/azure/linux_onnxruntime.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ jobs:
9595
-DPYTHON_EXECUTABLE=/usr/bin/python3.8
9696
-DENABLE_INTEL_MYRIAD_COMMON=OFF
9797
-DENABLE_INTEL_GNA=OFF
98-
-DENABLE_OPENCV=OFF
9998
-DENABLE_CPPLINT=OFF
10099
-DENABLE_TESTS=OFF
101100
-DENABLE_INTEL_CPU=ON

.ci/azure/mac.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ jobs:
145145
set -e
146146
mkdir -p $(INSTALL_DIR)/opencv/
147147
cmake -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake
148-
cp -R $(REPO_DIR)/temp/opencv_4.5.2_osx/opencv/* $(INSTALL_DIR)/opencv/
149148
workingDirectory: $(BUILD_DIR)
150149
displayName: 'Install tests'
151150

.ci/azure/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ jobs:
169169
workingDirectory: $(BUILD_SAMPLES_TESTS_DIR)
170170
displayName: 'Install Samples Tests'
171171

172-
- 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
172+
- script: $(CMAKE_CMD) -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake
173173
workingDirectory: $(BUILD_DIR)
174174
displayName: 'Install tests'
175175

.ci/openvino-onnx/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ RUN cmake .. \
5959
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
6060
-DENABLE_INTEL_MYRIAD_COMMON=OFF \
6161
-DENABLE_INTEL_GNA=OFF \
62-
-DENABLE_OPENCV=OFF \
6362
-DENABLE_CPPLINT=OFF \
6463
-DENABLE_NCC_STYLE=OFF \
6564
-DENABLE_TESTS=OFF \

cmake/features.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ ie_dependent_option (ENABLE_FUNCTIONAL_TESTS "functional tests" ON "ENABLE_TESTS
126126

127127
ie_dependent_option (ENABLE_SAMPLES "console samples are part of inference engine package" ON "NOT MINGW" OFF)
128128

129-
ie_option (ENABLE_OPENCV "enables OpenCV" ON)
129+
ie_option (ENABLE_OPENCV "enables OpenCV" OFF)
130130

131131
ie_option (ENABLE_V7_SERIALIZE "enables serialization to IR v7" OFF)
132132

src/bindings/c/tests/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44

55
set(TARGET_NAME "InferenceEngineCAPITests")
66

7-
# Find OpenCV components if exist
8-
find_package(OpenCV COMPONENTS core imgproc imgcodecs QUIET)
9-
if(NOT OpenCV_FOUND)
10-
message(WARNING "OPENCV is disabled or not found, ${TARGET_NAME} is disabled")
11-
return()
12-
endif()
13-
147
add_executable(${TARGET_NAME} ie_c_api_test.cpp test_model_repo.hpp)
158

16-
target_link_libraries(${TARGET_NAME} PRIVATE openvino_c ${OpenCV_LIBRARIES}
17-
commonTestUtils gtest_main)
9+
target_link_libraries(${TARGET_NAME} PRIVATE openvino_c commonTestUtils gtest_main)
1810

1911
target_compile_definitions(${TARGET_NAME}
2012
PRIVATE

src/bindings/c/tests/ie_c_api_test.cpp

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <gtest/gtest.h>
66
#include <stdio.h>
77
#include <stdlib.h>
8-
#include <opencv2/opencv.hpp>
98
#include <condition_variable>
109
#include <mutex>
1110
#include <c_api/ie_c_api.h>
@@ -15,12 +14,10 @@
1514

1615
std::string xml_std = TestDataHelpers::generate_model_path("test_model", "test_model_fp32.xml"),
1716
bin_std = TestDataHelpers::generate_model_path("test_model", "test_model_fp32.bin"),
18-
input_image_std = TestDataHelpers::generate_image_path("224x224", "dog.bmp"),
1917
input_image_nv12_std = TestDataHelpers::generate_image_path("224x224", "dog6.yuv");
2018

2119
const char* xml = xml_std.c_str();
2220
const char* bin = bin_std.c_str();
23-
const char* input_image = input_image_std.c_str();
2421
const char* input_image_nv12 = input_image_nv12_std.c_str();
2522

2623
std::mutex m;
@@ -58,29 +55,6 @@ size_t read_image_from_file(const char* img_path, unsigned char *img_data, size_
5855
return read_size;
5956
}
6057

61-
void Mat2Blob(const cv::Mat& img, ie_blob_t *blob)
62-
{
63-
dimensions_t dimenison;
64-
IE_EXPECT_OK(ie_blob_get_dims(blob, &dimenison));
65-
size_t channels = dimenison.dims[1];
66-
size_t width = dimenison.dims[3];
67-
size_t height = dimenison.dims[2];
68-
ie_blob_buffer_t buffer;
69-
IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer));
70-
uint8_t *blob_data = (uint8_t *)(buffer.buffer);
71-
cv::Mat resized_image;
72-
cv::resize(img, resized_image, cv::Size(width, height));
73-
74-
for (size_t c = 0; c < channels; c++) {
75-
for (size_t h = 0; h < height; h++) {
76-
for (size_t w = 0; w < width; w++) {
77-
blob_data[c * width * height + h * width + w] =
78-
resized_image.at<cv::Vec3b>(h, w)[c];
79-
}
80-
}
81-
}
82-
}
83-
8458
size_t find_device(ie_available_devices_t avai_devices, const char *device_name) {
8559
for (size_t i = 0; i < avai_devices.num_devices; ++i) {
8660
if (strstr(avai_devices.devices[i], device_name))
@@ -363,7 +337,7 @@ TEST(ie_core_import_network_from_memory, importNetworkFromMem) {
363337
std::string export_path = TestDataHelpers::generate_model_path("test_model", "exported_model.blob");
364338
IE_EXPECT_OK(ie_core_export_network(exe_network, export_path.c_str()));
365339

366-
std::vector<uchar> buffer(content_from_file(export_path.c_str(), true));
340+
std::vector<uint8_t> buffer(content_from_file(export_path.c_str(), true));
367341
ie_executable_network_t *network = nullptr;
368342

369343
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) {
11891163
ie_blob_t *blob = nullptr;
11901164
IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob));
11911165

1166+
dimensions_t dims;
1167+
IE_EXPECT_OK(ie_blob_get_dims(blob, &dims));
1168+
const size_t blob_elems_count = dims.dims[0] * dims.dims[1] * dims.dims[2] * dims.dims[3];
11921169

1193-
cv::Mat image = cv::imread(input_image);
1194-
Mat2Blob(image, blob);
1170+
ie_blob_buffer_t buffer;
1171+
IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer));
1172+
auto* blob_internal_buffer = (uint8_t*)buffer.buffer;
1173+
std::fill(blob_internal_buffer, blob_internal_buffer + blob_elems_count, uint8_t{0});
11951174

11961175
IE_EXPECT_OK(ie_infer_request_infer(infer_request));
11971176

@@ -1202,9 +1181,9 @@ TEST(ie_infer_request_infer, infer) {
12021181
EXPECT_EQ(dim_res.ranks, 2);
12031182
EXPECT_EQ(dim_res.dims[1], 10);
12041183

1205-
ie_blob_buffer_t buffer;
1206-
IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer));
1207-
float *output_data = (float *)(buffer.buffer);
1184+
ie_blob_buffer_t out_buffer;
1185+
IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &out_buffer));
1186+
float *output_data = (float *)(out_buffer.buffer);
12081187
EXPECT_NEAR(output_data[9], 0.f, 1.e-5);
12091188

12101189
ie_blob_free(&output_blob);
@@ -1239,9 +1218,14 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitFinish) {
12391218
ie_blob_t *blob = nullptr;
12401219
IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob));
12411220

1221+
dimensions_t dims;
1222+
IE_EXPECT_OK(ie_blob_get_dims(blob, &dims));
1223+
const size_t blob_elems_count = dims.dims[0] * dims.dims[1] * dims.dims[2] * dims.dims[3];
12421224

1243-
cv::Mat image = cv::imread(input_image);
1244-
Mat2Blob(image, blob);
1225+
ie_blob_buffer_t buffer;
1226+
IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer));
1227+
auto* blob_internal_buffer = (uint8_t*)buffer.buffer;
1228+
std::fill(blob_internal_buffer, blob_internal_buffer + blob_elems_count, uint8_t{0});
12451229

12461230
IE_EXPECT_OK(ie_infer_request_infer_async(infer_request));
12471231

@@ -1252,9 +1236,9 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitFinish) {
12521236
IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob));
12531237
EXPECT_NE(nullptr, output_blob);
12541238

1255-
ie_blob_buffer_t buffer;
1256-
IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer));
1257-
float *output_data = (float *)(buffer.buffer);
1239+
ie_blob_buffer_t out_buffer;
1240+
IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &out_buffer));
1241+
float *output_data = (float *)(out_buffer.buffer);
12581242
EXPECT_NEAR(output_data[9], 0.f, 1.e-5);
12591243
}
12601244

@@ -1291,9 +1275,14 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitTime) {
12911275
IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob));
12921276
EXPECT_NE(nullptr, blob);
12931277

1278+
dimensions_t dims;
1279+
IE_EXPECT_OK(ie_blob_get_dims(blob, &dims));
1280+
const size_t blob_elems_count = dims.dims[0] * dims.dims[1] * dims.dims[2] * dims.dims[3];
12941281

1295-
cv::Mat image = cv::imread(input_image);
1296-
Mat2Blob(image, blob);
1282+
ie_blob_buffer_t buffer;
1283+
IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer));
1284+
auto* blob_internal_buffer = (uint8_t*)buffer.buffer;
1285+
std::fill(blob_internal_buffer, blob_internal_buffer + blob_elems_count, uint8_t{0});
12971286

12981287
IE_EXPECT_OK(ie_infer_request_infer_async(infer_request));
12991288

@@ -1307,9 +1296,9 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitTime) {
13071296

13081297
IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob));
13091298

1310-
ie_blob_buffer_t buffer;
1311-
IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer));
1312-
float *output_data = (float *)(buffer.buffer);
1299+
ie_blob_buffer_t out_buffer;
1300+
IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &out_buffer));
1301+
float *output_data = (float *)(out_buffer.buffer);
13131302
EXPECT_NEAR(output_data[9], 0.f, 1.e-5);
13141303
}
13151304

@@ -1654,8 +1643,14 @@ TEST(ie_infer_set_completion_callback, setCallback) {
16541643
ie_blob_t *blob = nullptr;
16551644
IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob));
16561645

1657-
cv::Mat image = cv::imread(input_image);
1658-
Mat2Blob(image, blob);
1646+
dimensions_t dims;
1647+
IE_EXPECT_OK(ie_blob_get_dims(blob, &dims));
1648+
const size_t blob_elems_count = dims.dims[0] * dims.dims[1] * dims.dims[2] * dims.dims[3];
1649+
1650+
ie_blob_buffer_t buffer;
1651+
IE_EXPECT_OK(ie_blob_get_buffer(blob, &buffer));
1652+
auto* blob_internal_buffer = (uint8_t*)buffer.buffer;
1653+
std::fill(blob_internal_buffer, blob_internal_buffer + blob_elems_count, uint8_t{0});
16591654

16601655
ie_complete_call_back_t callback;
16611656
callback.completeCallBackFunc = completion_callback;

0 commit comments

Comments
 (0)