Skip to content

Commit

Permalink
Merge pull request #53 from RachelRen05/add_unitTest
Browse files Browse the repository at this point in the history
Add unit test & code style reformat.
  • Loading branch information
LewisLiuPub authored Feb 19, 2019
2 parents 5d5c319 + 7c9ae8d commit 3d65b04
Show file tree
Hide file tree
Showing 119 changed files with 5,230 additions and 4,664 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ One-step installation scripts are provided for the dependencies' installation. P
* run object detection service sample code input from Image
Run image processing service:
```bash
ros2 run dynamic_vino_sample image_object_server "image_object_server_oss.yaml"
ros2 launch dynamic_vino_sample image_object_server_oss.launch.py
```
Run example application with an absolute path of an image on another console:
```bash
Expand All @@ -197,3 +197,4 @@ One-step installation scripts are provided for the dependencies' installation. P

# More Information
* ROS2 OpenVINO discription writen in Chinese: https://mp.weixin.qq.com/s/BgG3RGauv5pmHzV_hkVAdw

Binary file added data/images/car_vihecle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 20 additions & 17 deletions doc/BINARY_VERSION_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,30 @@ This project is a ROS2 wrapper for CV API of [OpenVINO™](https://software.inte
## 5. Running the Demo
* Preparation
* download and convert a trained model to produce an optimized Intermediate Representation (IR) of the model
```bash
cd /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/install_prerequisites
sudo ./install_prerequisites.sh
mkdir -p ~/Downloads/models
cd ~/Downloads/models
wget http://download.tensorflow.org/models/object_detection/mask_rcnn_inception_v2_coco_2018_01_28.tar.gz
tar -zxvf mask_rcnn_inception_v2_coco_2018_01_28.tar.gz
cd mask_rcnn_inception_v2_coco_2018_01_28
python3 /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/mo_tf.py --input_model frozen_inference_graph.pb --tensorflow_use_custom_operations_config /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/extensions/front/tf/mask_rcnn_support.json --tensorflow_object_detection_api_pipeline_config pipeline.config --reverse_input_channels --output_dir ./output/
sudo mkdir -p /opt/models
sudo ln -sf ~/Downloads/models/mask_rcnn_inception_v2_coco_2018_01_28 /opt/models/
```
```bash
#object segmentation model
cd /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/install_prerequisites
sudo ./install_prerequisites.sh
mkdir -p ~/Downloads/models
cd ~/Downloads/models
wget http://download.tensorflow.org/models/object_detection/mask_rcnn_inception_v2_coco_2018_01_28.tar.gz
tar -zxvf mask_rcnn_inception_v2_coco_2018_01_28.tar.gz
cd mask_rcnn_inception_v2_coco_2018_01_28
python3 /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/mo_tf.py --input_model frozen_inference_graph.pb --tensorflow_use_custom_operations_config /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/extensions/front/tf/mask_rcnn_support.json --tensorflow_object_detection_api_pipeline_config pipeline.config --reverse_input_channels --output_dir ./output/
sudo mkdir -p /opt/models
sudo ln -sf ~/Downloads/models/mask_rcnn_inception_v2_coco_2018_01_28 /opt/models/
#object detection model
cd /opt/intel/computer_vision_sdk/deployment_tools/model_downloader
sudo python3 downloader.py --name ssd300
sudo python3 /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/mo.py --input_model /opt/intel/computer_vision_sdk/deployment_tools/model_downloader/object_detection/common/ssd/300/caffe/ssd300.caffemodel --output_dir /opt/intel/computer_vision_sdk/deployment_tools/model_downloader/object_detection/common/ssd/300/caffe/output/
```
* copy label files (excute _once_)<br>
```bash
sudo cp /opt/openvino_toolkit/ros2_openvino_toolkit/data/labels/emotions-recognition/FP32/emotions-recognition-retail-0003.labels /opt/intel/computer_vision_sdk/deployment_tools/intel_models/emotions-recognition-retail-0003/FP32
sudo cp /opt/openvino_toolkit/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels /opt/intel/computer_vision_sdk/deployment_tools/intel_models/face-detection-adas-0001/FP32
sudo cp /opt/openvino_toolkit/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels /opt/intel/computer_vision_sdk/deployment_tools/intel_models/face-detection-adas-0001/FP16
sudo cp /opt/openvino_toolkit/ros2_openvino_toolkit/data/labels/object_segmentation/frozen_inference_graph.labels ~/Downloads/models/mask_rcnn_inception_v2_coco_2018_01_28/output
sudo cp /opt/openvino_toolkit/ros2_openvino_toolkit/data/labels/object_detection/ssd300.labels /opt/intel/computer_vision_sdk/deployment_tools/model_downloader/object_detection/common/ssd/300/caffe/output
```
* set ENV LD_LIBRARY_PATH
```bash
Expand All @@ -164,10 +170,6 @@ This project is a ROS2 wrapper for CV API of [OpenVINO™](https://software.inte
```bash
ros2 launch dynamic_vino_sample pipeline_object.launch.py
```
* run object detection sample code input from RealSenseCameraTopic.
```bash
ros2 launch dynamic_vino_sample pipeline_object_topic.launch.py
```
* run object segmentation sample code input from RealSenseCameraTopic.
```bash
ros2 launch dynamic_vino_sample pipeline_segmentation.launch.py
Expand All @@ -179,7 +181,7 @@ This project is a ROS2 wrapper for CV API of [OpenVINO™](https://software.inte
* run object detection service sample code input from Image
Run image processing service:
```bash
ros2 run dynamic_vino_sample image_object_server "image_object_server.yaml"
ros2 launch dynamic_vino_sample image_object_server.launch.py
```
Run example application with an absolute path of an image on another console:
```bash
Expand All @@ -196,3 +198,4 @@ This project is a ROS2 wrapper for CV API of [OpenVINO™](https://software.inte
```
> solution - Please reboot while connecting Intel® Neural Compute Stick 2.


86 changes: 45 additions & 41 deletions dynamic_vino_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required (VERSION 3.5)
cmake_minimum_required(VERSION 3.5)

project(dynamic_vino_lib)

list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

####################################
## to use C++14
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
####################################

Expand All @@ -32,7 +32,7 @@ set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")

message(STATUS "Looking for inference engine configuration file at: ${CMAKE_PREFIX_PATH}")
find_package(InferenceEngine 1.1)
if (NOT InferenceEngine_FOUND)
if(NOT InferenceEngine_FOUND)
message(FATAL_ERROR "")
endif()

Expand Down Expand Up @@ -62,7 +62,7 @@ find_package(cv_bridge REQUIRED)
find_package(vino_param_lib REQUIRED)
find_package(yaml_cpp_vendor REQUIRED)

set (CpuExtension_lib $ENV{CPU_EXTENSION_LIB})
set(CpuExtension_lib $ENV{CPU_EXTENSION_LIB})

add_library(cpu_extension SHARED IMPORTED)
set_target_properties(cpu_extension PROPERTIES
Expand All @@ -74,46 +74,46 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif()

if (NOT(BIN_FOLDER))
if(NOT(BIN_FOLDER))
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set (ARCH intel64)
set(ARCH intel64)
else()
set (ARCH ia32)
set(ARCH ia32)
endif()

set (BIN_FOLDER ${ARCH})
set(BIN_FOLDER ${ARCH})
endif()

if (NOT (IE_MAIN_SOURCE_DIR))
if(NOT (IE_MAIN_SOURCE_DIR))
set(NEED_EXTENSIONS TRUE)
if (WIN32)
set (IE_MAIN_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../bin/)
if(WIN32)
set(IE_MAIN_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../bin/)
else()
set (IE_MAIN_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(IE_MAIN_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()

if(NOT(UNIX))
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set (CMAKE_LIBRARY_PATH ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set (CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set (LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}) # compatibility issue: linux uses LIBRARY_OUTPUT_PATH, windows uses LIBRARY_OUTPUT_DIRECTORY
else ()
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
set (CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
set (LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set(CMAKE_LIBRARY_PATH ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set(CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set(LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
set(LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}) # compatibility issue: linux uses LIBRARY_OUTPUT_PATH, windows uses LIBRARY_OUTPUT_DIRECTORY
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
set(CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
set(LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set(LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}/lib)
endif()


if (WIN32)
if(WIN32)
if(NOT "${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(FATAL_ERROR "Only 64-bit supported on Windows")
endif()
Expand All @@ -122,16 +122,16 @@ if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS -DNOMINMAX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") #no asynchronous structured exception handling
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
if (ENABLE_OMP)
if(ENABLE_OMP)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type ")
if (APPLE)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-command-line-argument")
elseif(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized -Winit-self -Wmaybe-uninitialized")
Expand All @@ -152,10 +152,14 @@ if(UNIX OR APPLE)
endif()
endif()

include(feature_defs OPTIONAL)
#The below command is commented in order to ignore "colcon test" errors.
#This maybe impacts CPU's inference tuning, although we tested on Core i7-6700 and got the similar performance.
#If you concern the inference performence, you can try to get the resource from the follow url and enable the below line.
#https://github.com/opencv/dldt/tree/2018/inference-engine/src/extension/cmake
#include(feature_defs OPTIONAL)

# Properties->C/C++->General->Additional Include Directories
include_directories (
include_directories(
# ${CMAKE_CURRENT_SOURCE_DIR}/common/format_reader
${CMAKE_CURRENT_SOURCE_DIR}/include
${InferenceEngine_INCLUDE_DIRS}
Expand All @@ -165,8 +169,8 @@ include_directories (
${librealsense2_INCLUDE_DIRS}
)

if (UNIX)
SET(LIB_DL dl)
if(UNIX)
set(LIB_DL dl)
endif()

set(DEPENDENCIES ${librealsense2_LIBRARIES} ${OpenCV_LIBS} cpu_extension)
Expand Down Expand Up @@ -202,7 +206,7 @@ add_library(${PROJECT_NAME} SHARED
src/outputs/rviz_output.cpp
src/outputs/base_output.cpp
src/outputs/ros_service_output.cpp
)
)

target_link_libraries(${PROJECT_NAME} ${DEPENDENCIES})

Expand Down
Loading

0 comments on commit 3d65b04

Please sign in to comment.