From 1c00eae503c78c308f1d1a412d5530eea5d18a31 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 28 Oct 2023 05:10:15 +0400 Subject: [PATCH] [opencv] added openvino support (#34727) * opencv: added openvino support * updated version database --- ports/opencv4/0021-static-openvino.patch | 25 ++++++++++++++++++++++++ ports/opencv4/portfile.cmake | 9 +++++++++ ports/opencv4/vcpkg.json | 6 +++++- versions/baseline.json | 2 +- versions/o-/opencv4.json | 5 +++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 ports/opencv4/0021-static-openvino.patch diff --git a/ports/opencv4/0021-static-openvino.patch b/ports/opencv4/0021-static-openvino.patch new file mode 100644 index 0000000000..156aca2bcc --- /dev/null +++ b/ports/opencv4/0021-static-openvino.patch @@ -0,0 +1,25 @@ +diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake +index 437042958e..a90eb5a5ab 100644 +--- a/cmake/OpenCVUtils.cmake ++++ b/cmake/OpenCVUtils.cmake +@@ -1632,13 +1632,19 @@ function(ocv_add_external_target name inc link def) + endif() + endfunction() + ++set(__OPENCV_EXPORTED_EXTERNAL_TARGETS "" CACHE INTERNAL "") + function(ocv_install_used_external_targets) + if(NOT BUILD_SHARED_LIBS + AND NOT (CMAKE_VERSION VERSION_LESS "3.13.0") # upgrade CMake: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2152 + ) + foreach(tgt in ${ARGN}) + if(tgt MATCHES "^ocv\.3rdparty\.") +- install(TARGETS ${tgt} EXPORT OpenCVModules) ++ list(FIND __OPENCV_EXPORTED_EXTERNAL_TARGETS "${tgt}" _found) ++ if(_found EQUAL -1) # don't export target twice ++ install(TARGETS ${tgt} EXPORT OpenCVModules) ++ list(APPEND __OPENCV_EXPORTED_EXTERNAL_TARGETS "${tgt}") ++ set(__OPENCV_EXPORTED_EXTERNAL_TARGETS "${__OPENCV_EXPORTED_EXTERNAL_TARGETS}" CACHE INTERNAL "") ++ endif() + endif() + endforeach() + endif() diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index d783f99fea..c7b20c6664 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -29,6 +29,7 @@ vcpkg_from_github( 0017-fix-flatbuffers.patch 0019-missing-include.patch 0020-fix-compat-cuda12.2.patch + 0021-static-openvino.patch # https://github.com/opencv/opencv/pull/23963 "${ARM64_WINDOWS_FIX}" ) # Disallow accidental build of vendored copies @@ -85,9 +86,13 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS # Cannot use vcpkg_check_features() for "dnn", "gtk", ipp", "openmp", "ovis", "python", "qt", "tbb" set(BUILD_opencv_dnn OFF) +set(WITH_OPENVINO OFF) if("dnn" IN_LIST FEATURES) if(NOT VCPKG_TARGET_IS_ANDROID) set(BUILD_opencv_dnn ON) + if(NOT VCPKG_TARGET_IS_UWP) + set(WITH_OPENVINO ON) + endif() else() message(WARNING "The dnn module cannot be enabled on Android") endif() @@ -446,6 +451,7 @@ vcpkg_cmake_configure( -DWITH_PROTOBUF=${BUILD_opencv_dnn} -DWITH_PYTHON=${WITH_PYTHON} -DWITH_OPENCLAMDBLAS=OFF + -DWITH_OPENVINO=${WITH_OPENVINO} -DWITH_TBB=${WITH_TBB} -DWITH_OPENJPEG=OFF -DWITH_CPUFEATURES=OFF @@ -526,6 +532,9 @@ find_dependency(Tesseract)") if("lapack" IN_LIST FEATURES) string(APPEND DEPS_STRING "\nfind_dependency(LAPACK)") endif() + if(WITH_OPENVINO) + string(APPEND DEPS_STRING "\nfind_dependency(OpenVINO CONFIG)") + endif() if("openexr" IN_LIST FEATURES) string(APPEND DEPS_STRING "\nfind_dependency(OpenEXR CONFIG)") endif() diff --git a/ports/opencv4/vcpkg.json b/ports/opencv4/vcpkg.json index 28ceb72bba..858221b401 100644 --- a/ports/opencv4/vcpkg.json +++ b/ports/opencv4/vcpkg.json @@ -1,7 +1,7 @@ { "name": "opencv4", "version": "4.8.0", - "port-version": 7, + "port-version": 8, "description": "computer vision library", "homepage": "https://github.com/opencv/opencv", "license": "Apache-2.0", @@ -109,6 +109,10 @@ "host": true, "default-features": false }, + { + "name": "openvino", + "platform": "!uwp" + }, "protobuf" ] }, diff --git a/versions/baseline.json b/versions/baseline.json index 1c9848874a..482a85d671 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6150,7 +6150,7 @@ }, "opencv4": { "baseline": "4.8.0", - "port-version": 7 + "port-version": 8 }, "opendnp3": { "baseline": "3.1.1", diff --git a/versions/o-/opencv4.json b/versions/o-/opencv4.json index 8d1ade83c4..a7aa4d6348 100644 --- a/versions/o-/opencv4.json +++ b/versions/o-/opencv4.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "48c97b54fceaef9a96d374693f47e3ea91383f3c", + "version": "4.8.0", + "port-version": 8 + }, { "git-tree": "ef78c1958b122045e9d1e353150049431b3162fa", "version": "4.8.0",