diff --git a/recipes/opencv/4.x/conandata.yml b/recipes/opencv/4.x/conandata.yml index 867bde99de61c5..3ae70746357fab 100644 --- a/recipes/opencv/4.x/conandata.yml +++ b/recipes/opencv/4.x/conandata.yml @@ -46,6 +46,10 @@ patches: patch_description: "MinGW: disable obsensor to avoid build issue" patch_type: "portability" patch_source: "https://github.com/opencv/opencv/pull/24478" + - patch_file: "patches/4.8.1-0003-openvino-cmake-fix.patch" + patch_description: "Fixed issue with OpenVINO and static build" + patch_type: "portability" + patch_source: "https://github.com/opencv/opencv/pull/23963" "4.5.5": - patch_file: "patches/4.5.5-0001-find-openexr.patch" patch_description: "Robust discovery & injection of OpenEXR" diff --git a/recipes/opencv/4.x/conanfile.py b/recipes/opencv/4.x/conanfile.py index 31a4382eaa7289..274534c1d0869c 100644 --- a/recipes/opencv/4.x/conanfile.py +++ b/recipes/opencv/4.x/conanfile.py @@ -122,6 +122,7 @@ class OpenCVConan(ConanFile): "with_flatbuffers": [True, False], "with_protobuf": [True, False], "with_vulkan": [True, False], + "with_openvino": [True, False], "dnn_cuda": [True, False], # highgui module options "with_gtk": [True, False], @@ -181,6 +182,7 @@ class OpenCVConan(ConanFile): "with_flatbuffers": True, "with_protobuf": True, "with_vulkan": False, + "with_openvino": False, "dnn_cuda": False, # highgui module options "with_gtk": False, @@ -276,6 +278,10 @@ def _has_wechat_qrcode_option(self): def _has_barcode_option(self): return Version(self.version) >= "4.5.3" and Version(self.version) < "4.8.0" + @property + def _has_openvino_option(self): + return Version(self.version) >= "4.6.0" + @property def _has_with_wayland_option(self): return Version(self.version) >= "4.7.0" and self.settings.os in ["Linux", "FreeBSD"] @@ -422,6 +428,9 @@ def wayland(): def xkbcommon(): return ["xkbcommon::libxkbcommon"] if self.options.get_safe("with_wayland") else [] + def openvino(): + return ["openvino::Runtime"] if self.options.get_safe("with_openvino") else [] + def opencv_calib3d(): return ["opencv_calib3d"] if self.options.calib3d else [] @@ -496,7 +505,7 @@ def opencv_xfeatures2d(): "dnn": { "is_built": self.options.dnn, "mandatory_options": ["imgproc"], - "requires": ["opencv_core", "opencv_imgproc"] + protobuf() + vulkan() + ipp(), + "requires": ["opencv_core", "opencv_imgproc"] + protobuf() + vulkan() + ipp() + openvino(), }, "features2d": { "is_built": self.options.features2d, @@ -1030,11 +1039,15 @@ def configure(self): # Call this first before any further manipulation of options based on other options self._solve_internal_dependency_graph(self._opencv_modules) + if not self._has_openvino_option: + self.options.rm_safe("with_openvino") + if not self.options.dnn: self.options.rm_safe("dnn_cuda") self.options.rm_safe("with_flatbuffers") self.options.rm_safe("with_protobuf") self.options.rm_safe("with_vulkan") + self.options.rm_safe("with_openvino") if not self.options.highgui: self.options.rm_safe("with_gtk") self.options.rm_safe("with_wayland") @@ -1094,6 +1107,8 @@ def requirements(self): self.requires("protobuf/3.21.12", transitive_libs=True) if self.options.get_safe("with_vulkan"): self.requires("vulkan-headers/1.3.268.0") + if self.options.get_safe("with_openvino"): + self.requires("openvino/2023.2.0") # gapi module dependencies if self.options.gapi: self.requires("ade/0.1.2d") @@ -1475,8 +1490,10 @@ def generate(self): tc.variables["OPENCV_DNN_CUDA"] = self.options.get_safe("dnn_cuda", False) + if self._has_openvino_option: + tc.variables["WITH_OPENVINO"] = self.options.get_safe("with_openvino", False) + if Version(self.version) >= "4.6.0": - tc.variables["WITH_OPENVINO"] = False tc.variables["WITH_TIMVX"] = False else: tc.variables["WITH_INF_ENGINE"] = False diff --git a/recipes/opencv/4.x/patches/4.8.1-0003-openvino-cmake-fix.patch b/recipes/opencv/4.x/patches/4.8.1-0003-openvino-cmake-fix.patch new file mode 100644 index 00000000000000..01a2aadd048401 --- /dev/null +++ b/recipes/opencv/4.x/patches/4.8.1-0003-openvino-cmake-fix.patch @@ -0,0 +1,23 @@ +--- 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()