diff --git a/README.md b/README.md
index 33d0f8be..869fa51c 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@
* [x] Age Gender Recognition
* [x] Emotion Recognition
* [x] Head Pose Estimation
-* [x] Object Segmentation
+* [x] Object Segmentation (Semantic & Instance)
* [x] Person Re-Identification
* [x] Vehicle Attribute Detection
* [x] Vehicle License Plate Detection
@@ -54,6 +54,7 @@
# Introduction
## Design Architecture
+
Architecture Design
From the view of hirarchical architecture design, the package is divided into different functional components, as shown in below picture.

@@ -94,8 +95,10 @@ See more from [here](https://github.com/openvinotoolkit/openvino) for Intel Open
- **Optimized Models** provided by Model Optimizer component of Intel® OpenVINO™ toolkit. Imports trained models from various frameworks (Caffe*, Tensorflow*, MxNet*, ONNX*, Kaldi*) and converts them to a unified intermediate representation file. It also optimizes topologies through node merging, horizontal fusion, eliminating batch normalization, and quantization. It also supports graph freeze and graph summarize along with dynamic input freezing.
+
## Logic Flow
+ Logic Flow
From the view of logic implementation, the package introduces the definitions of parameter manager, pipeline and pipeline manager. The following picture depicts how these entities co-work together when the corresponding program is launched.

@@ -119,6 +122,7 @@ The contents in **.yaml config file** should be well structured and follow the s
**Pipeline manager** manages all the created pipelines according to the inference requests or external demands (say, system exception, resource limitation, or end user's operation). Because of co-working with resource management and being aware of the whole framework, it covers the ability of performance optimization by sharing system resource between pipelines and reducing the burden of data copy.
+
# Supported Features
## Multiple Input Components
@@ -152,12 +156,13 @@ Currently, the corresponding relation of supported inference features, models us
|Emotion Recognition| Emotion recognition based on detected face image.|[pipeline_image.yaml](./sample/param/pipeline_image.yaml)
[pipeline_image_video.yaml](./sample/param/pipeline_image_video.yaml)
[pipeline_people.yaml](./sample/param/pipeline_people.yaml)
[pipeline_people_ip.yaml](./sample/param/pipeline_people_ip.yaml)|[emotions-recognition-retail-0003](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/emotions-recognition-retail-0003)|
|Age & Gender Recognition| Age and gender recognition based on detected face image.|[pipeline_image.yaml](./sample/param/pipeline_image.yaml)
[pipeline_image_video.yaml](./sample/param/pipeline_image_video.yaml)
[pipeline_people.yaml](./sample/param/pipeline_people.yaml)
[pipeline_people_ip.yaml](./sample/param/pipeline_people_ip.yaml)|[age-gender-recognition-retail-0013](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/age-gender-recognition-retail-0013)|
|Head Pose Estimation| Head pose estimation based on detected face image.|[pipeline_image.yaml](./sample/param/pipeline_image.yaml)
[pipeline_image_video.yaml](./sample/param/pipeline_image_video.yaml)
[pipeline_people.yaml](./sample/param/pipeline_people.yaml)
[pipeline_people_ip.yaml](./sample/param/pipeline_people_ip.yaml)|[head-pose-estimation-adas-0001](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/head-pose-estimation-adas-0001)|
-|Object Detection| Object detection based on SSD-based trained models.|[pipeline_object.yaml](./sample/param/pipeline_object.yaml)
[pipeline_object_topic.yaml](./sample/param/pipeline_object_topic.yaml)|[mobilenet-ssd](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/public/mobilenet-ssd)|
+|Object Detection| Object detection based on SSD-based trained models.|[pipeline_object.yaml](./sample/param/pipeline_object.yaml)
[pipeline_object_topic.yaml](./sample/param/pipeline_object_topic.yaml)|[mobilenet-ssd](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/public/mobilenet-ssd)
[yolov5](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/111-yolov5-quantization-migration)
[yolov7](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/226-yolov7-optimization)
[yolov8](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/230-yolov8-optimization)|
|Vehicle and License Detection| Vehicle and license detection based on Intel models.|[pipeline_vehicle_detection.yaml](./sample/param/pipeline_vehicle_detection.yaml)|[vehicle-license-plate-detection-barrier-0106](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/vehicle-license-plate-detection-barrier-0106)
[vehicle-attributes-recognition-barrier-0039](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/vehicle-attributes-recognition-barrier-0039)
[license-plate-recognition-barrier-0001](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/license-plate-recognition-barrier-0001)|
-|Object Segmentation| Object segmentation.|[pipeline_segmentation.yaml](./sample/param/pipeline_segmentation.yaml)
[pipeline_segmentation_image.yaml](./sample/param/pipeline_segmentation_image.yaml)
[pipeline_video.yaml](./sample/param/pipeline_video.yaml)|[semantic-segmentation-adas-0001](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/semantic-segmentation-adas-0001)
[deeplabv3](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/public/deeplabv3)|
+|Object Segmentation - Semantic| semantic segmentation, assign a class label to each pixel in an image. |[pipeline_segmentation.yaml](./sample/param/pipeline_segmentation.yaml)
[pipeline_segmentation_image.yaml](./sample/param/pipeline_segmentation_image.yaml)
[pipeline_video.yaml](./sample/param/pipeline_video.yaml)|[semantic-segmentation-adas-0001](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/semantic-segmentation-adas-0001)
[deeplabv3](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/public/deeplabv3)|
+| Object Segmentation - Instance | Instance Segmentation, combination of semantic segmentation & object detection. | [pipeline_segmentation_instance.launch.yaml](./sample/param/pipeline_segmentation_instance.yaml) | [yolov8-seg](https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/230-yolov8-optimization)
[mask_rcnn_inception_v2_coco_2018_01_28](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/public/mask_rcnn_inception_resnet_v2_atrous_coco)|
|Person Attributes| Person attributes based on object detection.|[pipeline_person_attributes.yaml](./sample/param/pipeline_person_attributes.yaml)|[person-attributes-recognition-crossroad-0230](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/person-attributes-recognition-crossroad-0230)
[person-detection-retail-0013](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/person-detection-retail-0013)|
|Person Reidentification|Person reidentification based on object detection.|[pipeline_person_reidentification.yaml](./sample/param/pipeline_reidentification.yaml)|[person-detection-retail-0013](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/person-detection-retail-0013)
[person-reidentification-retail-0277](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/intel/person-reidentification-retail-0277)|
-|Object Segmentation Maskrcnn| Object segmentation and detection based on maskrcnn model.|[pipeline_segmentation_maskrcnn.yaml](./sample/param/pipeline_segmentation_maskrcnn.yaml)|[mask_rcnn_inception_v2_coco_2018_01_28](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/public/mask_rcnn_inception_resnet_v2_atrous_coco)|
+|Object Segmentation Maskrcnn| Object segmentation and detection based on maskrcnn model.[_Deprecated, it is recommended to use `object segementation - instance` for first try._]|[pipeline_segmentation_maskrcnn.yaml](./sample/param/pipeline_segmentation_maskrcnn.yaml)|[mask_rcnn_inception_v2_coco_2018_01_28](https://github.com/openvinotoolkit/open_model_zoo/tree/releases/2022/3/models/public/mask_rcnn_inception_resnet_v2_atrous_coco)|
@@ -212,6 +217,7 @@ OpenCV based image window is natively supported by the package.
To enable window, Image Window output should be added into the output choices in .yaml config file. Refer to [the config file guidance](./doc/quick_start/yaml_configuration_guide.md) for more information about checking/adding this feature in your launching.
## Demo Result Snapshots
+Demo Snapshots
For the snapshot of demo results, refer to the following picture.
* Face detection input from standard camera
@@ -225,6 +231,7 @@ For the snapshot of demo results, refer to the following picture.
* Person reidentification input from standard camera

+
# Installation and Launching
## Deploy in Local Environment
@@ -240,11 +247,28 @@ For the snapshot of demo results, refer to the following picture.
* OpenVINO api 2.0: Refer to the OpenVINO document for [OpenVINO_api_2.0](https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html) for latest api 2.0 transition guide.
# FAQ
-* [How to get the IR file for yolov5?](./doc/quick_start/tutorial_for_yolov5_converted.md)
+* How to get the IR file for [yolov5](./doc/quick_start/tutorial_for_yolov5_converted.md) | [yolov7](./doc/quick_start/tutorial_for_yolov7_converted.md) | [yolov8](./doc/quick_start/tutorial_for_yolov8_converted.md) ?
* [How to build OpenVINO by source?](https://github.com/openvinotoolkit/openvino/wiki#how-to-build)
* [How to build RealSense by source?](https://github.com/IntelRealSense/librealsense/blob/master/doc/installation.md)
* [What is the basic command of Docker CLI?](https://docs.docker.com/engine/reference/commandline/docker/)
* [What is the canonical C++ API for interacting with ROS?](https://docs.ros2.org/latest/api/rclcpp/)
+ How to change logging level?
+ This project provides to logging levels: *DEBUG* & *INFO*.
+ You may follow the steps to change logging level:
+
+ - Update ./openvino_wrapper_lib/CMakeLists.txt by uncommenting (for DEBUG level) or commenting (for INFO level) this line:
+ ```code
+ #add_definitions(-DLOG_LEVEL_DEBUG)
+ ```
+ - Rebuild project
+ Refer corresponding quick-start documents to rebuild this project. e.g.:
+ ```code
+ source /opt/ros//setup.bash
+ colcon build --symlink-install
+ ```
+ - Launch OpenVINO Node
+ You will see the logging is changed.
+
# Feedback
* Report questions, issues and suggestions, using: [issue](https://github.com/intel/ros2_openvino_toolkit/issues).
diff --git a/data/labels/object_segmentation/frozen_inference_graph.labels b/data/labels/object_segmentation/frozen_inference_graph.labels
index b4427edc..744de27d 100644
--- a/data/labels/object_segmentation/frozen_inference_graph.labels
+++ b/data/labels/object_segmentation/frozen_inference_graph.labels
@@ -1,3 +1,4 @@
+_background
person
bicycle
car
@@ -87,4 +88,4 @@ vase
scissors
teddy_bear
hair_drier
-toothbrush
\ No newline at end of file
+toothbrush
diff --git a/openvino_param_lib/src/param_manager.cpp b/openvino_param_lib/src/param_manager.cpp
index 89527c95..bebf3d7f 100644
--- a/openvino_param_lib/src/param_manager.cpp
+++ b/openvino_param_lib/src/param_manager.cpp
@@ -191,6 +191,7 @@ void ParamManager::print() const
for (auto & infer : pipeline.infers) {
slog::info << "\t\tName: " << infer.name << slog::endl;
slog::info << "\t\tModel: " << infer.model << slog::endl;
+ slog::info << "\t\tModel-Type: " << infer.model_type << slog::endl;
slog::info << "\t\tEngine: " << infer.engine << slog::endl;
slog::info << "\t\tLabel: " << infer.label << slog::endl;
slog::info << "\t\tBatch: " << infer.batch << slog::endl;
diff --git a/openvino_wrapper_lib/CMakeLists.txt b/openvino_wrapper_lib/CMakeLists.txt
index f6ea6126..131607a5 100644
--- a/openvino_wrapper_lib/CMakeLists.txt
+++ b/openvino_wrapper_lib/CMakeLists.txt
@@ -30,7 +30,7 @@ set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
####################################
## to get verbose log,
## then, uncomment below line
-add_definitions(-DLOG_LEVEL_DEBUG)
+#add_definitions(-DLOG_LEVEL_DEBUG)
####################################
# environment variable OpenVINO_DIR can be use instead of relaive path to specify location of configuration file
@@ -189,6 +189,7 @@ add_library(${PROJECT_NAME} SHARED
src/inferences/head_pose_detection.cpp
src/inferences/object_segmentation.cpp
src/inferences/object_segmentation_maskrcnn.cpp
+ src/inferences/object_segmentation_instance.cpp
src/inferences/person_reidentification.cpp
src/inferences/person_attribs_detection.cpp
#src/inferences/landmarks_detection.cpp
@@ -209,6 +210,8 @@ add_library(${PROJECT_NAME} SHARED
src/models/head_pose_detection_model.cpp
src/models/object_segmentation_model.cpp
src/models/object_segmentation_maskrcnn_model.cpp
+ src/models/object_segmentation_instance_model.cpp
+ src/models/object_segmentation_instance_maskrcnn_model.cpp
src/models/person_reidentification_model.cpp
src/models/person_attribs_detection_model.cpp
#src/models/landmarks_detection_model.cpp
@@ -217,6 +220,7 @@ add_library(${PROJECT_NAME} SHARED
src/models/license_plate_detection_model.cpp
src/models/object_detection_ssd_model.cpp
src/models/object_detection_yolov5_model.cpp
+ src/models/object_detection_yolov8_model.cpp
src/outputs/image_window_output.cpp
src/outputs/ros_topic_output.cpp
src/outputs/rviz_output.cpp
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation_instance.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation_instance.hpp
new file mode 100644
index 00000000..f1dbc548
--- /dev/null
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation_instance.hpp
@@ -0,0 +1,151 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef OPENVINO_WRAPPER_LIB__INFERENCES__OBJECT_SEGMENTATION_INSTANCE_HPP_
+#define OPENVINO_WRAPPER_LIB__INFERENCES__OBJECT_SEGMENTATION_INSTANCE_HPP_
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "openvino_wrapper_lib/models/object_segmentation_instance_model.hpp"
+#include "openvino_wrapper_lib/engines/engine.hpp"
+#include "openvino_wrapper_lib/inferences/base_inference.hpp"
+#include "openvino/openvino.hpp"
+#include "opencv2/opencv.hpp"
+// namespace
+namespace openvino_wrapper_lib
+{
+/**
+ * @class ObjectSegmentationInstanceResult
+ * @brief Class for storing and processing object segmentation result.
+ */
+class ObjectSegmentationInstanceResult : public Result
+{
+public:
+ friend class ObjectSegmentationInstance;
+ explicit ObjectSegmentationInstanceResult(const cv::Rect & location);
+ inline std::string getLabel() const
+ {
+ return label_;
+ }
+ inline void setLabel(const std::string& label)
+ {
+ label_ = label;
+ }
+ /**
+ * @brief Get the confidence that the detected area is a face.
+ * @return The confidence value.
+ */
+ inline float getConfidence() const
+ {
+ return confidence_;
+ }
+ inline void setConfidence(float conf)
+ {
+ confidence_ = conf;
+ }
+ inline cv::Mat getMask() const
+ {
+ return mask_;
+ }
+ inline void setMask(const cv::Mat& mask)
+ {
+ mask_ = mask;
+ }
+
+private:
+ std::string label_ = "";
+ float confidence_ = -1;
+ cv::Mat mask_;
+};
+/**
+ * @class ObjectSegmentation
+ * @brief Class to load object segmentation model and perform object segmentation.
+ */
+class ObjectSegmentationInstance : public BaseInference
+{
+public:
+ using Result = openvino_wrapper_lib::ObjectSegmentationInstanceResult;
+ explicit ObjectSegmentationInstance(double);
+ ~ObjectSegmentationInstance() override;
+ /**
+ * @brief Load the object segmentation model.
+ */
+ void loadNetwork(std::shared_ptr);
+ /**
+ * @brief Enqueue a frame to this class.
+ * The frame will be buffered but not infered yet.
+ * @param[in] frame The frame to be enqueued.
+ * @param[in] input_frame_loc The location of the enqueued frame with respect
+ * to the frame generated by the input device.
+ * @return Whether this operation is successful.
+ */
+ bool enqueue(const cv::Mat &, const cv::Rect &) override;
+
+ /**
+ * @brief Start inference for all buffered frames.
+ * @return Whether this operation is successful.
+ */
+ bool submitRequest() override;
+ /**
+ * @brief This function will fetch the results of the previous inference and
+ * stores the results in a result buffer array. All buffered frames will be
+ * cleared.
+ * @return Whether the Inference object fetches a result this time
+ */
+ bool fetchResults() override;
+ /**
+ * @brief Get the length of the buffer result array.
+ * @return The length of the buffer result array.
+ */
+ int getResultsLength() const override;
+ /**
+ * @brief Get the location of result with respect
+ * to the frame generated by the input device.
+ * @param[in] idx The index of the result.
+ */
+ const openvino_wrapper_lib::Result * getLocationResult(int idx) const override;
+ /**
+ * @brief Show the observed detection result either through image window
+ or ROS topic.
+ */
+ void observeOutput(const std::shared_ptr & output);
+ /**
+ * @brief Get the name of the Inference instance.
+ * @return The name of the Inference instance.
+ */
+ const std::string getName() const override;
+ const std::vector getFilteredROIs(
+ const std::string filter_conditions) const override;
+
+private:
+ std::shared_ptr valid_model_;
+ std::vector results_;
+ int width_ = 0;
+ int height_ = 0;
+ double show_output_thresh_ = 0;
+
+ std::vector colors_ = {
+ {128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190},
+ {153, 153, 153}, {30, 170, 250}, {0, 220, 220}, {35, 142, 107}, {152, 251, 152},
+ {180, 130, 70}, {60, 20, 220}, {0, 0, 255}, {142, 0, 0}, {70, 0, 0},
+ {100, 60, 0}, {90, 0, 0}, {230, 0, 0}, {32, 11, 119}, {0, 74, 111},
+ {81, 0, 81}
+ };
+};
+} // namespace openvino_wrapper_lib
+#endif // OPENVINO_WRAPPER_LIB__INFERENCES__OBJECT_SEGMENTATION_HPP_
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/attributes/base_attribute.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/attributes/base_attribute.hpp
index 7f36c061..abf8b3aa 100644
--- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/attributes/base_attribute.hpp
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/attributes/base_attribute.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2018-2022 Intel Corporation
+// Copyright (c) 2018-2023 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -39,14 +39,24 @@ class ModelAttribute
{
public:
using Ptr = std::shared_ptr;
+ const char* DefaultInputName {"input0"};
+ const char* DefaultOutputName = "output0";
struct ModelAttr {
- int max_proposal_count = 0;
- int object_size = 0;
+ // Input Tensor Size
int input_height = 0;
int input_width = 0;
- std::string model_name;
+
+ //Input/Output Tensor Info
+ int input_tensor_count = 1; // The number of input tensors
+ int output_tensor_count = 1; // The number of output tensors
+ bool has_confidence_output = true; //Yolov5~7 have a float for confidence, while yolov8 hasn't.
+ bool need_transpose = false; // If the output tensor needs transpose
+ int max_proposal_count = 0; // The max number of objects in inference output tensor
+ int object_size = 0; //The size of each object in inference output tensor
std::map input_names;
std::map output_names;
+
+ std::string model_name;
std::vector labels;
};
@@ -62,12 +72,19 @@ class ModelAttribute
}
inline void printAttribute()
{
- slog::info << "----Attributes for Model " << attr_.model_name << "----" << slog::endl;
+ slog::info << "-------------------- Attributes for Model ----------------------" << slog::endl;
slog::info << "| model_name: " << attr_.model_name << slog::endl;
slog::info << "| max_proposal_count: " << attr_.max_proposal_count << slog::endl;
slog::info << "| object_size: " << attr_.object_size << slog::endl;
slog::info << "| input_height: " << attr_.input_height << slog::endl;
slog::info << "| input_width: " << attr_.input_width << slog::endl;
+ slog::info << "| input_tensor_count: " << attr_.input_tensor_count << slog::endl;
+ slog::info << "| output_tensor_count: " << attr_.output_tensor_count << slog::endl;
+ slog::info << "| need_transpose (max_proposal_count < object_size): " << std::boolalpha
+ << attr_.need_transpose << slog::endl;
+ slog::info << "| has_confidence_output: " << std::boolalpha << attr_.has_confidence_output <<
+ slog::endl;
+
slog::info << "| input_names: " << slog::endl;
for (auto & item: attr_.input_names) {
slog::info << "| " << item.first << "-->" << item.second << slog::endl;
@@ -77,13 +94,31 @@ class ModelAttribute
slog::info << "| " << item.first << "-->" << item.second << slog::endl;
}
+ slog::info << "| lables:" << slog::endl;
+ for (size_t i = 0; i(attr_.input_names.size())){
+ slog::info << "--------" << slog::endl;
+ slog::warn << "The count of input_tensor(s) is not aligned with input names!"
+ << slog::endl;
+ }
+ if( attr_.output_tensor_count != static_cast(attr_.output_names.size())){
+ slog::info << "--------" << slog::endl;
+ slog::warn << "The count of output_tensor(s) is not aligned with output names!"
+ << slog::endl;
+ }
+ slog::info << "-------------------- Attributes for Model ----------------------" << slog::endl;
}
virtual bool updateLayerProperty(
@@ -100,7 +135,7 @@ class ModelAttribute
attr_.model_name = name;
}
- inline std::string getInputName(std::string name = "input") const
+ inline std::string getInputName(std::string name = "input0") const
{
auto it = attr_.input_names.find(name);
if(it == attr_.input_names.end()){
@@ -111,7 +146,7 @@ class ModelAttribute
return it->second;
}
- inline std::string getOutputName(std::string name = "output") const
+ inline std::string getOutputName(std::string name = "output0") const
{
auto it = attr_.output_names.find(name);
if(it == attr_.output_names.end()){
@@ -135,10 +170,10 @@ class ModelAttribute
inline void loadLabelsFromFile(const std::string file_path)
{
std::ifstream input_file(file_path);
- std::copy(std::istream_iterator(input_file),
- std::istream_iterator(),
- std::back_inserter(attr_.labels));
+ for(std::string name; std::getline(input_file, name);){
+ attr_.labels.push_back(name);
}
+ }
inline std::vector& getLabels()
{
@@ -150,6 +185,11 @@ class ModelAttribute
attr_.input_names[key] = value;
}
+ inline const std::string getInputInfo(std::string key)
+ {
+ return attr_.input_names[key];
+ }
+
inline void addOutputInfo(std::string key, std::string value)
{
attr_.output_names[key] = value;
@@ -185,6 +225,72 @@ class ModelAttribute
attr_.object_size = size;
}
+ inline void setHasConfidenceOutput(const bool has)
+ {
+ attr_.has_confidence_output = has;
+ }
+
+ inline bool hasConfidenceOutput() const
+ {
+ return attr_.has_confidence_output;
+ }
+
+ inline void setCountOfInputs(const int count)
+ {
+ attr_.input_tensor_count = count;
+ }
+
+ inline int getCountOfInputs() const
+ {
+ return attr_.input_tensor_count;
+ }
+
+ inline void setCountOfOutputs(const int count)
+ {
+ attr_.output_tensor_count = count;
+ }
+
+ inline int getCountOfOutputs() const
+ {
+ return attr_.output_tensor_count;
+ }
+
+ inline void setTranspose(bool trans)
+ {
+ attr_.need_transpose = trans;
+ }
+
+ inline bool needTranspose() const
+ {
+ return attr_.need_transpose;
+ }
+
+ inline bool _renameMapKeyByValue(std::map& map,
+ const std::string& value, const std::string& new_key)
+ {
+ for (auto& item: map){
+ auto n = item.second.find(value);
+ if (std::string::npos != n) {
+ //if(item.second.contains(value)){
+ auto nh = map.extract(item.first);
+ nh.key() = new_key;
+ map.insert(std::move(nh));
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ inline bool retagOutputByValue(const std::string& value, const std::string& new_tag)
+ {
+ return _renameMapKeyByValue(attr_.output_names, value, new_tag);
+ }
+
+ inline bool retagInputByValue(const std::string& value, const std::string& new_tag)
+ {
+ return _renameMapKeyByValue(attr_.input_names, value, new_tag);
+ }
protected:
ModelAttr attr_;
std::string input_tensor_name_;
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/base_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/base_model.hpp
index ce0a0ac0..fbc84dcb 100644
--- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/base_model.hpp
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/base_model.hpp
@@ -107,6 +107,12 @@ namespace Models
* @param[in] network_reader The reader of the network to be set.
*/
virtual bool updateLayerProperty(std::shared_ptr& network_reader) = 0;
+
+ virtual bool matToBlob(
+ const cv::Mat &orig_image, const cv::Rect &, float scale_factor,
+ int batch_index, const std::shared_ptr &engine);
+
+ cv::Mat extendFrameToInputRatio(const cv::Mat);
ov::Core engine;
std::shared_ptr model_;
void setFrameSize(const int &w, const int &h)
@@ -119,11 +125,57 @@ namespace Models
return frame_size_;
}
+ inline void setFrameResizeeRatioWidth(const float r)
+ {
+ frame_resize_ratio_width_ = r;
+ }
+
+ inline void setFrameResizeeRatioHeight(const float r)
+ {
+ frame_resize_ratio_height_ = r;
+ }
+
+ inline float getFrameResizeRatioWidth() const
+ {
+ return frame_resize_ratio_width_;
+ }
+
+ inline float getFrameResizeRatioHeight() const
+ {
+ return frame_resize_ratio_height_;
+ }
+
+ inline void setKeepInputShapeRatio(bool keep)
+ {
+ keep_input_shape_ratio_ = keep;
+ }
+
+ inline bool isKeepInputRatio() const
+ {
+ return keep_input_shape_ratio_;
+ }
+
+ inline void setExpectedFrameSize(cv::Size expect)
+ {
+ expected_frame_size_ = expect;
+ }
+
+ inline cv::Size getExpectedFrameSize() const
+ {
+ return expected_frame_size_;
+ }
+
private:
int max_batch_size_;
std::string model_loc_;
std::string label_loc_;
+
+ //Information about Input Data
cv::Size frame_size_;
+ cv::Size expected_frame_size_ {224, 224};
+ float frame_resize_ratio_width_ = 1.0;
+ float frame_resize_ratio_height_ = 1.0;
+ bool keep_input_shape_ratio_ = false;
};
class ObjectDetectionModel : public BaseModel
@@ -135,9 +187,6 @@ namespace Models
std::vector &result,
const float &confidence_thresh = 0.3,
const bool &enable_roi_constraint = false) = 0;
- virtual bool matToBlob(
- const cv::Mat &orig_image, const cv::Rect &, float scale_factor,
- int batch_index, const std::shared_ptr &engine) = 0;
};
} // namespace Models
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_yolov5_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_yolov5_model.hpp
index 8e2f177e..e5cd757e 100644
--- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_yolov5_model.hpp
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_yolov5_model.hpp
@@ -53,21 +53,12 @@ class ObjectDetectionYolov5Model : public ObjectDetectionModel
const cv::Mat & frame,
const cv::Rect & input_frame_loc) override;
- bool matToBlob(
- const cv::Mat & orig_image, const cv::Rect &, float scale_factor,
- int batch_index, const std::shared_ptr & engine) override;
-
/**
* @brief Get the name of this detection model.
* @return Name of the model.
*/
const std::string getModelCategory() const override;
bool updateLayerProperty(std::shared_ptr&) override;
- static Resize_t pre_process_ov(const cv::Mat &input_image);
-
- cv::Mat input_image;
- Resize_t resize_img;
-
};
} // namespace Models
#endif // OPENVINO_WRAPPER_LIB__MODELS__OBJECT_DETECTION_YOLOV5_MODEL_HPP_
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_yolov8_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_yolov8_model.hpp
new file mode 100644
index 00000000..c3cdd828
--- /dev/null
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_yolov8_model.hpp
@@ -0,0 +1,35 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef OPENVINO_WRAPPER_LIB__MODELS__OBJECT_DETECTION_YOLOV8_MODEL_HPP_
+#define OPENVINO_WRAPPER_LIB__MODELS__OBJECT_DETECTION_YOLOV8_MODEL_HPP_
+#include
+#include
+#include
+#include "openvino_wrapper_lib/models/object_detection_yolov5_model.hpp"
+
+namespace Models
+{
+
+class ObjectDetectionYolov8Model : public ObjectDetectionYolov5Model
+{
+ using Result = openvino_wrapper_lib::ObjectDetectionResult;
+
+public:
+ explicit ObjectDetectionYolov8Model(const std::string& label_loc, const std::string & model_loc,
+ int batch_size = 1);
+
+};
+} // namespace Models
+#endif // OPENVINO_WRAPPER_LIB__MODELS__OBJECT_DETECTION_YOLOV8_MODEL_HPP_
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_instance_maskrcnn_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_instance_maskrcnn_model.hpp
new file mode 100644
index 00000000..8b32826d
--- /dev/null
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_instance_maskrcnn_model.hpp
@@ -0,0 +1,43 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#ifndef OPENVINO_WRAPPER_LIB__MODELS__OBJECT_SEGMENTATION_INSTANCE_MASKRCNN_MODEL_HPP_
+#define OPENVINO_WRAPPER_LIB__MODELS__OBJECT_SEGMENTATION_INSTANCE_MASKRCNN_MODEL_HPP_
+#include
+#include
+#include "openvino_wrapper_lib/models/base_model.hpp"
+
+namespace Models
+{
+
+/**
+ * @class ObjectSegmentationInstanceMaskrcnnModel
+ * @brief This class generates the object segmentation model.
+ */
+class ObjectSegmentationInstanceMaskrcnnModel : public ObjectSegmentationInstanceModel
+{
+ using Result = openvino_wrapper_lib::ObjectSegmentationInstanceResult;
+public:
+ ObjectSegmentationInstanceMaskrcnnModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
+
+ bool fetchResults(
+ const std::shared_ptr & engine,
+ std::vector & results,
+ const float & confidence_thresh = 0.3,
+ const bool & enable_roi_constraint = false);
+
+ bool updateLayerProperty(std::shared_ptr&) override;
+
+};
+} // namespace Models
+#endif // OPENVINO_WRAPPER_LIB__MODELS__OBJECT_SEGMENTATION_INSTANCE_MASKRCNN_MODEL_HPP_
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_instance_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_instance_model.hpp
new file mode 100644
index 00000000..2a566197
--- /dev/null
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_instance_model.hpp
@@ -0,0 +1,56 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#ifndef OPENVINO_WRAPPER_LIB__MODELS__OBJECT_SEGMENTATION_INSTANCE_MODEL_HPP_
+#define OPENVINO_WRAPPER_LIB__MODELS__OBJECT_SEGMENTATION_INSTANCE_MODEL_HPP_
+#include
+#include
+#include "openvino_wrapper_lib/models/base_model.hpp"
+
+namespace openvino_wrapper_lib
+{
+ class ObjectSegmentationInstanceResult;
+}
+
+namespace Models
+{
+
+/**
+ * @class ObjectSegmentationInstanceModel
+ * @brief This class generates the object segmentation model.
+ */
+class ObjectSegmentationInstanceModel : public BaseModel
+{
+ using Result = openvino_wrapper_lib::ObjectSegmentationInstanceResult;
+public:
+ ObjectSegmentationInstanceModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1);
+
+ virtual bool fetchResults(
+ const std::shared_ptr & engine,
+ std::vector & results,
+ const float & confidence_thresh = 0.3,
+ const bool & enable_roi_constraint = false);
+
+ bool enqueue(const std::shared_ptr & ,const cv::Mat &,
+ const cv::Rect & ) override;
+
+ /**
+ * @brief Get the name of this segmentation model.
+ * @return Name of the model.
+ */
+ const std::string getModelCategory() const override;
+ virtual bool updateLayerProperty(std::shared_ptr&) override;
+
+};
+} // namespace Models
+#endif // OPENVINO_WRAPPER_LIB__MODELS__OBJECT_SEGMENTATION_INSTANCE_MODEL_HPP_
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/base_output.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/base_output.hpp
index 67971a47..150c0a69 100644
--- a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/base_output.hpp
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/base_output.hpp
@@ -51,6 +51,7 @@
#include "openvino_wrapper_lib/inferences/vehicle_attribs_detection.hpp"
#include "openvino_wrapper_lib/inferences/license_plate_detection.hpp"
#include "openvino_wrapper_lib/inferences/object_segmentation_maskrcnn.hpp"
+#include "openvino_wrapper_lib/inferences/object_segmentation_instance.hpp"
#include "opencv2/opencv.hpp"
class Pipeline;
@@ -115,6 +116,12 @@ class BaseOutput
virtual void accept(const std::vector &)
{
}
+ /**
+ * @brief Generate output content according to the object segmentation result for instance models.
+ */
+ virtual void accept(const std::vector &)
+ {
+ }
/**
* @brief Generate output content according to the object detection result.
*/
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/image_window_output.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/image_window_output.hpp
index d7c39ea1..2ee11789 100644
--- a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/image_window_output.hpp
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/image_window_output.hpp
@@ -104,6 +104,12 @@ class ImageWindowOutput : public BaseOutput
* @param[in] An obejct segmentation result objetc.
*/
void accept(const std::vector &) override;
+ /**
+ * @brief Generate image window output content according to
+ * the object segmentation instance result.
+ * @param[in] An obejct segmentation result objetc.
+ */
+ void accept(const std::vector &) override;
/**
* @brief Generate image window output content according to
* the face detection result.
@@ -152,6 +158,7 @@ class ImageWindowOutput : public BaseOutput
void mergeMask(const std::vector &);
void mergeMask(const std::vector &);
+ void mergeMask(const std::vector &);
struct OutputData
{
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/ros_topic_output.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/ros_topic_output.hpp
index 74285c0e..ff3dc28d 100644
--- a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/ros_topic_output.hpp
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/ros_topic_output.hpp
@@ -120,6 +120,12 @@ class RosTopicOutput : public BaseOutput
* @param[in] results a bundle of object segmentation maskrcnn results.
*/
void accept(const std::vector &) override;
+ /**
+ * @brief Generate ros topic infomation according to
+ * the object segmentation result.
+ * @param[in] results a bundle of object segmentation maskrcnn results.
+ */
+ void accept(const std::vector &) override;
/**
* @brief Generate ros topic infomation according to
* the object detection result.
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_manager.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_manager.hpp
index e4a3d485..b4bef25d 100644
--- a/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_manager.hpp
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_manager.hpp
@@ -127,6 +127,8 @@ class PipelineManager
std::shared_ptr
createObjectSegmentationMaskrcnn(const Params::ParamManager::InferenceRawData & infer);
std::shared_ptr
+ createObjectSegmentationInstance(const Params::ParamManager::InferenceRawData & infer);
+ std::shared_ptr
createPersonReidentification(const Params::ParamManager::InferenceRawData & infer);
std::shared_ptr
createPersonAttribsDetection(const Params::ParamManager::InferenceRawData & infer);
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_params.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_params.hpp
index bcb2991a..e1cf80a2 100644
--- a/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_params.hpp
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_params.hpp
@@ -54,8 +54,12 @@ const char kInferTpye_HeadPoseEstimation[] = "HeadPoseEstimation";
const char kInferTpye_ObjectDetection[] = "ObjectDetection";
const char kInferTpye_ObjectSegmentation[] = "ObjectSegmentation";
const char kInferTpye_ObjectSegmentationMaskrcnn[] = "ObjectSegmentationMaskrcnn";
+const char kInferTpye_ObjectSegmentationInstance[] = "ObjectSegmentationInstance";
+const char kInferTpye_ObjectSegmentationTypeYolo[] = "yolo";
+const char kInferTpye_ObjectSegmentationTypeMaskrcnn[] = "maskrcnn";
const char kInferTpye_ObjectDetectionTypeSSD[] = "SSD";
const char kInferTpye_ObjectDetectionTypeYolov5[] = "yolov5";
+const char kInferTpye_ObjectDetectionTypeYolov8[] = "yolov8";
const char kInferTpye_PersonReidentification[] = "PersonReidentification";
const char kInferTpye_PersonAttribsDetection[] = "PersonAttribsDetection";
const char kInferTpye_LandmarksDetection[] = "LandmarksDetection";
diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/utils/common.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/utils/common.hpp
new file mode 100644
index 00000000..75877d44
--- /dev/null
+++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/utils/common.hpp
@@ -0,0 +1,385 @@
+// Copyright (C) 2018-2019 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+/**
+ * @brief a header file with common samples functionality
+ * @file common.hpp
+ */
+
+#pragma once
+
+#include
+#include