Skip to content
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
Empty file.
Empty file.
121 changes: 121 additions & 0 deletions doc/quick_start/getting_started_with_Galactic_Ubuntu20.04.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# ROS2_GALACTIC_OpenVINO_Toolkit

**NOTE:**
Below steps have been tested on **Ubuntu 20.04**.

## 1. Environment Setup
* Install ROS2 Galactic ([guide](https://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Debians.html))
* Install Intel® OpenVINO™ Toolkit Version: 2021.4 ([guide](https://docs.openvino.ai/2021.4/openvino_docs_install_guides_installing_openvino_linux.html)) or building by source code ([guide](https://github.com/openvinotoolkit/openvino/wiki/BuildingForLinux))
* Install Intel® RealSense ™ SDK ([guide](https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md))

## 2. Building and Installation
* Install ROS2_OpenVINO_Toolkit packages
```
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/intel/ros2_openvino_toolkit -b galactic_dev
git clone https://github.com/intel/ros2_object_msgs
git clone https://github.com/IntelRealSense/realsense-ros.git -b ros2
git clone https://github.com/ros-perception/vision_opencv.git -b ros2
```
* Install dependencies
```
sudo apt-get install ros-galactic-diagnostic-updater
```
* Build package
```
source /opt/ros/galactic/setup.bash
source /opt/intel/openvino_2021/bin/setupvars.sh
cd ~/catkin_ws
colcon build --symlink-install
source ./install/local_setup.bash
```

## 3. Running the Demo
* See all available models
```
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/tools/downloader
sudo python3 downloader.py --print_all
```

* Download the optimized Intermediate Representation (IR) of model (execute once), for example:
```
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/tools/downloader
sudo python3 downloader.py --name face-detection-adas-0001 --output_dir /opt/openvino_toolkit/models/face_detection/output
sudo python3 downloader.py --name age-gender-recognition-retail-0013 --output_dir /opt/openvino_toolkit/models/age-gender-recognition/output
sudo python3 downloader.py --name emotions-recognition-retail-0003 --output_dir /opt/openvino_toolkit/models/emotions-recognition/output
sudo python3 downloader.py --name head-pose-estimation-adas-0001 --output_dir /opt/openvino_toolkit/models/head-pose-estimation/output
sudo python3 downloader.py --name person-detection-retail-0013 --output_dir /opt/openvino_toolkit/models/person-detection/output
sudo python3 downloader.py --name person-reidentification-retail-0277 --output_dir /opt/openvino_toolkit/models/person-reidentification/output
sudo python3 downloader.py --name landmarks-regression-retail-0009 --output_dir /opt/openvino_toolkit/models/landmarks-regression/output
sudo python3 downloader.py --name semantic-segmentation-adas-0001 --output_dir /opt/openvino_toolkit/models/semantic-segmentation/output
sudo python3 downloader.py --name vehicle-license-plate-detection-barrier-0106 --output_dir /opt/openvino_toolkit/models/vehicle-license-plate-detection/output
sudo python3 downloader.py --name vehicle-attributes-recognition-barrier-0039 --output_dir /opt/openvino_toolkit/models/vehicle-attributes-recognition/output
sudo python3 downloader.py --name license-plate-recognition-barrier-0001 --output_dir /opt/openvino_toolkit/models/license-plate-recognition/output
sudo python3 downloader.py --name person-attributes-recognition-crossroad-0230 --output_dir /opt/openvino_toolkit/models/person-attributes/output
```

* copy label files (execute once)
```
sudo cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels /opt/openvino_toolkit/models/face_detection/output/intel/face-detection-adas-0001/FP32/
sudo cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels /opt/openvino_toolkit/models/face_detection/output/intel/face-detection-adas-0001/FP16/
sudo cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/emotions-recognition/FP32/emotions-recognition-retail-0003.labels /opt/openvino_toolkit/models/emotions-recognition/output/intel/emotions-recognition-retail-0003/FP32/
sudo cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/object_segmentation/frozen_inference_graph.labels /opt/openvino_toolkit/models/semantic-segmentation/output/FP32/
sudo cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/object_segmentation/frozen_inference_graph.labels /opt/openvino_toolkit/models/semantic-segmentation/output/FP16/
sudo cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/object_detection/vehicle-license-plate-detection-barrier-0106.labels /opt/openvino_toolkit/models/vehicle-license-plate-detection/output/intel/vehicle-license-plate-detection-barrier-0106/FP32

```

* If the model (tensorflow, caffe, MXNet, ONNX, Kaldi)need to be converted to intermediate representation (For example the model for object detection)
* mobilenet-ssd
```
sudo python3 downloader.py --name mobilenet-ssd --output_dir /opt/openvino_toolkit/models/object_detection/mobilenet_ssd/caffe/output
cd /opt/intel/openvino_2021/deployment_tools/model_optimizer
sudo python3 mo.py --input_model /opt/openvino_toolkit/models/object_detection/mobilenet_ssd/caffe/output/public/mobilenet-ssd/mobilenet-ssd.caffemodel --output_dir /opt/openvino_toolkit/models/object_detection/mobilenet_ssd/caffe/output
```
* deeplabv3
```
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/tools/downloader
sudo python3 downloader.py --name deeplabv3 --output_dir /opt/openvino_toolkit/models/deeplabv3/output
sudo python3 converter.py --name=deeplabv3 --mo /opt/intel/openvino_2021/deployment_tools/model_optimizer/mo.py
```

* Before launch, check the parameter configuration in ros2_openvino_toolkit/sample/param/xxxx.yaml, make sure the paramter like model path, label path, inputs are right.
* run face detection sample code input from StandardCamera.
```
ros2 launch dynamic_vino_sample pipeline_people.launch.py
```
* run person reidentification sample code input from StandardCamera.
```
ros2 launch dynamic_vino_sample pipeline_reidentification.launch.py
```
* run person face reidentification sample code input from RealSenseCamera.
```
ros2 launch dynamic_vino_sample pipeline_face_reidentification.launch.py
```
* run face detection sample code input from Image.
```
ros2 launch dynamic_vino_sample pipeline_image.launch.py
```
* run object segmentation sample code input from RealSenseCameraTopic.
```
ros2 launch dynamic_vino_sample pipeline_segmentation.launch.py
```
<!-- * run object segmentation sample code input from Image.
```
ros2 launch dynamic_vino_sample pipeline_segmentation_image.launch.py
``` -->
* run vehicle detection sample code input from StandardCamera.
```
ros2 launch dynamic_vino_sample pipeline_vehicle_detection.launch.py
```
* run person attributes sample code input from StandardCamera.
```
ros2 launch dynamic_vino_sample pipeline_person_attributes.launch.py
```

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

###### *Any security issue should be reported using process at https://01.org/security*

35 changes: 0 additions & 35 deletions docker/Dockerfile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Models
class AgeGenderDetectionModel : public BaseModel
{
public:
AgeGenderDetectionModel(const std::string & model_loc, int batch_size = 1);
AgeGenderDetectionModel(const std::string& label_loc, const std::string& model_loc, int batch_size = 1);
/**
* @brief Get the input name.
* @return Input name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Models
* @param[in] batch_size The number of batch size (default: 1) the network should have.
* @return Whether the input device is successfully turned on.
*/
BaseModel(const std::string &model_loc, int batch_size = 1);
BaseModel(const std::string& label_loc, const std::string& model_loc, int batch_size = 1);

/**
* @brief Get the maximum batch size of the model.
Expand Down Expand Up @@ -124,13 +124,14 @@ namespace Models
private:
int max_batch_size_;
std::string model_loc_;
std::string label_loc_;
cv::Size frame_size_;
};

class ObjectDetectionModel : public BaseModel
{
public:
ObjectDetectionModel(const std::string &model_loc, int batch_size = 1);
ObjectDetectionModel(const std::string& label_loc, const std::string& model_loc, int batch_size = 1);
virtual bool fetchResults(
const std::shared_ptr<Engines::Engine> &engine,
std::vector<dynamic_vino_lib::ObjectDetectionResult> &result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Models
class EmotionDetectionModel : public BaseModel
{
public:
EmotionDetectionModel(const std::string & model_loc, int batch_size = 1);
EmotionDetectionModel(const std::string& label_loc, const std::string& model_loc, int batch_size = 1);

/**
* @brief Get the name of this detection model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Models
class FaceDetectionModel : public ObjectDetectionModel
{
public:
FaceDetectionModel(const std::string & model_loc, int batch_size = 1);
FaceDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
//void checkLayerProperty(const InferenceEngine::CNNNetReader::Ptr &) override;
/**
* @brief Get the name of this detection model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Models
class FaceReidentificationModel : public BaseModel
{
public:
FaceReidentificationModel(const std::string & model_loc, int batch_size = 1);
FaceReidentificationModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
inline const std::string getInputName() {return input_;}
inline const std::string getOutputName() {return output_;}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Models
class HeadPoseDetectionModel : public BaseModel
{
public:
HeadPoseDetectionModel(const std::string & model_loc, int batch_size = 1);
HeadPoseDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);

/**
* @brief Get the output angle roll.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Models
class LandmarksDetectionModel : public BaseModel
{
public:
LandmarksDetectionModel(const std::string & model_loc, int batch_size = 1);
LandmarksDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
inline const std::string getInputName() {return input_;}
inline const std::string getOutputName() {return output_;}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Models
class LicensePlateDetectionModel : public BaseModel
{
public:
LicensePlateDetectionModel(const std::string & model_loc, int batch_size = 1);
LicensePlateDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
inline const std::string getInputName() {return input_;}
inline const std::string getSeqInputName() {return seq_input_;}
inline const std::string getOutputName() {return output_;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ObjectDetectionSSDModel : public ObjectDetectionModel
using Result = dynamic_vino_lib::ObjectDetectionResult;

public:
ObjectDetectionSSDModel(const std::string & model_loc, int batch_size = 1);
ObjectDetectionSSDModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);

bool fetchResults(
const std::shared_ptr<Engines::Engine> & engine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ObjectDetectionYolov2Model : public ObjectDetectionModel
using Result = dynamic_vino_lib::ObjectDetectionResult;

public:
ObjectDetectionYolov2Model(const std::string & model_loc, int batch_size = 1);
ObjectDetectionYolov2Model(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);

bool fetchResults(
const std::shared_ptr<Engines::Engine> & engine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Models
class ObjectSegmentationModel : public BaseModel
{
public:
ObjectSegmentationModel(const std::string & model_loc, int batch_size = 1);
ObjectSegmentationModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
inline int getMaxProposalCount() const
{
return max_proposal_count_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Models
class PersonAttribsDetectionModel : public BaseModel
{
public:
PersonAttribsDetectionModel(const std::string & model_loc, int batch_size = 1);
PersonAttribsDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
//inline const std::string getInputName() {return input_;}
//inline const std::string getOutputName() {return output_;}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Models
class PersonReidentificationModel : public BaseModel
{
public:
PersonReidentificationModel(const std::string & model_loc, int batch_size = 1);
PersonReidentificationModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
inline const std::string getInputName() {return input_;}
inline const std::string getOutputName() {return output_;}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Models
class VehicleAttribsDetectionModel : public BaseModel
{
public:
VehicleAttribsDetectionModel(const std::string & model_loc, int batch_size = 1);
VehicleAttribsDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
inline const std::string getInputName() {return input_;}
inline const std::string getColorOutputName() {return color_output_;}
inline const std::string getTypeOutputName() {return type_output_;}
Expand Down
3 changes: 2 additions & 1 deletion dynamic_vino_lib/src/models/age_gender_detection_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

// Validated Age Gender Classification Network
Models::AgeGenderDetectionModel::AgeGenderDetectionModel(
const std::string & label_loc,
const std::string & model_loc,
int max_batch_size)
: BaseModel(model_loc, max_batch_size)
: BaseModel(label_loc,model_loc, max_batch_size)
{
}
bool Models::AgeGenderDetectionModel::updateLayerProperty(
Expand Down
18 changes: 11 additions & 7 deletions dynamic_vino_lib/src/models/base_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@

// Validated Base Network
Models::BaseModel::BaseModel(
const std::string & model_loc, int max_batch_size)
: model_loc_(model_loc),
const std::string& label_loc, const std::string& model_loc, int max_batch_size)
: label_loc_(label_loc),
model_loc_(model_loc),
max_batch_size_(max_batch_size),
ModelAttribute(model_loc)
{
Expand All @@ -43,7 +44,8 @@ Models::BaseModel::BaseModel(

void Models::BaseModel::modelInit()
{
slog::info << "Loading network files" << slog::endl;
slog::info << "Loading network files" << model_loc_ << slog::endl;
slog::info << label_loc_ << slog::endl;
// Read network model
///net_reader_->ReadNetwork(model_loc_);
net_reader_ = engine.ReadNetwork(model_loc_);
Expand All @@ -54,8 +56,9 @@ void Models::BaseModel::modelInit()
///std::string bin_file_name = raw_name + ".bin";
///net_reader_->ReadWeights(bin_file_name);
// Read labels (if any)
std::string label_file_name = raw_name + ".labels";
loadLabelsFromFile(label_file_name);
std::string label_file_name = label_loc_.substr(0, last_index);
//std::string label_file_name = raw_name + ".labels";
loadLabelsFromFile(label_loc_);

// Set batch size to given max_batch_size_
slog::info << "Batch size is set to " << max_batch_size_ << slog::endl;
Expand Down Expand Up @@ -87,6 +90,7 @@ bool Models::BaseModel::updateLayerProperty(
#endif

Models::ObjectDetectionModel::ObjectDetectionModel(
const std::string & model_loc,
const std::string& label_loc,
const std::string& model_loc,
int max_batch_size)
: BaseModel(model_loc, max_batch_size) {}
: BaseModel(label_loc, model_loc, max_batch_size) {}
4 changes: 2 additions & 2 deletions dynamic_vino_lib/src/models/emotion_detection_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

// Validated Emotions Detection Network
Models::EmotionDetectionModel::EmotionDetectionModel(
const std::string & model_loc, int max_batch_size)
: BaseModel(model_loc, max_batch_size)
const std::string & label_loc, const std::string & model_loc, int max_batch_size)
: BaseModel(label_loc, model_loc, max_batch_size)
{
}

Expand Down
4 changes: 2 additions & 2 deletions dynamic_vino_lib/src/models/face_detection_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

// Validated Face Detection Network
Models::FaceDetectionModel::FaceDetectionModel(
const std::string & model_loc, int max_batch_size)
: ObjectDetectionModel(model_loc, max_batch_size)
const std::string & label_loc, const std::string & model_loc, int max_batch_size)
: ObjectDetectionModel(label_loc, model_loc, max_batch_size)
{
}

Expand Down
4 changes: 2 additions & 2 deletions dynamic_vino_lib/src/models/face_reidentification_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "dynamic_vino_lib/slog.hpp"
// Validated Face Reidentification Network
Models::FaceReidentificationModel::FaceReidentificationModel(
const std::string & model_loc, int max_batch_size)
: BaseModel(model_loc, max_batch_size) {}
const std::string & label_loc, const std::string & model_loc, int max_batch_size)
: BaseModel(label_loc, model_loc, max_batch_size) {}

void Models::FaceReidentificationModel::setLayerProperty(
InferenceEngine::CNNNetwork& net_reader)
Expand Down
4 changes: 2 additions & 2 deletions dynamic_vino_lib/src/models/head_pose_detection_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

// Validated Head Pose Network
Models::HeadPoseDetectionModel::HeadPoseDetectionModel(
const std::string & model_loc, int max_batch_size)
: BaseModel(model_loc, max_batch_size)
const std::string & label_loc, const std::string & model_loc, int max_batch_size)
: BaseModel(label_loc, model_loc, max_batch_size)
{
}

Expand Down
Loading