diff --git a/tools/realsense-viewer/CMakeLists.txt b/tools/realsense-viewer/CMakeLists.txt index fdd41a5076..e9ebeaf391 100644 --- a/tools/realsense-viewer/CMakeLists.txt +++ b/tools/realsense-viewer/CMakeLists.txt @@ -82,6 +82,9 @@ if(DEFINED OpenCV_DIR AND IS_DIRECTORY ${OpenCV_DIR}) ) endif() + +include(../../wrappers/openvino/check_vino_version.cmake) + if(DEFINED INTEL_OPENVINO_DIR AND IS_DIRECTORY ${INTEL_OPENVINO_DIR}) message( STATUS "Enabling OpenVINO face-detection for realsense-viewer ..." ) @@ -89,12 +92,22 @@ if(DEFINED INTEL_OPENVINO_DIR AND IS_DIRECTORY ${INTEL_OPENVINO_DIR}) include(${INTEL_OPENVINO_DIR}/inference_engine/share/InferenceEngineConfig.cmake) get_property(deps VARIABLE PROPERTY DEPENDENCIES) - set(DEPENDENCIES ${deps} ${InferenceEngine_LIBRARIES} ie_cpu_extension) + + check_vino_version() + if(OPENVINO2019) + set(DEPENDENCIES ${deps} ${InferenceEngine_LIBRARIES} ie_cpu_extension) + else() + set(DEPENDENCIES ${deps} ${InferenceEngine_LIBRARIES}) + endif() + include_directories( ../../wrappers/openvino ) include_directories( ../../wrappers/opencv ) include_directories( ${InferenceEngine_INCLUDE_DIRS} ) + + if(OPENVINO2019) # We need additional access to ext_list.hpp, for CPU extension support: - include_directories( ${IE_ROOT_DIR}/src/extension ) + include_directories( "${IE_ROOT_DIR}/src/extension" ) + endif() set(OPENVINO_FILES ../../wrappers/openvino/rs-vino/base-detection.cpp @@ -106,9 +119,12 @@ if(DEFINED INTEL_OPENVINO_DIR AND IS_DIRECTORY ${INTEL_OPENVINO_DIR}) ../../wrappers/openvino/rs-vino/detected-object.cpp ../../wrappers/openvino/rs-vino/detected-object.h ../../wrappers/openvino/rs-vino/openvino-helpers.h - ${IE_ROOT_DIR}/src/extension/ext_list.hpp ) + if(OPENVINO2019) + set(OPENVINO_FILES ${OPENVINO_FILES} "${IE_ROOT_DIR}/src/extension/ext_list.hpp") + endif() + set(RS_VIEWER_CPP ${RS_VIEWER_CPP} openvino-face-detection.cpp @@ -176,6 +192,10 @@ else() ) endif() +if(OPENVINO2019) + target_compile_definitions(realsense-viewer PRIVATE OPENVINO2019) +endif() + source_group("EasyLogging++" FILES ${ELPP_FILES}) source_group("SW-Update" FILES ${SW_UPDATE_FILES}) diff --git a/tools/realsense-viewer/openvino-face-detection.cpp b/tools/realsense-viewer/openvino-face-detection.cpp index 402d38fe13..1da12c1f0d 100644 --- a/tools/realsense-viewer/openvino-face-detection.cpp +++ b/tools/realsense-viewer/openvino-face-detection.cpp @@ -3,14 +3,15 @@ // NOTE: This file will be compiled only with INTEL_OPENVINO_DIR pointing to an OpenVINO install! - #include "post-processing-filters-list.h" #include "post-processing-worker-filter.h" + #include #include #include #include +namespace openvino = InferenceEngine; /* We need to extend the basic detected_object to include facial characteristics */ @@ -94,6 +95,7 @@ class openvino_face_detection : public post_processing_worker_filter // Complete background worker to ensure it releases the instance's resources in controlled manner release_background_worker(); } + public: void start( rs2::subdevice_model & model ) override { @@ -105,9 +107,14 @@ class openvino_face_detection : public post_processing_worker_filter void worker_start() override { LOG(INFO) << "Loading CPU extensions..."; - _ie.AddExtension( std::make_shared< InferenceEngine::Extensions::Cpu::CpuExtensions >(), "CPU" ); - _face_detector.load_into( _ie, "CPU" ); - _age_detector.load_into( _ie, "CPU" ); + std::string const device_name{ "CPU" }; + +#ifdef OPENVINO2019 + _ie.AddExtension(std::make_shared< openvino::Extensions::Cpu::CpuExtensions >(), device_name); +#endif + + _face_detector.load_into( _ie, device_name); + _age_detector.load_into( _ie, device_name); } /* diff --git a/wrappers/openvino/CMakeLists.txt b/wrappers/openvino/CMakeLists.txt index 288365e1ed..bc0d587d59 100644 --- a/wrappers/openvino/CMakeLists.txt +++ b/wrappers/openvino/CMakeLists.txt @@ -14,11 +14,23 @@ endif() set(IE_ROOT_DIR "${INTEL_OPENVINO_DIR}/inference_engine") include(${INTEL_OPENVINO_DIR}/inference_engine/share/InferenceEngineConfig.cmake) get_property(deps VARIABLE PROPERTY DEPENDENCIES) -set(DEPENDENCIES ${deps} ${InferenceEngine_LIBRARIES} ie_cpu_extension) + +include(check_vino_version.cmake) +check_vino_version() + +if(OPENVINO2019) + set(DEPENDENCIES ${deps} ${InferenceEngine_LIBRARIES} ie_cpu_extension) +else() + set(DEPENDENCIES ${deps} ${InferenceEngine_LIBRARIES}) +endif() + include_directories( . ) include_directories( ${InferenceEngine_INCLUDE_DIRS} ) + +if(OPENVINO2019) # We need additional access to ext_list.hpp, for CPU extension support: -include_directories( ${IE_ROOT_DIR}/src/extension ) + include_directories( "${IE_ROOT_DIR}/src/extension" ) +endif() # The rs-vino directory includes additional classes and helpers that need to be included set(OPENVINO_FILES @@ -29,8 +41,12 @@ set(OPENVINO_FILES ../rs-vino/detected-object.cpp ../rs-vino/detected-object.h ../rs-vino/openvino-helpers.h - ${IE_ROOT_DIR}/src/extension/ext_list.hpp ) + +if(OPENVINO2019) + set(OPENVINO_FILES ${OPENVINO_FILES} "${IE_ROOT_DIR}/src/extension/ext_list.hpp") +endif() + # And they make use of ELPP (EasyLogging++): include_directories( ../../third-party/easyloggingpp/src ) set( ELPP_FILES diff --git a/wrappers/openvino/check_vino_version.cmake b/wrappers/openvino/check_vino_version.cmake new file mode 100644 index 0000000000..01f63995ba --- /dev/null +++ b/wrappers/openvino/check_vino_version.cmake @@ -0,0 +1,10 @@ + +# OPENVINO version 2019 an lower has its own API for working with the device extensions. +# Here we checkout the OPENVINO version by existence of the specific file. +set(OPENVINO2019 false) +macro(check_vino_version) + if(EXISTS "${IE_ROOT_DIR}/src/extension/ext_list.hpp") + message("OPENVINO version has been found out to be 2019 or lower") + set(OPENVINO2019 true) + endif() +endmacro() diff --git a/wrappers/openvino/dnn/CMakeLists.txt b/wrappers/openvino/dnn/CMakeLists.txt index 3d80a8f55e..f512351689 100644 --- a/wrappers/openvino/dnn/CMakeLists.txt +++ b/wrappers/openvino/dnn/CMakeLists.txt @@ -21,6 +21,10 @@ add_executable(rs-dnn-vino ${ELPP_FILES} ) +if(OPENVINO2019) + target_compile_definitions(rs-dnn-vino PRIVATE OPENVINO2019) +endif() + source_group("OpenVINO" FILES ${OPENVINO_FILES}) source_group("EasyLogging++" FILES ${ELPP_FILES}) diff --git a/wrappers/openvino/dnn/rs-dnn-vino.cpp b/wrappers/openvino/dnn/rs-dnn-vino.cpp index 40714c6b00..cf1aed92d5 100644 --- a/wrappers/openvino/dnn/rs-dnn-vino.cpp +++ b/wrappers/openvino/dnn/rs-dnn-vino.cpp @@ -218,7 +218,10 @@ int main(int argc, char * argv[]) try openvino_helpers::error_listener error_listener; engine.SetLogCallback( error_listener ); std::string const device_name { "CPU" }; - engine.AddExtension( std::make_shared< openvino::Extensions::Cpu::CpuExtensions >(), device_name ); + +#ifdef OPENVINO2019 + engine.AddExtension(std::make_shared< openvino::Extensions::Cpu::CpuExtensions >(), device_name); +#endif std::vector< detector_and_labels > detectors; load_detectors_into( detectors, engine, device_name ); diff --git a/wrappers/openvino/face/CMakeLists.txt b/wrappers/openvino/face/CMakeLists.txt index 632d333a46..1080deb3bb 100644 --- a/wrappers/openvino/face/CMakeLists.txt +++ b/wrappers/openvino/face/CMakeLists.txt @@ -21,6 +21,10 @@ add_executable(rs-face-vino ${ELPP_FILES} ) +if(OPENVINO2019) + target_compile_definitions(rs-face-vino PRIVATE OPENVINO2019) +endif() + source_group("OpenVINO" FILES ${OPENVINO_FILES}) source_group("EasyLogging++" FILES ${ELPP_FILES}) diff --git a/wrappers/openvino/face/rs-face-vino.cpp b/wrappers/openvino/face/rs-face-vino.cpp index edd26c5a1f..32f29ec1a1 100644 --- a/wrappers/openvino/face/rs-face-vino.cpp +++ b/wrappers/openvino/face/rs-face-vino.cpp @@ -40,7 +40,10 @@ int main(int argc, char * argv[]) try openvino_helpers::error_listener error_listener; engine.SetLogCallback( error_listener ); std::string const device_name { "CPU" }; + +#ifdef OPENVINO2019 engine.AddExtension( std::make_shared< openvino::Extensions::Cpu::CpuExtensions >(), device_name ); +#endif openvino_helpers::object_detection faceDetector( "face-detection-adas-0001.xml", diff --git a/wrappers/openvino/rs-vino/openvino-helpers.h b/wrappers/openvino/rs-vino/openvino-helpers.h index 9cebb8e554..c88d32e32d 100644 --- a/wrappers/openvino/rs-vino/openvino-helpers.h +++ b/wrappers/openvino/rs-vino/openvino-helpers.h @@ -14,7 +14,9 @@ #pragma warning(disable:4275) # include # include +#ifdef OPENVINO2019 # include // Required for CPU extension usage +#endif #pragma warning(pop) #include