Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility to both 2019/2020 versions of the openVINO was added #7851

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions tools/realsense-viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,32 @@ 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 ..." )
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)

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
Expand All @@ -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
Expand Down Expand Up @@ -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})

Expand Down
15 changes: 11 additions & 4 deletions tools/realsense-viewer/openvino-face-detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <rs-vino/object-detection.h>
#include <rs-vino/age-gender-detection.h>
#include <rs-vino/detected-object.h>
#include <cv-helpers.hpp>

namespace openvino = InferenceEngine;

/* We need to extend the basic detected_object to include facial characteristics
*/
Expand Down Expand Up @@ -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
{
Expand All @@ -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);
}

/*
Expand Down
22 changes: 19 additions & 3 deletions wrappers/openvino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions wrappers/openvino/check_vino_version.cmake
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions wrappers/openvino/dnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
5 changes: 4 additions & 1 deletion wrappers/openvino/dnn/rs-dnn-vino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 4 additions & 0 deletions wrappers/openvino/face/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
3 changes: 3 additions & 0 deletions wrappers/openvino/face/rs-face-vino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions wrappers/openvino/rs-vino/openvino-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#pragma warning(disable:4275)
# include <inference_engine.hpp>
# include <ie_iextension.h>
#ifdef OPENVINO2019
# include <ext_list.hpp> // Required for CPU extension usage
#endif
#pragma warning(pop)

#include <opencv2/opencv.hpp>
Expand Down