Skip to content

Commit 3215db2

Browse files
committed
Merge pull request opencv#21591 from alalek:dnn_drop_legacy_ie
2 parents fc28ba3 + effce05 commit 3215db2

35 files changed

+206
-2787
lines changed

cmake/OpenCVDetectInferenceEngine.cmake

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -23,80 +23,6 @@ endif()
2323

2424
# ======================
2525

26-
macro(ocv_ie_find_extra_libraries find_prefix find_suffix)
27-
file(GLOB libraries "${INF_ENGINE_LIB_DIRS}/${find_prefix}inference_engine*${find_suffix}")
28-
foreach(full_path IN LISTS libraries)
29-
get_filename_component(library "${full_path}" NAME_WE)
30-
string(REPLACE "${find_prefix}" "" library "${library}")
31-
if(library STREQUAL "inference_engine" OR library STREQUAL "inference_engined")
32-
# skip
33-
else()
34-
add_library(${library} UNKNOWN IMPORTED)
35-
set_target_properties(${library} PROPERTIES
36-
IMPORTED_LOCATION "${full_path}")
37-
list(APPEND custom_libraries ${library})
38-
endif()
39-
endforeach()
40-
endmacro()
41-
42-
function(add_custom_ie_build _inc _lib _lib_rel _lib_dbg _msg)
43-
if(NOT _inc OR NOT (_lib OR _lib_rel OR _lib_dbg))
44-
return()
45-
endif()
46-
if(NOT _lib)
47-
if(_lib_rel)
48-
set(_lib "${_lib_rel}")
49-
else()
50-
set(_lib "${_lib_dbg}")
51-
endif()
52-
endif()
53-
add_library(inference_engine UNKNOWN IMPORTED)
54-
set_target_properties(inference_engine PROPERTIES
55-
IMPORTED_LOCATION "${_lib}"
56-
IMPORTED_IMPLIB_RELEASE "${_lib_rel}"
57-
IMPORTED_IMPLIB_DEBUG "${_lib_dbg}"
58-
INTERFACE_INCLUDE_DIRECTORIES "${_inc}"
59-
)
60-
61-
set(custom_libraries "")
62-
set(__prefixes "${CMAKE_FIND_LIBRARY_PREFIXES}")
63-
if(NOT __prefixes)
64-
set(__prefixes "_empty_")
65-
endif()
66-
foreach(find_prefix ${__prefixes})
67-
if(find_prefix STREQUAL "_empty_") # foreach doesn't iterate over empty elements
68-
set(find_prefix "")
69-
endif()
70-
if(NOT DEFINED INFERENCE_ENGINE_FIND_LIBRARY_SUFFIXES) # allow custom override
71-
set(INFERENCE_ENGINE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
72-
if(APPLE)
73-
ocv_list_filterout(INFERENCE_ENGINE_FIND_LIBRARY_SUFFIXES "^.so$") # skip plugins (can't be linked)
74-
endif()
75-
endif()
76-
foreach(find_suffix ${INFERENCE_ENGINE_FIND_LIBRARY_SUFFIXES})
77-
ocv_ie_find_extra_libraries("${find_prefix}" "${find_suffix}")
78-
endforeach()
79-
if(NOT CMAKE_FIND_LIBRARY_SUFFIXES)
80-
ocv_ie_find_extra_libraries("${find_prefix}" "")
81-
endif()
82-
endforeach()
83-
84-
if(NOT INF_ENGINE_RELEASE VERSION_GREATER "2018050000")
85-
find_library(INF_ENGINE_OMP_LIBRARY iomp5 PATHS "${INF_ENGINE_OMP_DIR}" NO_DEFAULT_PATH)
86-
if(NOT INF_ENGINE_OMP_LIBRARY)
87-
message(WARNING "OpenMP for IE have not been found. Set INF_ENGINE_OMP_DIR variable if you experience build errors.")
88-
endif()
89-
endif()
90-
if(EXISTS "${INF_ENGINE_OMP_LIBRARY}")
91-
set_target_properties(inference_engine PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${INF_ENGINE_OMP_LIBRARY}")
92-
endif()
93-
set(INF_ENGINE_VERSION "Unknown" CACHE STRING "")
94-
set(INF_ENGINE_TARGET "inference_engine;${custom_libraries}" PARENT_SCOPE)
95-
message(STATUS "Detected InferenceEngine: ${_msg}")
96-
endfunction()
97-
98-
# ======================
99-
10026
find_package(InferenceEngine QUIET)
10127
if(InferenceEngine_FOUND)
10228
set(INF_ENGINE_TARGET ${InferenceEngine_LIBRARIES})
@@ -118,38 +44,6 @@ elseif(DEFINED INF_ENGINE_RELEASE)
11844
endif()
11945
set(INF_ENGINE_RELEASE "${INF_ENGINE_RELEASE_INIT}" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
12046

121-
if(NOT INF_ENGINE_TARGET AND INF_ENGINE_LIB_DIRS AND INF_ENGINE_INCLUDE_DIRS)
122-
find_path(ie_custom_inc "inference_engine.hpp" PATHS "${INF_ENGINE_INCLUDE_DIRS}" NO_DEFAULT_PATH)
123-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
124-
find_library(ie_custom_lib_dbg "inference_engined" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH) # Win32 and MacOSX
125-
endif()
126-
find_library(ie_custom_lib "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH)
127-
find_library(ie_custom_lib_rel "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Release" NO_DEFAULT_PATH)
128-
find_library(ie_custom_lib_dbg "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Debug" NO_DEFAULT_PATH)
129-
add_custom_ie_build("${ie_custom_inc}" "${ie_custom_lib}" "${ie_custom_lib_rel}" "${ie_custom_lib_dbg}" "INF_ENGINE_{INCLUDE,LIB}_DIRS")
130-
endif()
131-
132-
set(_loc "$ENV{INTEL_OPENVINO_DIR}")
133-
if(NOT _loc AND DEFINED ENV{INTEL_CVSDK_DIR})
134-
set(_loc "$ENV{INTEL_CVSDK_DIR}") # OpenVINO 2018.x
135-
endif()
136-
if(NOT INF_ENGINE_TARGET AND _loc)
137-
if(NOT INF_ENGINE_RELEASE VERSION_GREATER "2018050000")
138-
set(INF_ENGINE_PLATFORM_DEFAULT "ubuntu_16.04")
139-
else()
140-
set(INF_ENGINE_PLATFORM_DEFAULT "")
141-
endif()
142-
set(INF_ENGINE_PLATFORM "${INF_ENGINE_PLATFORM_DEFAULT}" CACHE STRING "InferenceEngine platform (library dir)")
143-
find_path(ie_custom_env_inc "inference_engine.hpp" PATHS "${_loc}/deployment_tools/inference_engine/include" NO_DEFAULT_PATH)
144-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
145-
find_library(ie_custom_env_lib_dbg "inference_engined" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
146-
endif()
147-
find_library(ie_custom_env_lib "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
148-
find_library(ie_custom_env_lib_rel "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Release" NO_DEFAULT_PATH)
149-
find_library(ie_custom_env_lib_dbg "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Debug" NO_DEFAULT_PATH)
150-
add_custom_ie_build("${ie_custom_env_inc}" "${ie_custom_env_lib}" "${ie_custom_env_lib_rel}" "${ie_custom_env_lib_dbg}" "OpenVINO (${_loc})")
151-
endif()
152-
15347
set(tgts)
15448
set(defs)
15549

modules/dnn/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
115115
endif()
116116

117117
set(dnn_runtime_libs "")
118-
if(TARGET ocv.3rdparty.openvino)
118+
119+
ocv_option(OPENCV_DNN_OPENVINO "Build with OpenVINO support (2021.4+)" (TARGET ocv.3rdparty.openvino))
120+
if(TARGET ocv.3rdparty.openvino AND OPENCV_DNN_OPENVINO)
121+
if(NOT HAVE_OPENVINO AND NOT HAVE_NGRAPH)
122+
message(FATAL_ERROR "DNN: Inference Engine is not supported without enabled 'nGraph'. Check build configuration.")
123+
endif()
119124
list(APPEND dnn_runtime_libs ocv.3rdparty.openvino)
120125
endif()
121126

modules/dnn/include/opencv2/dnn/dnn.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
284284
*/
285285
virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs);
286286

287-
virtual Ptr<BackendNode> initInfEngine(const std::vector<Ptr<BackendWrapper> > &inputs);
288-
289287
virtual Ptr<BackendNode> initNgraph(const std::vector<Ptr<BackendWrapper> > &inputs, const std::vector<Ptr<BackendNode> >& nodes);
290288

291289
/**

modules/dnn/include/opencv2/dnn/utils/inference_engine.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
1515

1616

1717
/* Values for 'OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE' parameter */
18+
/// @deprecated
1819
#define CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API "NN_BUILDER"
20+
/// @deprecated
1921
#define CV_DNN_BACKEND_INFERENCE_ENGINE_NGRAPH "NGRAPH"
2022

2123
/** @brief Returns Inference Engine internal backend API.
2224
*
2325
* See values of `CV_DNN_BACKEND_INFERENCE_ENGINE_*` macros.
2426
*
25-
* Default value is controlled through `OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE` runtime parameter (environment variable).
27+
* `OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE` runtime parameter (environment variable) is ignored since 4.6.0.
28+
*
29+
* @deprecated
2630
*/
2731
CV_EXPORTS_W cv::String getInferenceEngineBackendType();
2832

@@ -31,6 +35,8 @@ CV_EXPORTS_W cv::String getInferenceEngineBackendType();
3135
* See values of `CV_DNN_BACKEND_INFERENCE_ENGINE_*` macros.
3236
*
3337
* @returns previous value of internal backend API
38+
*
39+
* @deprecated
3440
*/
3541
CV_EXPORTS_W cv::String setInferenceEngineBackendType(const cv::String& newBackendType);
3642

0 commit comments

Comments
 (0)