diff --git a/openvino_param_lib/src/param_manager.cpp b/openvino_param_lib/src/param_manager.cpp index 89527c95..4ab38225 100644 --- a/openvino_param_lib/src/param_manager.cpp +++ b/openvino_param_lib/src/param_manager.cpp @@ -99,9 +99,9 @@ void operator>>(const YAML::Node & node, ParamManager::InferenceRawData & infer) YAML_PARSE(node, "batch", infer.batch) YAML_PARSE(node, "confidence_threshold", infer.confidence_threshold) YAML_PARSE(node, "enable_roi_constraint", infer.enable_roi_constraint) - if (infer.model_type.size() == 0) { - infer.model_type = "SSD"; - } + // if (infer.model_type.size() == 0) { + // infer.model_type = "SSD"; + // } slog::info << "Inference Params:name=" << infer.name << slog::endl; } diff --git a/openvino_wrapper_lib/CMakeLists.txt b/openvino_wrapper_lib/CMakeLists.txt index f6ea6126..ee85a667 100644 --- a/openvino_wrapper_lib/CMakeLists.txt +++ b/openvino_wrapper_lib/CMakeLists.txt @@ -20,6 +20,7 @@ project(openvino_wrapper_lib) ## to use C++17 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}") #################################### diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/age_gender_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/age_gender_detection.hpp index 865348f5..c5222d25 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/age_gender_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/age_gender_detection.hpp @@ -75,12 +75,13 @@ class AgeGenderDetection : public BaseInference { public: using Result = openvino_wrapper_lib::AgeGenderResult; - AgeGenderDetection(); - ~AgeGenderDetection() override; + AgeGenderDetection() {}; + ~AgeGenderDetection() override {}; + /** * @brief Load the age gender detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/base_inference.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/base_inference.hpp index 318fbeac..bf0e4761 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/base_inference.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/base_inference.hpp @@ -22,7 +22,9 @@ #include #include #include +#include "openvino_param_lib/param_manager.hpp" #include "openvino_wrapper_lib/engines/engine.hpp" +#include "openvino_wrapper_lib/engines/engine_manager.hpp" #include "openvino_wrapper_lib/models/base_model.hpp" #include "openvino_wrapper_lib/slog.hpp" #include "openvino/openvino.hpp" @@ -93,13 +95,21 @@ class Result class BaseInference { public: - BaseInference(); - virtual ~BaseInference(); + BaseInference() {}; + virtual ~BaseInference() {}; + + virtual void init(const Params::ParamManager::InferenceRawData &val) {}; /** * @brief load the Engine instance that contains the request for * running netwrok on target calculation device. */ void loadEngine(std::shared_ptr engine); + + /** + * @brief Load the face detection model. + */ + virtual void loadNetwork(const std::shared_ptr) = 0; + /** * @brief Get the loaded Engine instance. * @return The loaded Engine instance. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/emotions_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/emotions_detection.hpp index 38d50fbe..9d9d337c 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/emotions_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/emotions_detection.hpp @@ -65,12 +65,12 @@ class EmotionsDetection : public BaseInference { public: using Result = openvino_wrapper_lib::EmotionsResult; - EmotionsDetection(); - ~EmotionsDetection() override; + EmotionsDetection() {}; + ~EmotionsDetection() override {}; /** * @brief Load the emotin detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/face_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/face_detection.hpp index 6c18adbe..32997ebf 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/face_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/face_detection.hpp @@ -53,7 +53,8 @@ class FaceDetectionResult : public ObjectDetectionResult class FaceDetection : public ObjectDetection { public: - explicit FaceDetection(bool, double); + FaceDetection() : ObjectDetection() {}; + ~FaceDetection() override {}; }; } // namespace openvino_wrapper_lib #endif // OPENVINO_WRAPPER_LIB__INFERENCES__FACE_DETECTION_HPP_ diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/face_reidentification.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/face_reidentification.hpp index 7175f3be..24e71f7c 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/face_reidentification.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/face_reidentification.hpp @@ -54,12 +54,18 @@ class FaceReidentification : public BaseInference { public: using Result = openvino_wrapper_lib::FaceReidentificationResult; - explicit FaceReidentification(double); - ~FaceReidentification() override; + FaceReidentification() {}; + ~FaceReidentification() override {}; + + /** + * @brief initialize params + */ + void init(const Params::ParamManager::InferenceRawData &val) override; + /** * @brief Load the face reidentification model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/head_pose_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/head_pose_detection.hpp index 1a0ebc4f..e528bb16 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/head_pose_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/head_pose_detection.hpp @@ -79,12 +79,13 @@ class HeadPoseDetection : public BaseInference { public: using Result = openvino_wrapper_lib::HeadPoseResult; - HeadPoseDetection(); - ~HeadPoseDetection() override; + HeadPoseDetection() {}; + ~HeadPoseDetection() override {}; + /** * @brief Load the headpose detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/landmarks_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/landmarks_detection.hpp index fe7a34e6..55c7a254 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/landmarks_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/landmarks_detection.hpp @@ -54,12 +54,12 @@ class LandmarksDetection : public BaseInference { public: using Result = openvino_wrapper_lib::LandmarksDetectionResult; - LandmarksDetection(); - ~LandmarksDetection() override; + LandmarksDetection() {}; + ~LandmarksDetection() override {}; /** * @brief Load the landmarks detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/license_plate_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/license_plate_detection.hpp index 1d9ef900..1908abaf 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/license_plate_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/license_plate_detection.hpp @@ -54,12 +54,12 @@ class LicensePlateDetection : public BaseInference { public: using Result = openvino_wrapper_lib::LicensePlateDetectionResult; - LicensePlateDetection(); - ~LicensePlateDetection() override; + LicensePlateDetection() {}; + ~LicensePlateDetection() override {}; /** * @brief Load the license plate detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_detection.hpp index 47b7cc68..b405d2f4 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_detection.hpp @@ -72,7 +72,7 @@ class ObjectDetectionResult : public Result return this->confidence_ > s2.confidence_; } -private: +protected: std::string label_ = ""; float confidence_ = -1; }; @@ -103,7 +103,7 @@ class ObjectDetectionResultFilter : public BaseFilter */ std::vector getFilteredLocations() override; -private: +protected: /** * @brief Decide whether a result is valid for label filter condition. * @param[in] Result to be decided, filter operator, target label value. @@ -142,12 +142,17 @@ class ObjectDetection : public BaseInference public: using Result = openvino_wrapper_lib::ObjectDetectionResult; using Filter = openvino_wrapper_lib::ObjectDetectionResultFilter; - explicit ObjectDetection(bool, double); - ~ObjectDetection() override; + ObjectDetection() {}; + ~ObjectDetection() override {}; + + /** + * @brief initialize params + */ + void init(const Params::ParamManager::InferenceRawData &val) override; /** * @brief Load the face detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. @@ -195,7 +200,7 @@ class ObjectDetection : public BaseInference */ static double calcIoU(const cv::Rect & box_1, const cv::Rect & box_2); -private: +protected: std::shared_ptr valid_model_; std::shared_ptr result_filter_; std::vector results_; diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation.hpp index a450c567..66a79c32 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation.hpp @@ -72,12 +72,17 @@ class ObjectSegmentation : public BaseInference { public: using Result = openvino_wrapper_lib::ObjectSegmentationResult; - explicit ObjectSegmentation(double); - ~ObjectSegmentation() override; + ObjectSegmentation() {}; + ~ObjectSegmentation() override {}; + + /** + * @brief initialize params + */ + void init(const Params::ParamManager::InferenceRawData &val) override; /** * @brief Load the object segmentation model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation_maskrcnn.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation_maskrcnn.hpp index 7954157b..ca137205 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation_maskrcnn.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/object_segmentation_maskrcnn.hpp @@ -72,12 +72,17 @@ class ObjectSegmentationMaskrcnn : public BaseInference { public: using Result = openvino_wrapper_lib::ObjectSegmentationMaskrcnnResult; - explicit ObjectSegmentationMaskrcnn(double); - ~ObjectSegmentationMaskrcnn() override; + ObjectSegmentationMaskrcnn() {}; + ~ObjectSegmentationMaskrcnn() override {}; + + /** + * @brief initialize params + */ + void init(const Params::ParamManager::InferenceRawData &val) override; /** * @brief Load the object segmentation model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/person_attribs_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/person_attribs_detection.hpp index f5a3c100..84a544d4 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/person_attribs_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/person_attribs_detection.hpp @@ -72,12 +72,17 @@ class PersonAttribsDetection : public BaseInference { public: using Result = openvino_wrapper_lib::PersonAttribsDetectionResult; - explicit PersonAttribsDetection(double); - ~PersonAttribsDetection() override; + + PersonAttribsDetection() {}; + ~PersonAttribsDetection() override {} + /** + * @brief initialize params + */ + void init(const Params::ParamManager::InferenceRawData &val) override; /** * @brief Load the person attributes detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/person_reidentification.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/person_reidentification.hpp index be6d55f8..76673432 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/person_reidentification.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/person_reidentification.hpp @@ -52,12 +52,16 @@ class PersonReidentification : public BaseInference { public: using Result = openvino_wrapper_lib::PersonReidentificationResult; - explicit PersonReidentification(double); - ~PersonReidentification() override; + PersonReidentification() {}; + ~PersonReidentification() override {} + /** + * @brief initialize params + */ + void init(const Params::ParamManager::InferenceRawData &val) override; /** * @brief Load the face detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/vehicle_attribs_detection.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/vehicle_attribs_detection.hpp index 575e99d1..4d8de56b 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/vehicle_attribs_detection.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inferences/vehicle_attribs_detection.hpp @@ -59,12 +59,12 @@ class VehicleAttribsDetection : public BaseInference { public: using Result = openvino_wrapper_lib::VehicleAttribsDetectionResult; - VehicleAttribsDetection(); - ~VehicleAttribsDetection() override; + VehicleAttribsDetection() {}; + ~VehicleAttribsDetection() override {}; /** * @brief Load the vehicle attributes detection model. */ - void loadNetwork(std::shared_ptr); + void loadNetwork(const std::shared_ptr) override; /** * @brief Enqueue a frame to this class. * The frame will be buffered but not infered yet. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/base_input.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/base_input.hpp index 79350653..af686bf6 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/base_input.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/base_input.hpp @@ -43,6 +43,7 @@ struct Config class BaseInputDevice : public Ros2Handler { public: + BaseInputDevice() = default; /** * @brief Initialize the input device, * for cameras, it will turn the camera on and get ready to read frames, @@ -50,6 +51,11 @@ class BaseInputDevice : public Ros2Handler * @return Whether the input device is successfully turned on. */ virtual bool initialize() = 0; + /** + * @brief Initialize the input device, + * @return Whether the input device is successfully setup. + */ + virtual bool initialize(const std::string &str) = 0; /** * @brief Initialize the input device with given width and height. * @return Whether the input device is successfully turned on. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/image_input.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/image_input.hpp index e1a7b6c9..facef84b 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/image_input.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/image_input.hpp @@ -32,6 +32,7 @@ namespace Input class Image : public BaseInputDevice { public: + Image() {}; explicit Image(const std::string &); /** * @brief Read an image file from the file path. @@ -39,6 +40,14 @@ class Image : public BaseInputDevice * @return Whether the input device is successfully turned on. */ bool initialize() override; + + /** + * @brief Read an image file from the file path. + * @param[in] An image file path. + * @return Whether the input device is successfully setup. + */ + bool initialize(const std::string &file) override {file_.assign(file); return initialize();}; + /** * @brief Initialize the input device with given width and height. * No implementation for Image class. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/image_topic.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/image_topic.hpp index cc5274fd..f3832dc0 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/image_topic.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/image_topic.hpp @@ -36,8 +36,9 @@ namespace Input class ImageTopic : public BaseInputDevice { public: - ImageTopic(rclcpp::Node::SharedPtr node = nullptr); + ImageTopic() {}; bool initialize() override; + bool initialize(const std::string &file) override { return initialize();}; bool initialize(size_t width, size_t height) override; bool read(cv::Mat * frame) override; diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/ip_camera.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/ip_camera.hpp index c497cf85..d112a924 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/ip_camera.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/ip_camera.hpp @@ -33,6 +33,7 @@ namespace Input class IpCamera : public BaseInputDevice { public: + IpCamera() {}; explicit IpCamera(const std::string & ip_uri) : ip_uri_(ip_uri) {} /** * @brief Initialize the input device, @@ -41,6 +42,13 @@ class IpCamera : public BaseInputDevice * @return Whether the input device is successfully turned on. */ bool initialize() override; + /** + * @brief Initialize the input device, + * for cameras, it will turn the camera on and get ready to read frames, + * for videos, it will open a video file. + * @return Whether the input device is successfully setup. + */ + bool initialize(const std::string &ip_uri) override {ip_uri_.assign(ip_uri); return initialize();}; /** * @brief Initialize the input device with given width and height. * @return Whether the input device is successfully turned on. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/realsense_camera.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/realsense_camera.hpp index 8752289c..7323ab04 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/realsense_camera.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/realsense_camera.hpp @@ -33,12 +33,20 @@ namespace Input class RealSenseCamera : public BaseInputDevice { public: + RealSenseCamera() {}; /** * @brief Initialize the input device, turn the * camera on and get ready to read frames. * @return Whether the input device is successfully turned on. */ bool initialize() override; + /** + * @brief Initialize the input device, + * @brief Initialize the input device, turn the + * camera on and get ready to read frames. + * @return Whether the input device is successfully setup. + */ + bool initialize(const std::string &ip_uri) override { return initialize();}; /** * @brief Initialize the input device with given width and height. * @return Whether the input device is successfully turned on. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/standard_camera.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/standard_camera.hpp index d5924551..4d747a4e 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/standard_camera.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/standard_camera.hpp @@ -40,6 +40,7 @@ namespace Input class StandardCamera : public BaseInputDevice { public: + StandardCamera() {}; /** * @brief Initialize the input device, * for cameras, it will turn the camera on and get ready to read frames, @@ -47,6 +48,13 @@ class StandardCamera : public BaseInputDevice * @return Whether the input device is successfully turned on. */ bool initialize() override; + /** + * @brief Initialize the input device, + * @brief Initialize the input device, turn the + * camera on and get ready to read frames. + * @return Whether the input device is successfully setup. + */ + bool initialize(const std::string &ip_uri) override { return initialize();}; /** * @brief Initialize the input device with given width and height. * @return Whether the input device is successfully turned on. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/video_input.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/video_input.hpp index c4ee9b10..b735f21b 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/video_input.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/inputs/video_input.hpp @@ -32,6 +32,7 @@ namespace Input class Video : public BaseInputDevice { public: + Video() {}; explicit Video(const std::string &); /** * @brief Read a video file from the file path. @@ -39,6 +40,12 @@ class Video : public BaseInputDevice * @return Whether the input device is successfully turned on. */ bool initialize() override; + /** + * @brief Read a video file from the file path. + * @param[in] An video file path. + * @return Whether the input device is successfully setup. + */ + bool initialize(const std::string &video) override {video_.assign(video); return initialize();}; /** * @brief Initialize the input device with given width and height. * No implementation for Video class. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/age_gender_detection_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/age_gender_detection_model.hpp index 564f93a3..6f113dc5 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/age_gender_detection_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/age_gender_detection_model.hpp @@ -32,7 +32,7 @@ namespace Models class AgeGenderDetectionModel : public BaseModel { public: - AgeGenderDetectionModel(const std::string& label_loc, const std::string& model_loc, int batch_size = 1); + AgeGenderDetectionModel() {}; /** * @brief Get the input name. * @return Input name. 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..8f436339 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 @@ -49,6 +49,8 @@ class ModelAttribute std::map output_names; std::vector labels; }; + + ModelAttribute() {}; ModelAttribute(const std::string model_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..66856331 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 @@ -30,6 +30,7 @@ #include #include +#include #include "openvino_wrapper_lib/slog.hpp" #include "openvino_wrapper_lib/models/attributes/base_attribute.hpp" @@ -63,7 +64,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& label_loc, const std::string& model_loc, int batch_size = 1); + BaseModel() {}; /** * @brief Get the maximum batch size of the model. @@ -77,7 +78,7 @@ namespace Models { max_batch_size_ = max_batch_size; } - + virtual bool enqueue( const std::shared_ptr &engine, const cv::Mat &frame, @@ -87,7 +88,7 @@ namespace Models * the network input, output size, check layer property and * set layer property. */ - void modelInit(); + void modelInit(const Params::ParamManager::InferenceRawData & param, bool use_def_batch = false, int batch_size = 1); /** * @brief Get the name of the model. * @return The name of the model. @@ -119,7 +120,7 @@ namespace Models return frame_size_; } - private: + protected: int max_batch_size_; std::string model_loc_; std::string label_loc_; @@ -129,7 +130,7 @@ namespace Models class ObjectDetectionModel : public BaseModel { public: - ObjectDetectionModel(const std::string& label_loc, const std::string& model_loc, int batch_size = 1); + ObjectDetectionModel() {}; virtual bool fetchResults( const std::shared_ptr &engine, std::vector &result, diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/emotion_detection_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/emotion_detection_model.hpp index 56c73665..518f8b78 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/emotion_detection_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/emotion_detection_model.hpp @@ -32,7 +32,7 @@ namespace Models class EmotionDetectionModel : public BaseModel { public: - EmotionDetectionModel(const std::string& label_loc, const std::string& model_loc, int batch_size = 1); + EmotionDetectionModel() {}; /** * @brief Get the name of this detection model. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/face_detection_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/face_detection_model.hpp index c4923a36..0601f69b 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/face_detection_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/face_detection_model.hpp @@ -32,7 +32,7 @@ namespace Models class FaceDetectionModel : public ObjectDetectionModel { public: - FaceDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + FaceDetectionModel() : ObjectDetectionModel(){}; //void checkLayerProperty(const InferenceEngine::CNNNetReader::Ptr &) override; /** * @brief Get the name of this detection model. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/face_reidentification_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/face_reidentification_model.hpp index 4eda2755..edad551e 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/face_reidentification_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/face_reidentification_model.hpp @@ -30,7 +30,7 @@ namespace Models class FaceReidentificationModel : public BaseModel { public: - FaceReidentificationModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + FaceReidentificationModel() {}; inline const std::string getInputName() {return input_;} inline const std::string getOutputName() {return output_;} /** diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/head_pose_detection_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/head_pose_detection_model.hpp index d815f125..113311be 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/head_pose_detection_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/head_pose_detection_model.hpp @@ -32,7 +32,7 @@ namespace Models class HeadPoseDetectionModel : public BaseModel { public: - HeadPoseDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + HeadPoseDetectionModel() {}; /** * @brief Get the output angle roll. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/landmarks_detection_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/landmarks_detection_model.hpp index 71a7244f..b79eded6 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/landmarks_detection_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/landmarks_detection_model.hpp @@ -29,7 +29,7 @@ namespace Models class LandmarksDetectionModel : public BaseModel { public: - LandmarksDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + LandmarksDetectionModel() {}; inline const std::string getInputName() {return input_;} inline const std::string getOutputName() {return output_;} /** diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/license_plate_detection_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/license_plate_detection_model.hpp index 76c2deed..d6560e65 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/license_plate_detection_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/license_plate_detection_model.hpp @@ -29,7 +29,7 @@ namespace Models class LicensePlateDetectionModel : public BaseModel { public: - LicensePlateDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + LicensePlateDetectionModel() {}; inline const std::string getInputName() {return input_;} inline const std::string getSeqInputName() {return seq_input_;} inline const std::string getOutputName() {return output_;} diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_ssd_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_ssd_model.hpp index 818414dd..85279011 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_ssd_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_detection_ssd_model.hpp @@ -32,7 +32,7 @@ class ObjectDetectionSSDModel : public ObjectDetectionModel using Result = openvino_wrapper_lib::ObjectDetectionResult; public: - ObjectDetectionSSDModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + ObjectDetectionSSDModel() {}; bool fetchResults( const std::shared_ptr & engine, 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..77b3c169 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 @@ -40,7 +40,7 @@ class ObjectDetectionYolov5Model : public ObjectDetectionModel using Result = openvino_wrapper_lib::ObjectDetectionResult; public: - ObjectDetectionYolov5Model(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + ObjectDetectionYolov5Model() {}; bool fetchResults( const std::shared_ptr & engine, diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_maskrcnn_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_maskrcnn_model.hpp index 49940225..2a24a38b 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_maskrcnn_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_maskrcnn_model.hpp @@ -29,7 +29,7 @@ namespace Models class ObjectSegmentationMaskrcnnModel : public BaseModel { public: - ObjectSegmentationMaskrcnnModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + ObjectSegmentationMaskrcnnModel() {}; inline int getMaxProposalCount() const { return max_proposal_count_; diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_model.hpp index 217ec132..079b0770 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/object_segmentation_model.hpp @@ -29,7 +29,7 @@ namespace Models class ObjectSegmentationModel : public BaseModel { public: - ObjectSegmentationModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + ObjectSegmentationModel() {}; inline int getMaxProposalCount() const { return max_proposal_count_; diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/person_attribs_detection_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/person_attribs_detection_model.hpp index d22e6a2d..fdc4a2e0 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/person_attribs_detection_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/person_attribs_detection_model.hpp @@ -29,7 +29,7 @@ namespace Models class PersonAttribsDetectionModel : public BaseModel { public: - PersonAttribsDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + PersonAttribsDetectionModel() {}; /** * @brief Get the name of this detection model. * @return Name of the model. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/person_reidentification_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/person_reidentification_model.hpp index 4b2937ff..95175088 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/person_reidentification_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/person_reidentification_model.hpp @@ -29,7 +29,7 @@ namespace Models class PersonReidentificationModel : public BaseModel { public: - PersonReidentificationModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + PersonReidentificationModel() {}; inline const std::string getInputName() {return input_;} inline const std::string getOutputName() {return output_;} /** diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/vehicle_attribs_detection_model.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/vehicle_attribs_detection_model.hpp index 8012bd68..14d708ea 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/models/vehicle_attribs_detection_model.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/models/vehicle_attribs_detection_model.hpp @@ -29,7 +29,7 @@ namespace Models class VehicleAttribsDetectionModel : public BaseModel { public: - VehicleAttribsDetectionModel(const std::string& label_loc, const std::string & model_loc, int batch_size = 1); + VehicleAttribsDetectionModel() {}; inline const std::string getInputName() {return input_tensor_name_;} inline const std::string getColorOutputName() {return color_output_;} inline const std::string getTypeOutputName() {return type_output_;} 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..94c1b643 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 @@ -62,11 +62,18 @@ namespace Outputs * visitor pattern to perform different operations to different inference * result with different output device */ + + class BaseOutput { public: - explicit BaseOutput(std::string output_name) - : output_name_(output_name) {} + BaseOutput() {}; + + virtual void initialize(const std::string &name, + rclcpp::Node::SharedPtr parent_node = nullptr) + { + output_name_ = name; + } /** * @brief Generate output content according to the license plate 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..40c765ac 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 @@ -33,7 +33,23 @@ namespace Outputs class ImageWindowOutput : public BaseOutput { public: - explicit ImageWindowOutput(const std::string & output_name, int focal_length = 950); + ImageWindowOutput() {}; + + void initialize(const std::string &name, + rclcpp::Node::SharedPtr parent_node = nullptr)override + { + output_name_ = name; + focal_length_ = 950; + cv::namedWindow(output_name_, cv::WINDOW_AUTOSIZE); + } + + void initialize(const std::string &name, int focal_length, + rclcpp::Node::SharedPtr parent_node = nullptr) + { + output_name_ = name; + focal_length_ = focal_length; + cv::namedWindow(output_name_, cv::WINDOW_AUTOSIZE); + } /** * @brief Calculate the camera matrix of a frame for image diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/ros_service_output.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/ros_service_output.hpp index d0558ad2..c1398d24 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/ros_service_output.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/ros_service_output.hpp @@ -48,8 +48,13 @@ namespace Outputs class RosServiceOutput : public RosTopicOutput { public: - explicit RosServiceOutput(std::string output_name) - : RosTopicOutput(output_name) {} + RosServiceOutput() {}; + + void initialize(const std::string &name, + rclcpp::Node::SharedPtr parent_node = nullptr)override + { + output_name_ = name; + } /** * @brief Publish all the detected infomations generated by the accept @@ -66,7 +71,6 @@ class RosServiceOutput : public RosTopicOutput void setServiceResponse(std::shared_ptr response); private: - const std::string service_name_; }; } // namespace Outputs #endif // OPENVINO_WRAPPER_LIB__OUTPUTS__ROS_SERVICE_OUTPUT_HPP_ 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..fc7c490a 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 @@ -60,8 +60,11 @@ namespace Outputs class RosTopicOutput : public BaseOutput { public: - explicit RosTopicOutput(std::string output_name_, - const rclcpp::Node::SharedPtr node=nullptr); + RosTopicOutput() {}; + + void initialize(const std::string &name, + rclcpp::Node::SharedPtr parent_node = nullptr)override; + /** * @brief Calculate the camera matrix of a frame. * @param[in] A frame. diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/rviz_output.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/rviz_output.hpp index 6711fab6..80c7f66f 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/rviz_output.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/outputs/rviz_output.hpp @@ -38,7 +38,11 @@ namespace Outputs class RvizOutput : public BaseOutput { public: - explicit RvizOutput(std::string output_name, const rclcpp::Node::SharedPtr node=nullptr); + RvizOutput() {}; + + void initialize(const std::string &name, + rclcpp::Node::SharedPtr parent_node = nullptr)override; + /** * @brief Construct frame for rviz * @param[in] A frame. 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..03c6fd18 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_manager.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_manager.hpp @@ -27,9 +27,54 @@ #include #include #include +#include #include #include "openvino_wrapper_lib/pipeline.hpp" #include "openvino_wrapper_lib/engines/engine_manager.hpp" +#include "openvino_wrapper_lib/vino_factory.hpp" + + +template +std::string string_format( const std::string& format, Args ... args ) +{ + int size_s = std::snprintf( nullptr, 0, format.c_str(), args ... ) + 1; // Extra space for '\0' + if( size_s <= 0 ){ throw std::runtime_error( "Error during formatting." ); } + auto size = static_cast( size_s ); + std::unique_ptr buf( new char[ size ] ); + std::snprintf( buf.get(), size, format.c_str(), args ... ); + return std::string( buf.get(), buf.get() + size - 1 ); // We don't want the '\0' inside +} + +#define REG_INPUT_FACTORY VinoFactory +#define REG_INPUT(BASE, name, key) static REG_INPUT_FACTORY::TReg gs_input_##name(key) + +#define trace(fmt, ...) printf(fmt, ##__VA_ARGS__) +#define REG_MODEL_FACTORY VinoFactory +#define REG_MODEL(BASE, name, key) static REG_MODEL_FACTORY::TReg gs_model_##name(key) +#define REG_MODEL_TYPE(BASE, name, ...) static REG_MODEL_FACTORY::TReg gs_model_##name(string_format("%s", __VA_ARGS__)) + + + +#define REG_INFERENCE_FACTORY VinoFactory +#define REG_INFERENCE(T, name, key) static REG_INFERENCE_FACTORY::TReg gs_inference_##name(key) + +#define REG_OUTPUT_FACTORY VinoFactory +#define REG_OUTPUT(BASE, name, key) static REG_OUTPUT_FACTORY::TReg gs_output_##name(key) + +// REG_INPUT(class name, search key(in this case is string type), expand variable suffix) +// eg: +// #define REG_INPUT_FACTORY VinoFactory +// #define REG_INPUT(BASE, key, name) static REG_INPUT_FACTORY::TReg gs_input_##name(key) + +// REG_INPUT(ImageClass, "JPG", jpg) +// REG_INPUT(ImageClass, "PNG", png) +// VinoFactory::TReg gs_input_IMG +// +// Viriable type: VinoFactory::TReg +// Viriable name: gs_input_jpg, gs_input_png +// search keys: "JPG", "PNG" + + /** * @class PipelineManager @@ -112,32 +157,6 @@ class PipelineManager parseOutput(const PipelineData & pdata); std::map> parseInference(const Params::ParamManager::PipelineRawData & params); - std::shared_ptr - createFaceDetection(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createAgeGenderRecognition(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createEmotionRecognition(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createHeadPoseEstimation(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createObjectDetection(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createObjectSegmentation(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createObjectSegmentationMaskrcnn(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createPersonReidentification(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createPersonAttribsDetection(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createLandmarksDetection(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createFaceReidentification(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createVehicleAttribsDetection(const Params::ParamManager::InferenceRawData & infer); - std::shared_ptr - createLicensePlateDetection(const Params::ParamManager::InferenceRawData & infer); std::map pipelines_; ServiceData service_; Engines::EngineManager engine_manager_; 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..409d1f55 100644 --- a/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_params.hpp +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/pipeline_params.hpp @@ -27,10 +27,6 @@ #include #include #include - -#include "openvino_wrapper_lib/inferences/base_inference.hpp" -#include "openvino_wrapper_lib/inputs/standard_camera.hpp" -#include "openvino_wrapper_lib/outputs/base_output.hpp" #include "opencv2/opencv.hpp" const char kInputType_Image[] = "Image"; diff --git a/openvino_wrapper_lib/include/openvino_wrapper_lib/vino_factory.hpp b/openvino_wrapper_lib/include/openvino_wrapper_lib/vino_factory.hpp new file mode 100644 index 00000000..01f31841 --- /dev/null +++ b/openvino_wrapper_lib/include/openvino_wrapper_lib/vino_factory.hpp @@ -0,0 +1,126 @@ + /* + * Copyright (c) 2018 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. + */ +#pragma once + +#include +#include +#include +#include +#include "openvino_wrapper_lib/slog.hpp" + +template +class VinoFactory +{ +public: + template + struct TReg + { + TReg(KEY key) + { + getFactory().getMap().emplace(key, [] { return new T(); }); + } + + template + TReg(KEY key, Args&&... args) + { + getFactory().getMap().emplace(key, [&] {return new T(std::forward(args)...);}); + } + }; + + static BASE* produce(const KEY& key) + { + auto item = getFactory().getMap().find(key); + + if(item == getFactory().getMap().end()) + { + slog::err << "VinoFactory:Invalid inference key: " << key << ". Please check your key name and type!" << slog::endl; + + + slog::info << "-----------Factory Map---------------" << slog::endl; + + for(auto v : getFactory().getMap()) + { + slog::info << " " << v.first << slog::endl; + } + + slog::info << "-------------------------------------" << slog::endl; + + return nullptr; + } + + return item->second(); + } + + static std::unique_ptr produce_unique(const KEY& key) + { + return std::unique_ptr(produce(key)); + } + + static std::shared_ptr produce_shared(const KEY& key) + { + return std::shared_ptr(produce(key)); + } + + static BASE* find(const KEY& key) + { + auto &instance = getFactory(); + auto item = instance.getMap().find(key); + + if(item == instance.getMap().end()) + { + + slog::err << "VinoFactory: invalid key for find: " << key << ". Please check your key name and type!" << slog::endl; + + + slog::info << "-----------Factory Map---------------" << slog::endl; + + for(auto v : getFactory().getMap()) + { + slog::info << " " << v.first << slog::endl; + } + + slog::info << "-------------------------------------" << slog::endl; + + return nullptr; + } + + return item->second(); + } + +private: + VinoFactory() {}; + virtual ~VinoFactory(){}; + + // Disable Left Value Copy + VinoFactory(const VinoFactory&) = delete; + VinoFactory &operator=(const VinoFactory&) = delete; + + // Disable Move + VinoFactory(VinoFactory&&) = delete; + + static VinoFactory& getFactory() + { + static VinoFactory instance; + return instance; + } + + static std::map>& getMap() + { + return getFactory().map_; + } + + std::map> map_; +}; \ No newline at end of file diff --git a/openvino_wrapper_lib/src/inferences/age_gender_detection.cpp b/openvino_wrapper_lib/src/inferences/age_gender_detection.cpp index 59138e3a..1df5cc83 100644 --- a/openvino_wrapper_lib/src/inferences/age_gender_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/age_gender_detection.cpp @@ -30,18 +30,11 @@ openvino_wrapper_lib::AgeGenderResult::AgeGenderResult(const cv::Rect & location { } -// AgeGender Detection -openvino_wrapper_lib::AgeGenderDetection::AgeGenderDetection() -: openvino_wrapper_lib::BaseInference() -{ -} - -openvino_wrapper_lib::AgeGenderDetection::~AgeGenderDetection() = default; - void openvino_wrapper_lib::AgeGenderDetection::loadNetwork( - std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/base_inference.cpp b/openvino_wrapper_lib/src/inferences/base_inference.cpp index 52138e5c..a01d77dc 100644 --- a/openvino_wrapper_lib/src/inferences/base_inference.cpp +++ b/openvino_wrapper_lib/src/inferences/base_inference.cpp @@ -29,10 +29,6 @@ openvino_wrapper_lib::Result::Result(const cv::Rect & location) } // BaseInference -openvino_wrapper_lib::BaseInference::BaseInference() = default; - -openvino_wrapper_lib::BaseInference::~BaseInference() = default; - void openvino_wrapper_lib::BaseInference::loadEngine(const std::shared_ptr engine) { engine_ = engine; diff --git a/openvino_wrapper_lib/src/inferences/emotions_detection.cpp b/openvino_wrapper_lib/src/inferences/emotions_detection.cpp index e239c228..f1421e04 100644 --- a/openvino_wrapper_lib/src/inferences/emotions_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/emotions_detection.cpp @@ -32,18 +32,11 @@ openvino_wrapper_lib::EmotionsResult::EmotionsResult(const cv::Rect & location) { } -// Emotions Detection -openvino_wrapper_lib::EmotionsDetection::EmotionsDetection() -: openvino_wrapper_lib::BaseInference() -{ -} - -openvino_wrapper_lib::EmotionsDetection::~EmotionsDetection() = default; - void openvino_wrapper_lib::EmotionsDetection::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/face_detection.cpp b/openvino_wrapper_lib/src/inferences/face_detection.cpp index 0037bea3..553b38bf 100644 --- a/openvino_wrapper_lib/src/inferences/face_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/face_detection.cpp @@ -31,11 +31,3 @@ openvino_wrapper_lib::FaceDetectionResult::FaceDetectionResult(const cv::Rect & : ObjectDetectionResult(location) { } - -// FaceDetection -openvino_wrapper_lib::FaceDetection::FaceDetection( - bool enable_roi_constraint, - double show_output_thresh) -: ObjectDetection(enable_roi_constraint, show_output_thresh) -{ -} diff --git a/openvino_wrapper_lib/src/inferences/face_reidentification.cpp b/openvino_wrapper_lib/src/inferences/face_reidentification.cpp index 392d4d62..f09a3caa 100644 --- a/openvino_wrapper_lib/src/inferences/face_reidentification.cpp +++ b/openvino_wrapper_lib/src/inferences/face_reidentification.cpp @@ -30,17 +30,17 @@ openvino_wrapper_lib::FaceReidentificationResult::FaceReidentificationResult( : Result(location) {} // FaceReidentification -openvino_wrapper_lib::FaceReidentification::FaceReidentification(double match_thresh) -: openvino_wrapper_lib::BaseInference() -{ - face_tracker_ = std::make_shared(1000, match_thresh, 0.3); +void openvino_wrapper_lib::FaceReidentification::init( + const Params::ParamManager::InferenceRawData &val) +{ + face_tracker_ = std::make_shared(1000, val.confidence_threshold, 0.3); } -openvino_wrapper_lib::FaceReidentification::~FaceReidentification() = default; void openvino_wrapper_lib::FaceReidentification::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/head_pose_detection.cpp b/openvino_wrapper_lib/src/inferences/head_pose_detection.cpp index 591c6fdd..2df710d8 100644 --- a/openvino_wrapper_lib/src/inferences/head_pose_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/head_pose_detection.cpp @@ -31,17 +31,11 @@ openvino_wrapper_lib::HeadPoseResult::HeadPoseResult(const cv::Rect & location) } // Head Pose Detection -openvino_wrapper_lib::HeadPoseDetection::HeadPoseDetection() -: openvino_wrapper_lib::BaseInference() -{ -} - -openvino_wrapper_lib::HeadPoseDetection::~HeadPoseDetection() = default; - void openvino_wrapper_lib::HeadPoseDetection::loadNetwork( - std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/landmarks_detection.cpp b/openvino_wrapper_lib/src/inferences/landmarks_detection.cpp index f3e468c8..5668c7db 100644 --- a/openvino_wrapper_lib/src/inferences/landmarks_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/landmarks_detection.cpp @@ -30,14 +30,11 @@ openvino_wrapper_lib::LandmarksDetectionResult::LandmarksDetectionResult( : Result(location) {} // LandmarksDetection -openvino_wrapper_lib::LandmarksDetection::LandmarksDetection() -: openvino_wrapper_lib::BaseInference() {} - -openvino_wrapper_lib::LandmarksDetection::~LandmarksDetection() = default; void openvino_wrapper_lib::LandmarksDetection::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/license_plate_detection.cpp b/openvino_wrapper_lib/src/inferences/license_plate_detection.cpp index aa0f8c1d..5d2a62c1 100644 --- a/openvino_wrapper_lib/src/inferences/license_plate_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/license_plate_detection.cpp @@ -30,14 +30,11 @@ openvino_wrapper_lib::LicensePlateDetectionResult::LicensePlateDetectionResult( : Result(location) {} // LicensePlateDetection -openvino_wrapper_lib::LicensePlateDetection::LicensePlateDetection() -: openvino_wrapper_lib::BaseInference() {} - -openvino_wrapper_lib::LicensePlateDetection::~LicensePlateDetection() = default; void openvino_wrapper_lib::LicensePlateDetection::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/object_detection.cpp b/openvino_wrapper_lib/src/inferences/object_detection.cpp index 8470a103..dda58f70 100644 --- a/openvino_wrapper_lib/src/inferences/object_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/object_detection.cpp @@ -33,25 +33,24 @@ openvino_wrapper_lib::ObjectDetectionResult::ObjectDetectionResult(const cv::Rec } // ObjectDetection -openvino_wrapper_lib::ObjectDetection::ObjectDetection( - bool enable_roi_constraint, - double show_output_thresh) -: show_output_thresh_(show_output_thresh), - enable_roi_constraint_(enable_roi_constraint), openvino_wrapper_lib::BaseInference() +void openvino_wrapper_lib::ObjectDetection::init( + const Params::ParamManager::InferenceRawData &val) { - result_filter_ = std::make_shared(); - result_filter_->init(); -} + show_output_thresh_ = val.confidence_threshold; + enable_roi_constraint_ = val.enable_roi_constraint; -openvino_wrapper_lib::ObjectDetection::~ObjectDetection() = default; + result_filter_ = std::make_shared(); + result_filter_->init(); +} void openvino_wrapper_lib::ObjectDetection::loadNetwork( - std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); setMaxBatchSize(network->getMaxBatchSize()); } + bool openvino_wrapper_lib::ObjectDetection::enqueue( const cv::Mat & frame, const cv::Rect & input_frame_loc) diff --git a/openvino_wrapper_lib/src/inferences/object_segmentation.cpp b/openvino_wrapper_lib/src/inferences/object_segmentation.cpp index 699731e3..0155e094 100644 --- a/openvino_wrapper_lib/src/inferences/object_segmentation.cpp +++ b/openvino_wrapper_lib/src/inferences/object_segmentation.cpp @@ -35,18 +35,17 @@ openvino_wrapper_lib::ObjectSegmentationResult::ObjectSegmentationResult(const c } // ObjectSegmentation -openvino_wrapper_lib::ObjectSegmentation::ObjectSegmentation(double show_output_thresh) - : show_output_thresh_(show_output_thresh), openvino_wrapper_lib::BaseInference() +void openvino_wrapper_lib::ObjectSegmentation::init( + const Params::ParamManager::InferenceRawData &val) { + show_output_thresh_ = val.confidence_threshold; } -openvino_wrapper_lib::ObjectSegmentation::~ObjectSegmentation() = default; - void openvino_wrapper_lib::ObjectSegmentation::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - slog::info << "Loading Network: " << network->getModelCategory() << slog::endl; - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } @@ -235,3 +234,4 @@ const std::vector openvino_wrapper_lib::ObjectSegmentation::getFiltere std::vector filtered_rois; return filtered_rois; } + diff --git a/openvino_wrapper_lib/src/inferences/object_segmentation_maskrcnn.cpp b/openvino_wrapper_lib/src/inferences/object_segmentation_maskrcnn.cpp index 7c35fc55..b426225c 100644 --- a/openvino_wrapper_lib/src/inferences/object_segmentation_maskrcnn.cpp +++ b/openvino_wrapper_lib/src/inferences/object_segmentation_maskrcnn.cpp @@ -35,18 +35,17 @@ openvino_wrapper_lib::ObjectSegmentationMaskrcnnResult::ObjectSegmentationMaskrc } // ObjectSegmentation -openvino_wrapper_lib::ObjectSegmentationMaskrcnn::ObjectSegmentationMaskrcnn(double show_output_thresh) - : show_output_thresh_(show_output_thresh), openvino_wrapper_lib::BaseInference() +void openvino_wrapper_lib::ObjectSegmentationMaskrcnn::init( + const Params::ParamManager::InferenceRawData &val) { + show_output_thresh_ = val.confidence_threshold; } -openvino_wrapper_lib::ObjectSegmentationMaskrcnn::~ObjectSegmentationMaskrcnn() = default; - void openvino_wrapper_lib::ObjectSegmentationMaskrcnn::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - slog::info << "Loading Network: " << network->getModelCategory() << slog::endl; - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/person_attribs_detection.cpp b/openvino_wrapper_lib/src/inferences/person_attribs_detection.cpp index 79b5c446..3613e64e 100644 --- a/openvino_wrapper_lib/src/inferences/person_attribs_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/person_attribs_detection.cpp @@ -31,14 +31,17 @@ openvino_wrapper_lib::PersonAttribsDetectionResult::PersonAttribsDetectionResult : Result(location) {} // PersonAttribsDetection -openvino_wrapper_lib::PersonAttribsDetection::PersonAttribsDetection(double attribs_confidence) -: attribs_confidence_(attribs_confidence), openvino_wrapper_lib::BaseInference() {} +void openvino_wrapper_lib::PersonAttribsDetection::init( + const Params::ParamManager::InferenceRawData &val) +{ + attribs_confidence_ = val.confidence_threshold; +} -openvino_wrapper_lib::PersonAttribsDetection::~PersonAttribsDetection() = default; void openvino_wrapper_lib::PersonAttribsDetection::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/person_reidentification.cpp b/openvino_wrapper_lib/src/inferences/person_reidentification.cpp index 9d4d891a..749dad51 100644 --- a/openvino_wrapper_lib/src/inferences/person_reidentification.cpp +++ b/openvino_wrapper_lib/src/inferences/person_reidentification.cpp @@ -30,17 +30,17 @@ openvino_wrapper_lib::PersonReidentificationResult::PersonReidentificationResult : Result(location) {} // PersonReidentification -openvino_wrapper_lib::PersonReidentification::PersonReidentification(double match_thresh) -: openvino_wrapper_lib::BaseInference() +void openvino_wrapper_lib::PersonReidentification::init( + const Params::ParamManager::InferenceRawData &val) { - person_tracker_ = std::make_shared(1000, match_thresh, 0.3); + person_tracker_ = std::make_shared(1000, val.confidence_threshold, 0.3); } -openvino_wrapper_lib::PersonReidentification::~PersonReidentification() = default; void openvino_wrapper_lib::PersonReidentification::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inferences/vehicle_attribs_detection.cpp b/openvino_wrapper_lib/src/inferences/vehicle_attribs_detection.cpp index 232d73ea..8afbe453 100644 --- a/openvino_wrapper_lib/src/inferences/vehicle_attribs_detection.cpp +++ b/openvino_wrapper_lib/src/inferences/vehicle_attribs_detection.cpp @@ -30,14 +30,11 @@ openvino_wrapper_lib::VehicleAttribsDetectionResult::VehicleAttribsDetectionResu : Result(location) {} // VehicleAttribsDetection -openvino_wrapper_lib::VehicleAttribsDetection::VehicleAttribsDetection() -: openvino_wrapper_lib::BaseInference() {} - -openvino_wrapper_lib::VehicleAttribsDetection::~VehicleAttribsDetection() = default; void openvino_wrapper_lib::VehicleAttribsDetection::loadNetwork( - const std::shared_ptr network) + const std::shared_ptr network) { - valid_model_ = network; + valid_model_ = std::dynamic_pointer_cast(network); + setMaxBatchSize(network->getMaxBatchSize()); } diff --git a/openvino_wrapper_lib/src/inputs/image_topic.cpp b/openvino_wrapper_lib/src/inputs/image_topic.cpp index a716e2fe..5d6e3972 100644 --- a/openvino_wrapper_lib/src/inputs/image_topic.cpp +++ b/openvino_wrapper_lib/src/inputs/image_topic.cpp @@ -25,11 +25,6 @@ #define INPUT_TOPIC "/openvino_toolkit/image_raw" -Input::ImageTopic::ImageTopic(rclcpp::Node::SharedPtr node) -: node_(node) -{ -} - bool Input::ImageTopic::initialize() { slog::debug << "before Image Topic init" << slog::endl; diff --git a/openvino_wrapper_lib/src/models/age_gender_detection_model.cpp b/openvino_wrapper_lib/src/models/age_gender_detection_model.cpp index ac3eea86..70d7b35b 100644 --- a/openvino_wrapper_lib/src/models/age_gender_detection_model.cpp +++ b/openvino_wrapper_lib/src/models/age_gender_detection_model.cpp @@ -23,13 +23,6 @@ #include "openvino_wrapper_lib/slog.hpp" // Validated Age Gender Classification Network -Models::AgeGenderDetectionModel::AgeGenderDetectionModel( - const std::string & label_loc, - const std::string & model_loc, - int max_batch_size) -: BaseModel(label_loc,model_loc, max_batch_size) -{ -} bool Models::AgeGenderDetectionModel::updateLayerProperty( std::shared_ptr& model) { diff --git a/openvino_wrapper_lib/src/models/base_model.cpp b/openvino_wrapper_lib/src/models/base_model.cpp index 70647b5a..04622289 100644 --- a/openvino_wrapper_lib/src/models/base_model.cpp +++ b/openvino_wrapper_lib/src/models/base_model.cpp @@ -28,23 +28,18 @@ #include "openvino_wrapper_lib/models/attributes/base_attribute.hpp" // Validated Base Network -Models::BaseModel::BaseModel( - 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) +void Models::BaseModel::modelInit(const Params::ParamManager::InferenceRawData & param, bool use_def_batch, int batch_size) { - if (model_loc.empty()) { + if (param.model.empty()) { throw std::logic_error("model file name is empty!"); } -} + label_loc_ = param.label; + model_loc_ = param.model; + attr_.model_name = param.model; + max_batch_size_ = use_def_batch ? batch_size : param.batch; -void Models::BaseModel::modelInit() -{ - slog::info << "Loading network files" << model_loc_ << slog::endl; - slog::info << label_loc_ << slog::endl; + slog::info << "Loading network files: " << model_loc_ << slog::endl; // Read network model model_ = engine.read_model(model_loc_); @@ -83,9 +78,3 @@ bool Models::BaseModel::updateLayerProperty( return true; } #endif - -Models::ObjectDetectionModel::ObjectDetectionModel( - const std::string& label_loc, - const std::string& model_loc, - int max_batch_size) -: BaseModel(label_loc, model_loc, max_batch_size) {} diff --git a/openvino_wrapper_lib/src/models/emotion_detection_model.cpp b/openvino_wrapper_lib/src/models/emotion_detection_model.cpp index 9d7579bb..f2e9e571 100644 --- a/openvino_wrapper_lib/src/models/emotion_detection_model.cpp +++ b/openvino_wrapper_lib/src/models/emotion_detection_model.cpp @@ -23,12 +23,6 @@ // Validated Emotions Detection Network -Models::EmotionDetectionModel::EmotionDetectionModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: BaseModel(label_loc, model_loc, max_batch_size) -{ -} - bool Models::EmotionDetectionModel::updateLayerProperty (std::shared_ptr& model) { diff --git a/openvino_wrapper_lib/src/models/face_detection_model.cpp b/openvino_wrapper_lib/src/models/face_detection_model.cpp index ced9982e..85fd649a 100644 --- a/openvino_wrapper_lib/src/models/face_detection_model.cpp +++ b/openvino_wrapper_lib/src/models/face_detection_model.cpp @@ -23,12 +23,6 @@ #include "openvino_wrapper_lib/slog.hpp" // Validated Face Detection Network -Models::FaceDetectionModel::FaceDetectionModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: ObjectDetectionModel(label_loc, model_loc, max_batch_size) -{ -} - const std::string Models::FaceDetectionModel::getModelCategory() const { return "Face Detection"; diff --git a/openvino_wrapper_lib/src/models/face_reidentification_model.cpp b/openvino_wrapper_lib/src/models/face_reidentification_model.cpp index d8deb8f5..9df78095 100644 --- a/openvino_wrapper_lib/src/models/face_reidentification_model.cpp +++ b/openvino_wrapper_lib/src/models/face_reidentification_model.cpp @@ -20,10 +20,6 @@ #include "openvino_wrapper_lib/models/face_reidentification_model.hpp" #include "openvino_wrapper_lib/slog.hpp" // Validated Face Reidentification Network -Models::FaceReidentificationModel::FaceReidentificationModel( - 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& model) { diff --git a/openvino_wrapper_lib/src/models/head_pose_detection_model.cpp b/openvino_wrapper_lib/src/models/head_pose_detection_model.cpp index 2f4ec293..85941e66 100644 --- a/openvino_wrapper_lib/src/models/head_pose_detection_model.cpp +++ b/openvino_wrapper_lib/src/models/head_pose_detection_model.cpp @@ -24,12 +24,6 @@ #include "openvino_wrapper_lib/slog.hpp" // Validated Head Pose Network -Models::HeadPoseDetectionModel::HeadPoseDetectionModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: BaseModel(label_loc, model_loc, max_batch_size) -{ -} - bool Models::HeadPoseDetectionModel::updateLayerProperty (std::shared_ptr& model) { diff --git a/openvino_wrapper_lib/src/models/landmarks_detection_model.cpp b/openvino_wrapper_lib/src/models/landmarks_detection_model.cpp index 3c261c5b..a6f4554c 100644 --- a/openvino_wrapper_lib/src/models/landmarks_detection_model.cpp +++ b/openvino_wrapper_lib/src/models/landmarks_detection_model.cpp @@ -20,10 +20,6 @@ #include "openvino_wrapper_lib/models/landmarks_detection_model.hpp" #include "openvino_wrapper_lib/slog.hpp" // Validated Landmarks Detection Network -Models::LandmarksDetectionModel::LandmarksDetectionModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: BaseModel(label_loc, model_loc, max_batch_size) {} - void Models::LandmarksDetectionModel::setLayerProperty( InferenceEngine::CNNNetwork& model) { diff --git a/openvino_wrapper_lib/src/models/license_plate_detection_model.cpp b/openvino_wrapper_lib/src/models/license_plate_detection_model.cpp index bfdf4ce5..0ce72fe4 100644 --- a/openvino_wrapper_lib/src/models/license_plate_detection_model.cpp +++ b/openvino_wrapper_lib/src/models/license_plate_detection_model.cpp @@ -20,10 +20,6 @@ #include "openvino_wrapper_lib/models/license_plate_detection_model.hpp" #include "openvino_wrapper_lib/slog.hpp" // Validated Vehicle Attributes Detection Network -Models::LicensePlateDetectionModel::LicensePlateDetectionModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: BaseModel(label_loc, model_loc, max_batch_size) {} - bool Models::LicensePlateDetectionModel::updateLayerProperty( std::shared_ptr& model) { diff --git a/openvino_wrapper_lib/src/models/object_detection_ssd_model.cpp b/openvino_wrapper_lib/src/models/object_detection_ssd_model.cpp index 2c938ca8..41a46e59 100644 --- a/openvino_wrapper_lib/src/models/object_detection_ssd_model.cpp +++ b/openvino_wrapper_lib/src/models/object_detection_ssd_model.cpp @@ -26,13 +26,6 @@ #include "openvino_wrapper_lib/models/attributes/base_attribute.hpp" // Validated Object Detection Network -Models::ObjectDetectionSSDModel::ObjectDetectionSSDModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: ObjectDetectionModel(label_loc, model_loc, max_batch_size) -{ - slog::debug << "TESTING: in ObjectDetectionSSDModel" << slog::endl; -} - const std::string Models::ObjectDetectionSSDModel::getModelCategory() const { return "Object Detection SSD"; diff --git a/openvino_wrapper_lib/src/models/object_detection_yolov5_model.cpp b/openvino_wrapper_lib/src/models/object_detection_yolov5_model.cpp index 8dd7176d..f919eb55 100644 --- a/openvino_wrapper_lib/src/models/object_detection_yolov5_model.cpp +++ b/openvino_wrapper_lib/src/models/object_detection_yolov5_model.cpp @@ -27,12 +27,6 @@ // Validated Object Detection Network -Models::ObjectDetectionYolov5Model::ObjectDetectionYolov5Model( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: ObjectDetectionModel(label_loc, model_loc, max_batch_size) -{ -} - bool Models::ObjectDetectionYolov5Model::updateLayerProperty( std::shared_ptr& model) { diff --git a/openvino_wrapper_lib/src/models/object_segmentation_maskrcnn_model.cpp b/openvino_wrapper_lib/src/models/object_segmentation_maskrcnn_model.cpp index d08b5a57..bf9a4c1a 100644 --- a/openvino_wrapper_lib/src/models/object_segmentation_maskrcnn_model.cpp +++ b/openvino_wrapper_lib/src/models/object_segmentation_maskrcnn_model.cpp @@ -24,14 +24,6 @@ #include "openvino_wrapper_lib/engines/engine.hpp" // Validated Object Segmentation Network -Models::ObjectSegmentationMaskrcnnModel::ObjectSegmentationMaskrcnnModel( - const std::string & label_loc, - const std::string & model_loc, - int max_batch_size) - : BaseModel(label_loc, model_loc, max_batch_size) -{ -} - bool Models::ObjectSegmentationMaskrcnnModel::enqueue( const std::shared_ptr &engine, const cv::Mat &frame, diff --git a/openvino_wrapper_lib/src/models/object_segmentation_model.cpp b/openvino_wrapper_lib/src/models/object_segmentation_model.cpp index 1d076757..c87acb61 100644 --- a/openvino_wrapper_lib/src/models/object_segmentation_model.cpp +++ b/openvino_wrapper_lib/src/models/object_segmentation_model.cpp @@ -23,14 +23,6 @@ #include "openvino_wrapper_lib/slog.hpp" #include "openvino_wrapper_lib/engines/engine.hpp" // Validated Object Segmentation Network -Models::ObjectSegmentationModel::ObjectSegmentationModel( - const std::string & label_loc, - const std::string & model_loc, - int max_batch_size) - : BaseModel(label_loc, model_loc, max_batch_size) -{ -} - bool Models::ObjectSegmentationModel::enqueue( const std::shared_ptr &engine, const cv::Mat &frame, diff --git a/openvino_wrapper_lib/src/models/person_attribs_detection_model.cpp b/openvino_wrapper_lib/src/models/person_attribs_detection_model.cpp index 405740d6..01eaefdc 100644 --- a/openvino_wrapper_lib/src/models/person_attribs_detection_model.cpp +++ b/openvino_wrapper_lib/src/models/person_attribs_detection_model.cpp @@ -21,10 +21,6 @@ #include "openvino_wrapper_lib/models/person_attribs_detection_model.hpp" #include "openvino_wrapper_lib/slog.hpp" // Validated Person Attributes Detection Network -Models::PersonAttribsDetectionModel::PersonAttribsDetectionModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: BaseModel(label_loc, model_loc, max_batch_size) {} - bool Models::PersonAttribsDetectionModel::updateLayerProperty( std::shared_ptr& model) { diff --git a/openvino_wrapper_lib/src/models/person_reidentification_model.cpp b/openvino_wrapper_lib/src/models/person_reidentification_model.cpp index 911a3609..7cea01c5 100644 --- a/openvino_wrapper_lib/src/models/person_reidentification_model.cpp +++ b/openvino_wrapper_lib/src/models/person_reidentification_model.cpp @@ -20,10 +20,6 @@ #include "openvino_wrapper_lib/models/person_reidentification_model.hpp" #include "openvino_wrapper_lib/slog.hpp" // Validated Person Reidentification Network -Models::PersonReidentificationModel::PersonReidentificationModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: BaseModel(label_loc, model_loc, max_batch_size) {} - bool Models::PersonReidentificationModel::updateLayerProperty( std::shared_ptr& model) { diff --git a/openvino_wrapper_lib/src/models/vehicle_attribs_detection_model.cpp b/openvino_wrapper_lib/src/models/vehicle_attribs_detection_model.cpp index e5a65947..2ae5404c 100644 --- a/openvino_wrapper_lib/src/models/vehicle_attribs_detection_model.cpp +++ b/openvino_wrapper_lib/src/models/vehicle_attribs_detection_model.cpp @@ -20,10 +20,6 @@ #include "openvino_wrapper_lib/models/vehicle_attribs_detection_model.hpp" #include "openvino_wrapper_lib/slog.hpp" // Validated Vehicle Attributes Detection Network -Models::VehicleAttribsDetectionModel::VehicleAttribsDetectionModel( - const std::string & label_loc, const std::string & model_loc, int max_batch_size) -: BaseModel(label_loc, model_loc, max_batch_size) {} - bool Models::VehicleAttribsDetectionModel::updateLayerProperty( std::shared_ptr& model) { diff --git a/openvino_wrapper_lib/src/outputs/image_window_output.cpp b/openvino_wrapper_lib/src/outputs/image_window_output.cpp index 0f2b93e2..a6e74f44 100644 --- a/openvino_wrapper_lib/src/outputs/image_window_output.cpp +++ b/openvino_wrapper_lib/src/outputs/image_window_output.cpp @@ -26,12 +26,6 @@ #include "openvino_wrapper_lib/outputs/image_window_output.hpp" #include "openvino_wrapper_lib/pipeline.hpp" -Outputs::ImageWindowOutput::ImageWindowOutput(const std::string & output_name, int focal_length) -: BaseOutput(output_name), focal_length_(focal_length) -{ - cv::namedWindow(output_name_, cv::WINDOW_AUTOSIZE); -} - void Outputs::ImageWindowOutput::feedFrame(const cv::Mat & frame) { // frame_ = frame; diff --git a/openvino_wrapper_lib/src/outputs/ros_topic_output.cpp b/openvino_wrapper_lib/src/outputs/ros_topic_output.cpp index a0f8a531..4adb5c19 100644 --- a/openvino_wrapper_lib/src/outputs/ros_topic_output.cpp +++ b/openvino_wrapper_lib/src/outputs/ros_topic_output.cpp @@ -21,18 +21,21 @@ #include #include #include "openvino_wrapper_lib/outputs/ros_topic_output.hpp" -#include "openvino_wrapper_lib/pipeline_params.hpp" #include "openvino_wrapper_lib/pipeline.hpp" #include "cv_bridge/cv_bridge.h" -Outputs::RosTopicOutput::RosTopicOutput(std::string output_name, - const rclcpp::Node::SharedPtr node) -: BaseOutput(output_name) -{ + +void Outputs::RosTopicOutput::initialize( + const std::string &name, + rclcpp::Node::SharedPtr parent_node) +{ + output_name_ = name; + const rclcpp::Node::SharedPtr node = parent_node; + if(node != nullptr){ node_ = node; } else { - node_ = rclcpp::Node::make_shared(output_name + "_topic_publisher"); + node_ = rclcpp::Node::make_shared(output_name_ + "_topic_publisher"); } pub_license_plate_ = node_->create_publisher( "/openvino_toolkit/" + output_name_ + "/detected_license_plates", 16); @@ -61,6 +64,7 @@ Outputs::RosTopicOutput::RosTopicOutput(std::string output_name, pub_headpose_ = node_->create_publisher( "/openvino_toolkit/" + output_name_ + "/headposes", 16); + emotions_topic_ = nullptr; detected_objects_topic_ = nullptr; faces_topic_ = nullptr; @@ -73,7 +77,7 @@ Outputs::RosTopicOutput::RosTopicOutput(std::string output_name, landmarks_topic_ = nullptr; vehicle_attribs_topic_ = nullptr; license_plate_topic_ = nullptr; -} +}; void Outputs::RosTopicOutput::feedFrame(const cv::Mat & frame) { diff --git a/openvino_wrapper_lib/src/outputs/rviz_output.cpp b/openvino_wrapper_lib/src/outputs/rviz_output.cpp index f35e6414..013ecfd9 100644 --- a/openvino_wrapper_lib/src/outputs/rviz_output.cpp +++ b/openvino_wrapper_lib/src/outputs/rviz_output.cpp @@ -25,18 +25,24 @@ #include "openvino_wrapper_lib/pipeline.hpp" #include "openvino_wrapper_lib/outputs/rviz_output.hpp" -Outputs::RvizOutput::RvizOutput(std::string output_name, const rclcpp::Node::SharedPtr node) -: BaseOutput(output_name) -{ + +void Outputs::RvizOutput::initialize( + const std::string &name, + rclcpp::Node::SharedPtr parent_node) +{ + output_name_ = name; + const rclcpp::Node::SharedPtr node = parent_node; + if(node != nullptr){ node_ = node; } else { - node_ = rclcpp::Node::make_shared(output_name + "_image_publisher"); + node_ = rclcpp::Node::make_shared(output_name_ + "_image_publisher"); } image_topic_ = nullptr; pub_image_ = node_->create_publisher( "/openvino_toolkit/" + output_name_ + "/images", 16); - image_window_output_ = std::make_shared(output_name_, 950); + image_window_output_ = std::make_shared(); + image_window_output_->initialize(output_name_, 950); } void Outputs::RvizOutput::feedFrame(const cv::Mat & frame) diff --git a/openvino_wrapper_lib/src/pipeline_manager.cpp b/openvino_wrapper_lib/src/pipeline_manager.cpp index 184ac922..56e70d82 100644 --- a/openvino_wrapper_lib/src/pipeline_manager.cpp +++ b/openvino_wrapper_lib/src/pipeline_manager.cpp @@ -66,6 +66,53 @@ #include "openvino_wrapper_lib/pipeline_params.hpp" #include "openvino_wrapper_lib/services/pipeline_processing_server.hpp" #include "openvino_wrapper_lib/engines/engine_manager.hpp" + + +REG_INPUT(Image, Image, "Image"); +REG_INPUT(Video, Video, "Video"); +REG_INPUT(IpCamera, IpCamera, "IpCamera"); +REG_INPUT(StandardCamera, StandardCamera, "StandardCamera"); +REG_INPUT(RealSenseCameraTopic, RealSenseCameraTopic, "RealSenseCameraTopic"); +REG_INPUT(ImageTopic, ImageTopic, "ImageTopic"); +REG_INPUT(RealSenseCamera, RealSenseCamera, "RealSenseCamera"); + +REG_MODEL(AgeGenderDetectionModel, AgeGenderRecognition, "AgeGenderRecognition"); +REG_MODEL(EmotionDetectionModel, EmotionDetection, "EmotionRecognition"); +REG_MODEL(HeadPoseDetectionModel, HeadPoseEstimation, "HeadPoseEstimation"); +REG_MODEL(ObjectSegmentationModel, ObjectSegmentation, "ObjectSegmentation"); + +REG_MODEL(ObjectSegmentationMaskrcnnModel, ObjectSegmentationMaskrcnn,"ObjectSegmentationMaskrcnn"); +REG_MODEL(PersonReidentificationModel, PersonReidentification, "PersonReidentification"); +REG_MODEL(VehicleAttribsDetectionModel, VehicleAttribsDetection, "VehicleAttribsDetection"); +REG_MODEL(LicensePlateDetectionModel, LicensePlateDetection, "LicensePlateDetection"); +REG_MODEL(PersonAttribsDetectionModel, PersonAttribsDetection, "PersonAttribsDetection"); +// REG_MODEL(LandmarksDetectionModel, "LandmarksDetection", LandmarksDetection); +// REG_MODEL(FaceReidentificationModel, "FaceReidentification", FaceReidentification); +REG_MODEL(ObjectDetectionSSDModel, ObjectDetection, "ObjectDetection"); +REG_MODEL(ObjectDetectionSSDModel, FaceDetection, "FaceDetection"); +REG_MODEL_TYPE(ObjectDetectionSSDModel, FaceDetectionSSD, "FaceDetection", "SSD"); +REG_MODEL(ObjectDetectionYolov5Model, ObjectDetectionYolov5,"ObjectDetectionyolov5"); + +REG_INFERENCE(AgeGenderDetection, AgeGenderDetection, "AgeGenderRecognition"); +REG_INFERENCE(EmotionsDetection, EmotionsDetection, "EmotionRecognition"); +REG_INFERENCE(HeadPoseDetection, HeadPoseDetection, "HeadPoseEstimation"); +REG_INFERENCE(FaceDetection, FaceDetection, "FaceDetection"); +REG_INFERENCE(ObjectDetection, ObjectDetection, "ObjectDetection"); +REG_INFERENCE(ObjectSegmentation, ObjectSegmentation, "ObjectSegmentation"); + +REG_INFERENCE(ObjectSegmentationMaskrcnn, ObjectSegmentationMaskrcnn, "ObjectSegmentationMaskrcnn"); +REG_INFERENCE(PersonReidentification, PersonReidentification, "PersonReidentification"); +REG_INFERENCE(VehicleAttribsDetection, VehicleAttribsDetection, "VehicleAttribsDetection"); +REG_INFERENCE(LicensePlateDetection, LicensePlateDetection, "LicensePlateDetection"); +REG_INFERENCE(PersonAttribsDetection, PersonAttribsDetection, "PersonAttribsDetection"); +// REG_INFERENCE(LandmarksDetection, "LandmarksDetection", LandmarksDetection); +// REG_INFERENCE(FaceReidentification, "FaceReidentification", FaceReidentification); + +REG_OUTPUT(RvizOutput, RViz, "RViz"); +REG_OUTPUT(ImageWindowOutput, ImageWindow,"ImageWindow"); +REG_OUTPUT(RosTopicOutput, RosTopic, "RosTopic"); +REG_OUTPUT(RosServiceOutput, RosService, "RosService"); + std::shared_ptr PipelineManager::createPipeline(const Params::ParamManager::PipelineRawData & params, rclcpp::Node::SharedPtr node) @@ -125,62 +172,41 @@ PipelineManager::parseInputDevice(const PipelineData & pdata) std::map> inputs; for (auto & name : pdata.params.inputs) { slog::info << "Parsing InputDvice: " << name << slog::endl; - std::shared_ptr device = nullptr; - if (name == kInputType_RealSenseCamera) { - device = std::make_shared(); - } else if (name == kInputType_StandardCamera) { - device = std::make_shared(); - } else if (name == kInputType_IpCamera) { - if (pdata.params.input_meta != "") { - device = std::make_shared(pdata.params.input_meta); - } - } else if (name == kInputType_CameraTopic || name == kInputType_ImageTopic) { - device = std::make_shared(pdata.parent_node); - } else if (name == kInputType_Video) { - if (pdata.params.input_meta != "") { - device = std::make_shared(pdata.params.input_meta); - } - } else if (name == kInputType_Image) { - if (pdata.params.input_meta != "") { - device = std::make_shared(pdata.params.input_meta); - } - } else { - slog::err << "Invalid input device name: " << name << slog::endl; - } + std::shared_ptr device = REG_INPUT_FACTORY::produce_shared(name); - if (device != nullptr) { - device->initialize(); - inputs.insert({name, device}); + if (device != nullptr) + { + device->initialize(pdata.params.input_meta); + inputs.insert({ name, device }); slog::info << " ... Adding one Input device: " << name << slog::endl; } + else + { + slog::err << "Invalid input device input_name: " << name << slog::endl; + } } return inputs; } - std::map> PipelineManager::parseOutput(const PipelineData & pdata) { std::map> outputs; for (auto & name : pdata.params.outputs) { slog::info << "Parsing Output: " << name << slog::endl; - std::shared_ptr object = nullptr; - if (name == kOutputTpye_RosTopic) { - object = std::make_shared(pdata.params.name, pdata.parent_node); - } else if (name == kOutputTpye_ImageWindow) { - object = std::make_shared(pdata.params.name); - } else if (name == kOutputTpye_RViz) { - object = std::make_shared(pdata.params.name, pdata.parent_node); - } else if (name == kOutputTpye_RosService) { - object = std::make_shared(pdata.params.name); - } else { - slog::err << "Invalid output name: " << name << slog::endl; - } - if (object != nullptr) { - outputs.insert({name, object}); + std::shared_ptr object = REG_OUTPUT_FACTORY::produce_shared(name); + + if (object != nullptr) + { + object->initialize(pdata.params.name, pdata.parent_node); + outputs.insert({name, object }); slog::info << " ... Adding one Output: " << name << slog::endl; } + else + { + slog::err << "Invalid output name: " << name << slog::endl; + } } return outputs; @@ -194,42 +220,35 @@ PipelineManager::parseInference(const Params::ParamManager::PipelineRawData & pa if (infer.name.empty() || infer.model.empty()) { continue; } - slog::info << "Parsing Inference: " << infer.name << slog::endl; - std::shared_ptr object = nullptr; - - if (infer.name == kInferTpye_FaceDetection) { - object = createFaceDetection(infer); - } else if (infer.name == kInferTpye_AgeGenderRecognition) { - object = createAgeGenderRecognition(infer); - } else if (infer.name == kInferTpye_EmotionRecognition) { - object = createEmotionRecognition(infer); - } else if (infer.name == kInferTpye_HeadPoseEstimation) { - object = createHeadPoseEstimation(infer); - } else if (infer.name == kInferTpye_ObjectDetection) { - object = createObjectDetection(infer); - } else if (infer.name == kInferTpye_ObjectSegmentation) { - object = createObjectSegmentation(infer); - } else if (infer.name == kInferTpye_ObjectSegmentationMaskrcnn) { - object = createObjectSegmentationMaskrcnn(infer); - } else if (infer.name == kInferTpye_PersonReidentification) { - object = createPersonReidentification(infer); - } else if (infer.name == kInferTpye_PersonAttribsDetection) { - object = createPersonAttribsDetection(infer); - } /*else if (infer.name == kInferTpye_LandmarksDetection) { - object = createLandmarksDetection(infer); - } else if (infer.name == kInferTpye_FaceReidentification) { - object = createFaceReidentification(infer); - } */ else if (infer.name == kInferTpye_VehicleAttribsDetection) { - object = createVehicleAttribsDetection(infer); - } else if (infer.name == kInferTpye_LicensePlateDetection) { - object = createLicensePlateDetection(infer); - }else { - slog::err << "Invalid inference name: " << infer.name << slog::endl; + slog::info << "Parsing Model: " << infer.name << slog::endl; + + auto model_name = infer.name + infer.model_type; + std::shared_ptr model = + REG_MODEL_FACTORY::produce_shared(model_name); + + if (model != nullptr) { + model->modelInit(infer); + slog::info << " ... Loading Model: " << model_name << slog::endl; + } else { + slog::err << "Invalid Model name: " << model_name << slog::endl; } + slog::info << "createEngine..." << infer.engine << slog::endl; + auto engine = engine_manager_.createEngine(infer.engine, model); + + slog::info << "Parsing Inference: " << infer.name << slog::endl; + + std::shared_ptr object = + REG_INFERENCE_FACTORY::produce_shared(infer.name); + if (object != nullptr) { + object->init(infer); + object->loadNetwork(model); + object->loadEngine(engine); inferences.insert({infer.name, object}); slog::info << " ... Adding one Inference: " << infer.name << slog::endl; + } else { + slog::err << "Invalid inference name: " << infer.name << slog::endl; } } @@ -237,289 +256,6 @@ PipelineManager::parseInference(const Params::ParamManager::PipelineRawData & pa } -std::shared_ptr -PipelineManager::createFaceDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - return createObjectDetection(infer); -} - -std::shared_ptr -PipelineManager::createAgeGenderRecognition(const Params::ParamManager::InferenceRawData & param) -{ - auto model = std::make_shared(param.label, param.model, param.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(param.engine, model); - auto infer = std::make_shared(); - infer->loadNetwork(model); - infer->loadEngine(engine); - - return infer; -} - -std::shared_ptr -PipelineManager::createEmotionRecognition(const Params::ParamManager::InferenceRawData & param) -{ - auto model = std::make_shared(param.label, param.model, param.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(param.engine, model); - auto infer = std::make_shared(); - infer->loadNetwork(model); - infer->loadEngine(engine); - - return infer; -} - -std::shared_ptr -PipelineManager::createHeadPoseEstimation(const Params::ParamManager::InferenceRawData & param) -{ - auto model = std::make_shared(param.label, param.model, param.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(param.engine, model); - auto infer = std::make_shared(); - infer->loadNetwork(model); - infer->loadEngine(engine); - - return infer; -} - - -std::shared_ptr -PipelineManager::createObjectDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - std::shared_ptr object_detection_model; - std::shared_ptr object_inference_ptr; - slog::debug << "for test in createObjectDetection()" << slog::endl; - if (infer.model_type == kInferTpye_ObjectDetectionTypeSSD) { - object_detection_model = - std::make_shared(infer.label, infer.model, infer.batch); - } - if (infer.model_type == kInferTpye_ObjectDetectionTypeYolov5) { - object_detection_model = - std::make_shared(infer.label, infer.model, infer.batch); - } - - slog::debug << "for test in createObjectDetection(), Created SSDModel" << slog::endl; - object_inference_ptr = std::make_shared( - infer.enable_roi_constraint, infer.confidence_threshold); // To-do theshold configuration - slog::debug << "for test in createObjectDetection(), before modelInit()" << slog::endl; - object_detection_model->modelInit(); - auto object_detection_engine = engine_manager_.createEngine( - infer.engine, object_detection_model); - slog::debug << "for test in createObjectDetection(), before loadNetwork" << slog::endl; - object_inference_ptr->loadNetwork(object_detection_model); - object_inference_ptr->loadEngine(object_detection_engine); - slog::debug << "for test in createObjectDetection(), OK" << slog::endl; - return object_inference_ptr; -} - -std::shared_ptr -PipelineManager::createObjectSegmentation(const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.label, infer.model, infer.batch); - model->modelInit(); - slog::info << "Segmentation model initialized." << slog::endl; - auto engine = engine_manager_.createEngine(infer.engine, model); - slog::info << "Segmentation Engine initialized." << slog::endl; - auto segmentation_inference_ptr = std::make_shared( - infer.confidence_threshold); - slog::info << "Segmentation Inference instanced." << slog::endl; - segmentation_inference_ptr->loadNetwork(model); - segmentation_inference_ptr->loadEngine(engine); - - return segmentation_inference_ptr; -} - -std::shared_ptr -PipelineManager::createObjectSegmentationMaskrcnn(const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.label, infer.model, infer.batch); - model->modelInit(); - slog::info << "Segmentation model initialized." << slog::endl; - auto engine = engine_manager_.createEngine(infer.engine, model); - slog::info << "Segmentation Engine initialized." << slog::endl; - auto segmentation_inference_ptr = std::make_shared( - infer.confidence_threshold); - slog::info << "Segmentation Inference instanced." << slog::endl; - segmentation_inference_ptr->loadNetwork(model); - segmentation_inference_ptr->loadEngine(engine); - - return segmentation_inference_ptr; -} - -std::shared_ptr -PipelineManager::createPersonReidentification( - const Params::ParamManager::InferenceRawData & infer) -{ - std::shared_ptr person_reidentification_model; - std::shared_ptr reidentification_inference_ptr; - slog::debug << "for test in createPersonReidentification()"<(infer.label, infer.model, infer.batch); - person_reidentification_model->modelInit(); - slog::info << "Reidentification model initialized" << slog::endl; - auto person_reidentification_engine = engine_manager_.createEngine(infer.engine, person_reidentification_model); - reidentification_inference_ptr = - std::make_shared(infer.confidence_threshold); - slog::debug<< "for test in createPersonReidentification(), before loadNetwork"<loadNetwork(person_reidentification_model); - reidentification_inference_ptr->loadEngine(person_reidentification_engine); - slog::debug<< "for test in createPersonReidentification(), OK"< -PipelineManager::createVehicleAttribsDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.label, infer.model, infer.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto vehicle_attribs_ptr = - std::make_shared(); - vehicle_attribs_ptr->loadNetwork(model); - vehicle_attribs_ptr->loadEngine(engine); - - return vehicle_attribs_ptr; -} - -std::shared_ptr -PipelineManager::createLicensePlateDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.label, infer.model, infer.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto license_plate_ptr = - std::make_shared(); - license_plate_ptr->loadNetwork(model); - license_plate_ptr->loadEngine(engine); - - return license_plate_ptr; -} - -std::shared_ptr -PipelineManager::createPersonAttribsDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.label, infer.model, infer.batch); - slog::debug << "for test in createPersonAttributesDetection()"<modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto attribs_inference_ptr = - std::make_shared(infer.confidence_threshold); - attribs_inference_ptr->loadNetwork(model); - attribs_inference_ptr->loadEngine(engine); - - return attribs_inference_ptr; -} - -#if 0 -std::shared_ptr -PipelineManager::createPersonReidentification( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.model, infer.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto reidentification_inference_ptr = - std::make_shared(infer.confidence_threshold); - reidentification_inference_ptr->loadNetwork(model); - reidentification_inference_ptr->loadEngine(engine); - - return reidentification_inference_ptr; -} - -std::shared_ptr -PipelineManager::createPersonAttribsDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.model, infer.batch); - - model->modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto attribs_inference_ptr = - std::make_shared(infer.confidence_threshold); - attribs_inference_ptr->loadNetwork(model); - attribs_inference_ptr->loadEngine(engine); - - return attribs_inference_ptr; -} - -std::shared_ptr -PipelineManager::createLandmarksDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.model, infer.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto landmarks_inference_ptr = - std::make_shared(); - landmarks_inference_ptr->loadNetwork(model); - landmarks_inference_ptr->loadEngine(engine); - - return landmarks_inference_ptr; -} - -std::shared_ptr -PipelineManager::createFaceReidentification( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.model, infer.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto face_reid_ptr = - std::make_shared(infer.confidence_threshold); - face_reid_ptr->loadNetwork(model); - face_reid_ptr->loadEngine(engine); - - return face_reid_ptr; -} - -std::shared_ptr -PipelineManager::createVehicleAttribsDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.model, infer.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto vehicle_attribs_ptr = - std::make_shared(); - vehicle_attribs_ptr->loadNetwork(model); - vehicle_attribs_ptr->loadEngine(engine); - - return vehicle_attribs_ptr; -} - -std::shared_ptr -PipelineManager::createLicensePlateDetection( - const Params::ParamManager::InferenceRawData & infer) -{ - auto model = - std::make_shared(infer.model, infer.batch); - model->modelInit(); - auto engine = engine_manager_.createEngine(infer.engine, model); - auto license_plate_ptr = - std::make_shared(); - license_plate_ptr->loadNetwork(model); - license_plate_ptr->loadEngine(engine); - - return license_plate_ptr; -} -#endif - void PipelineManager::threadPipeline(const char * name) { PipelineData & p = pipelines_[name];