Skip to content

Commit 52219a8

Browse files
authored
Enable linking against OV python package (#249)
* Enable linking against OV python package * Update json dep version to avoid cmake deprecated warnings * Update OV package ver in win builder
1 parent 3aa9be3 commit 52219a8

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

.github/workflows/test_precommit.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
source venv/Scripts/activate
9898
python -m pip install --upgrade pip
9999
pip install model_api/python/[tests] --extra-index-url https://download.pytorch.org/whl/cpu
100-
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/2024.1/windows/w_openvino_toolkit_windows_2024.1.0.15008.f4afc983258_x86_64.zip --output w_openvino_toolkit_windows.zip
100+
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/2024.6/windows/w_openvino_toolkit_windows_2024.6.0.17404.4c0f47d2335_x86_64.zip --output w_openvino_toolkit_windows.zip
101101
unzip w_openvino_toolkit_windows.zip
102102
rm w_openvino_toolkit_windows.zip
103103
curl -L https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-windows.exe --output opencv-4.10.0-windows.exe
@@ -112,13 +112,13 @@ jobs:
112112
shell: bash
113113
run: |
114114
mkdir build && cd build
115-
MSYS_NO_PATHCONV=1 cmake ../examples/cpp/ -DOpenVINO_DIR=$GITHUB_WORKSPACE/w_openvino_toolkit_windows_2024.1.0.15008.f4afc983258_x86_64/runtime/cmake -DOpenCV_DIR=$GITHUB_WORKSPACE/opencv/opencv/build -DCMAKE_CXX_FLAGS=/WX
115+
MSYS_NO_PATHCONV=1 cmake ../examples/cpp/ -DOpenVINO_DIR=$GITHUB_WORKSPACE/w_openvino_toolkit_windows_2024.6.0.17404.4c0f47d2335_x86_64/runtime/cmake -DOpenCV_DIR=$GITHUB_WORKSPACE/opencv/opencv/build -DCMAKE_CXX_FLAGS=/WX
116116
cmake --build . --config Release -j $((`nproc`*2+2))
117117
- name: Run sync sample
118118
shell: cmd
119119
# .\w_openvino_toolkit_windows_2023.0.0.10926.b4452d56304_x86_64\setupvars.bat exits with 0 code without moving to a next command. Set PATH manually
120120
run: |
121-
set PATH=opencv\opencv\build\x64\vc16\bin;w_openvino_toolkit_windows_2024.1.0.15008.f4afc983258_x86_64\runtime\bin\intel64\Release;w_openvino_toolkit_windows_2024.1.0.15008.f4afc983258_x86_64\runtime\3rdparty\tbb\bin;%PATH%
121+
set PATH=opencv\opencv\build\x64\vc16\bin;w_openvino_toolkit_windows_2024.6.0.17404.4c0f47d2335_x86_64\runtime\bin\intel64\Release;w_openvino_toolkit_windows_2024.6.0.17404.4c0f47d2335_x86_64\runtime\3rdparty\tbb\bin;%PATH%
122122
.\build\Release\synchronous_api.exe .\data\public\ssd_mobilenet_v1_fpn_coco\FP16\ssd_mobilenet_v1_fpn_coco.xml .\data\BloodImage_00007.jpg
123123
serving_api:
124124
strategy:

model_api/cpp/CMakeLists.txt

+22-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ if(NOT GENERATOR_IS_MULTI_CONFIG_VAR AND NOT DEFINED CMAKE_BUILD_TYPE)
1313
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ...")
1414
endif()
1515

16-
project(model_api)
16+
set(model_api_VERSION 0.0.0)
17+
18+
project(model_api
19+
VERSION ${model_api_VERSION}
20+
DESCRIPTION "OpenVINO Vision API"
21+
HOMEPAGE_URL "https://github.com/openvinotoolkit/model_api/"
22+
LANGUAGES CXX C)
1723

1824
if(WIN32)
1925
if(NOT "${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
@@ -23,13 +29,24 @@ if(WIN32)
2329
add_definitions(-DNOMINMAX)
2430
endif()
2531

26-
set(model_api_VERSION 0.0.0)
27-
2832
find_package(OpenCV REQUIRED COMPONENTS core imgproc)
29-
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
33+
34+
# Looking for OpenVINO in the python distribution. It doesn't work for cross-compiling build
35+
if(NOT CMAKE_CROSSCOMPILING)
36+
find_package(Python3 REQUIRED)
37+
execute_process(
38+
COMMAND ${Python3_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
39+
OUTPUT_VARIABLE OpenVINO_DIR_PY
40+
ERROR_QUIET
41+
)
42+
endif()
43+
44+
find_package(OpenVINO REQUIRED
45+
COMPONENTS Runtime Threading
46+
HINTS "${OpenVINO_DIR_PY}")
3047

3148
include(FetchContent)
32-
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz)
49+
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
3350
FetchContent_MakeAvailable(json)
3451

3552
file(GLOB MODELS_SOURCES ./models/src/*.cpp)

0 commit comments

Comments
 (0)