From 426173a0f9ca2e3aba3f47bf66fb77025a288128 Mon Sep 17 00:00:00 2001 From: Yelin Jeong Date: Tue, 14 May 2024 13:56:14 +0900 Subject: [PATCH] [decoder] Remove dependency from base class to derived class This patch removes dependency from Bounding box class to properties. setBoxDecodingMode does not need to be modified even if a new box property added. Signed-off-by: Yelin Jeong --- .../tensor_decoder/box_properties/mobilenetssd.cc | 58 +++++++++ .../box_properties/mobilenetssdpp.cc | 56 +++++++++ .../box_properties/mppalmdetection.cc | 56 +++++++++ .../tensor_decoder/box_properties/ovdetection.cc | 59 +++++++++ .../tensor_decoder/box_properties/yolo.cc | 97 +++++++++++++++ .../tensor_decoder/tensordec-boundingbox.cc | 106 +++++++++++------ .../tensor_decoder/tensordec-boundingbox.h | 132 +-------------------- 7 files changed, 400 insertions(+), 164 deletions(-) diff --git a/ext/nnstreamer/tensor_decoder/box_properties/mobilenetssd.cc b/ext/nnstreamer/tensor_decoder/box_properties/mobilenetssd.cc index 316c3ee..1e0ec1c 100644 --- a/ext/nnstreamer/tensor_decoder/box_properties/mobilenetssd.cc +++ b/ext/nnstreamer/tensor_decoder/box_properties/mobilenetssd.cc @@ -32,9 +32,34 @@ #define H_SCALE_DEFAULT (5.0f) #define W_SCALE_DEFAULT (5.0f) +#define BOX_SIZE (4) +#define DETECTION_MAX (2034) /* add ssd_mobilenet v3 support */ +#define PARAMS_MAX (6) + #define _expit(x) (1.f / (1.f + expf (-((float) x)))) /** + * @brief Class for MobilenetSSD box properties + */ +class MobilenetSSD : public BoxProperties +{ + public: + MobilenetSSD (); + ~MobilenetSSD (); + int mobilenet_ssd_loadBoxPrior (); + + int setOptionInternal (const char *param); + int checkCompatible (const GstTensorsConfig *config); + GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); + + private: + char *box_prior_path; /**< Box Prior file path */ + gfloat box_priors[BOX_SIZE][DETECTION_MAX + 1]; /** loaded box prior */ + gfloat params[PARAMS_MAX]; /** Post Processing parameters */ + gfloat sigmoid_threshold; /** Inverse value of valid detection threshold in sigmoid domain */ +}; + +/** * @brief C++-Template-like box location calculation for box-priors * @bug This is not macro-argument safe. Use paranthesis! * @param[in] bb The configuration, "bounding_boxes" @@ -135,6 +160,17 @@ logit (float x) return log (x / (1.0 - x)); } +static BoxProperties *mobilenet = nullptr; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +void init_properties_mobilenetssd (void) __attribute__ ((constructor)); +void fini_properties_mobilenetssd (void) __attribute__ ((destructor)); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + /** @brief Constructor of MobilenetSSD */ MobilenetSSD::MobilenetSSD () { @@ -149,6 +185,13 @@ MobilenetSSD::MobilenetSSD () max_detection = 0; total_labels = 0; box_prior_path = nullptr; + name = g_strdup_printf ("mobilenet-ssd"); +} + +/** @brief Destructor of MobilenetSSD */ +MobilenetSSD::~MobilenetSSD () +{ + g_free (name); } /** @@ -360,3 +403,18 @@ MobilenetSSD::decode (const GstTensorsConfig *config, const GstTensorMemory *inp nms (results, params[IOU_THRESHOLD_IDX]); return results; } + +/** @brief Initialize this object for tensor decoder bounding box */ +void +init_properties_mobilenetssd () +{ + mobilenet = new MobilenetSSD (); + BoundingBox::addProperties (mobilenet); +} + +/** @brief Destruct this object for tensor decoder bounding box */ +void +fini_properties_mobilenetssd () +{ + delete mobilenet; +} diff --git a/ext/nnstreamer/tensor_decoder/box_properties/mobilenetssdpp.cc b/ext/nnstreamer/tensor_decoder/box_properties/mobilenetssdpp.cc index 570d3be..63dad0a 100644 --- a/ext/nnstreamer/tensor_decoder/box_properties/mobilenetssdpp.cc +++ b/ext/nnstreamer/tensor_decoder/box_properties/mobilenetssdpp.cc @@ -23,6 +23,7 @@ #define CLASSES_IDX (1) #define SCORES_IDX (2) #define NUM_IDX (3) +#define MAX_TENSORS (4U) #define LOCATIONS_DEFAULT (3) #define CLASSES_DEFAULT (1) @@ -31,6 +32,25 @@ #define THRESHOLD_DEFAULT (G_MINFLOAT) /** + * @brief Class for MobilenetSSDPP box properties + */ +class MobilenetSSDPP : public BoxProperties +{ + public: + MobilenetSSDPP (); + ~MobilenetSSDPP (); + int get_mobilenet_ssd_pp_tensor_idx (int idx); + + int setOptionInternal (const char *param); + int checkCompatible (const GstTensorsConfig *config); + GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); + + private: + gint tensor_mapping[MAX_TENSORS]; /* Output tensor index mapping */ + gfloat threshold; /* Detection threshold */ +}; + +/** * @brief C++-Template-like box location calculation for Tensorflow SSD model * @param[in] type The tensor type of inputptr * @param[in] typename nnstreamer enum corresponding to the type @@ -82,6 +102,17 @@ _get_objects_mobilenet_ssd_pp (type, typename, (mem_num->data), (mem_classes->data), \ (mem_scores->data), (mem_boxes->data), config, results, i_width, i_height) +static BoxProperties *mobilenetpp = nullptr; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +void init_properties_mobilenetssd_pp (void) __attribute__ ((constructor)); +void fini_properties_mobilenetssd_pp (void) __attribute__ ((destructor)); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + /** * @brief MOBILENET SSD PostProcess Output tensor feature mapping. */ @@ -93,6 +124,8 @@ typedef enum { MOBILENET_SSD_PP_BBOX_IDX_UNKNOWN } mobilenet_ssd_pp_bbox_idx_t; + +/** @brief Constructor of MobilenetSSDPP */ MobilenetSSDPP::MobilenetSSDPP () { tensor_mapping[LOCATIONS_IDX] = LOCATIONS_DEFAULT; @@ -100,6 +133,14 @@ MobilenetSSDPP::MobilenetSSDPP () tensor_mapping[SCORES_IDX] = SCORES_DEFAULT; tensor_mapping[NUM_IDX] = NUM_DEFAULT; threshold = THRESHOLD_DEFAULT; + name = g_strdup_printf ("mobilenet-ssd-postprocess"); +} + + +/** @brief Destructor of MobilenetSSDPP */ +MobilenetSSDPP::~MobilenetSSDPP () +{ + g_free (name); } /** @brief Helper to retrieve tensor index by feature */ @@ -236,3 +277,18 @@ MobilenetSSDPP::decode (const GstTensorsConfig *config, const GstTensorMemory *i } return results; } + +/** @brief Initialize this object for tensor decoder bounding box */ +void +init_properties_mobilenetssd_pp () +{ + mobilenetpp = new MobilenetSSDPP (); + BoundingBox::addProperties (mobilenetpp); +} + +/** @brief Destruct this object for tensor decoder bounding box */ +void +fini_properties_mobilenetssd_pp () +{ + delete mobilenetpp; +} diff --git a/ext/nnstreamer/tensor_decoder/box_properties/mppalmdetection.cc b/ext/nnstreamer/tensor_decoder/box_properties/mppalmdetection.cc index b529003..33200e4 100644 --- a/ext/nnstreamer/tensor_decoder/box_properties/mppalmdetection.cc +++ b/ext/nnstreamer/tensor_decoder/box_properties/mppalmdetection.cc @@ -32,6 +32,34 @@ #define MIN_SCORE_THRESHOLD_DEFAULT (0.5) #define PARAMS_STRIDE_SIZE (8) +#define PARAMS_MAX (13) + +/** + * @brief Class for MpPalmDetection box properties + */ +class MpPalmDetection : public BoxProperties +{ + public: + MpPalmDetection (); + ~MpPalmDetection (); + void mp_palm_detection_generate_anchors (); + int setOptionInternal (const char *param); + int checkCompatible (const GstTensorsConfig *config); + + GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); + + private: + gint num_layers; + /** Number of stride layers */ + gfloat min_scale; /** Minimum scale */ + gfloat max_scale; /** Maximum scale */ + gfloat offset_x; /** anchor X offset */ + gfloat offset_y; /** anchor Y offset */ + gint strides[PARAMS_MAX]; /** Stride data for each layers */ + gfloat min_score_threshold; /** minimum threshold of score */ + + GArray *anchors; +}; /** * @brief C++-Template-like box location calculation for Tensorflow model @@ -107,6 +135,17 @@ _calculate_scale (float min_scale, float max_scale, int stride_index, int num_st } } +static BoxProperties *mp_palm_detection = nullptr; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +void init_properties_mp_palm_detection (void) __attribute__ ((constructor)); +void fini_properties_mp_palm_detection (void) __attribute__ ((destructor)); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + /** * @brief Generate anchor information */ @@ -193,6 +232,7 @@ MpPalmDetection::MpPalmDetection () strides[3] = STRIDE_3_DEFAULT; min_score_threshold = MIN_SCORE_THRESHOLD_DEFAULT; anchors = g_array_new (FALSE, TRUE, sizeof (anchor)); + name = g_strdup_printf ("mp-palm-detection"); } /** @brief Destructor of MpPalmDetection */ @@ -201,6 +241,7 @@ MpPalmDetection::~MpPalmDetection () if (anchors) g_array_free (anchors, TRUE); anchors = NULL; + g_free (name); } /** @brief Set internal option of MpPalmDetection @@ -316,3 +357,18 @@ MpPalmDetection::decode (const GstTensorsConfig *config, const GstTensorMemory * nms (results, 0.05f); return results; } + +/** @brief Initialize this object for tensor decoder bounding box */ +void +init_properties_mp_palm_detection () +{ + mp_palm_detection = new MpPalmDetection (); + BoundingBox::addProperties (mp_palm_detection); +} + +/** @brief Destruct this object for tensor decoder bounding box */ +void +fini_properties_mp_palm_detection () +{ + delete mp_palm_detection; +} diff --git a/ext/nnstreamer/tensor_decoder/box_properties/ovdetection.cc b/ext/nnstreamer/tensor_decoder/box_properties/ovdetection.cc index fcb141d..e1dd8db 100644 --- a/ext/nnstreamer/tensor_decoder/box_properties/ovdetection.cc +++ b/ext/nnstreamer/tensor_decoder/box_properties/ovdetection.cc @@ -17,6 +17,27 @@ #include "../tensordec-boundingbox.h" #define OV_PERSON_DETECTION_CONF_THRESHOLD (0.8) +#define DETECTION_MAX (200U) +#define DEFAULT_MAX_TENSORS (1) +#define DEFAULT_SIZE_DETECTION_DESC (7) + +/** + * @brief Class for OVDetection box properties + */ +class OVDetection : public BoxProperties +{ + public: + OVDetection (); + ~OVDetection (); + int setOptionInternal (const char *param) + { + UNUSED (param); + return TRUE; + } + int checkCompatible (const GstTensorsConfig *config); + GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); +}; + /** * @brief C++-Template-like box location calculation for OpenVino Person Detection Model * @param[in] type The tensor type of inputptr @@ -66,6 +87,29 @@ } \ break +static BoxProperties *ov_detection = nullptr; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +void init_properties_ovdetection (void) __attribute__ ((constructor)); +void fini_properties_ovdetection (void) __attribute__ ((destructor)); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/** @brief Constructor of OVDetection */ +OVDetection::OVDetection () +{ + name = g_strdup_printf ("ov-person-detection"); +} + +/** @brief Destructor of OVDetection */ +OVDetection::~OVDetection () +{ + g_free (name); +} + /** @brief Check compatibility of given tensors config */ int OVDetection::checkCompatible (const GstTensorsConfig *config) @@ -121,3 +165,18 @@ OVDetection::decode (const GstTensorsConfig *config, const GstTensorMemory *inpu } return results; } + +/** @brief Initialize this object for tensor decoder bounding box */ +void +init_properties_ovdetection () +{ + ov_detection = new OVDetection (); + BoundingBox::addProperties (ov_detection); +} + +/** @brief Destruct this object for tensor decoder bounding box */ +void +fini_properties_ovdetection () +{ + delete ov_detection; +} diff --git a/ext/nnstreamer/tensor_decoder/box_properties/yolo.cc b/ext/nnstreamer/tensor_decoder/box_properties/yolo.cc index 1ec34b6..4328071 100644 --- a/ext/nnstreamer/tensor_decoder/box_properties/yolo.cc +++ b/ext/nnstreamer/tensor_decoder/box_properties/yolo.cc @@ -22,12 +22,72 @@ #define DEFAULT_DETECTION_NUM_INFO_YOLO5 (5) #define DEFAULT_DETECTION_NUM_INFO_YOLO8 (4) +/** + * @brief Class for YoloV5 box properties + */ +class YoloV5 : public BoxProperties +{ + public: + YoloV5 (); + ~YoloV5 (); + int setOptionInternal (const char *param); + int checkCompatible (const GstTensorsConfig *config); + GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); + + private: + /* From option3, whether the output values are scaled or not */ + int scaled_output; + gfloat conf_threshold; + gfloat iou_threshold; +}; + +/** + * @brief Class for YoloV8 box properties + */ +class YoloV8 : public BoxProperties +{ + public: + YoloV8 (); + ~YoloV8 (); + int setOptionInternal (const char *param); + int checkCompatible (const GstTensorsConfig *config); + GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); + + private: + /* From option3, whether the output values are scaled or not */ + int scaled_output; + gfloat conf_threshold; + gfloat iou_threshold; +}; + +static BoxProperties *yolo5 = nullptr; +static BoxProperties *yolo8 = nullptr; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +void init_properties_yolo5 (void) __attribute__ ((constructor)); +void fini_properties_yolo5 (void) __attribute__ ((destructor)); + +void init_properties_yolo8 (void) __attribute__ ((constructor)); +void fini_properties_yolo8 (void) __attribute__ ((destructor)); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + /** @brief Constructor of YoloV5 */ YoloV5::YoloV5 () { scaled_output = 0; conf_threshold = YOLO_DETECTION_CONF_THRESHOLD; iou_threshold = YOLO_DETECTION_IOU_THRESHOLD; + name = g_strdup_printf ("yolov5"); +} + +/** @brief Destructor of YoloV5 */ +YoloV5::~YoloV5 () +{ + g_free (name); } /** @brief Set internal option of YoloV5 @@ -153,6 +213,13 @@ YoloV8::YoloV8 () scaled_output = 0; conf_threshold = YOLO_DETECTION_CONF_THRESHOLD; iou_threshold = YOLO_DETECTION_IOU_THRESHOLD; + name = g_strdup_printf ("yolov8"); +} + +/** @brief Destructor of YoloV8 */ +YoloV8::~YoloV8 () +{ + g_free (name); } /** @brief Set internal option of YoloV8 */ @@ -285,3 +352,33 @@ YoloV8::decode (const GstTensorsConfig *config, const GstTensorMemory *input) nms (results, iou_threshold); return results; } + +/** @brief Initialize this object for tensor decoder bounding box */ +void +init_properties_yolo5 () +{ + yolo5 = new YoloV5 (); + BoundingBox::addProperties (yolo5); +} + +/** @brief Destruct this object for tensor decoder bounding box */ +void +fini_properties_yolo5 () +{ + delete yolo5; +} + +/** @brief Initialize this object for tensor decoder bounding box */ +void +init_properties_yolo8 () +{ + yolo8 = new YoloV8 (); + BoundingBox::addProperties (yolo8); +} + +/** @brief Destruct this object for tensor decoder bounding box */ +void +fini_properties_yolo8 () +{ + delete yolo8; +} diff --git a/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.cc b/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.cc index a99b81d..7e18758 100644 --- a/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.cc +++ b/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.cc @@ -51,6 +51,11 @@ void fini_bb (void) __attribute__ ((destructor)); } #endif /* __cplusplus */ +/** + * @brief mutex for box properties table. + */ +G_LOCK_DEFINE_STATIC (box_properties_table); + /* font.c */ extern uint8_t rasters[][13]; @@ -77,6 +82,23 @@ static const char *bb_modes[] = { NULL, }; +/** + * @brief Change deprecated mode name + */ +static const char * +updateDecodingMode (const char *param) +{ + if (g_strcmp0 (param, bb_modes[OLDNAME_MOBILENET_SSD_BOUNDING_BOX]) == 0) { + return bb_modes[MOBILENET_SSD_BOUNDING_BOX]; + } + + if (g_strcmp0 (param, bb_modes[OLDNAME_MOBILENET_SSD_PP_BOUNDING_BOX]) == 0) { + return bb_modes[MOBILENET_SSD_PP_BOUNDING_BOX]; + } + + return param; +} + /** @brief tensordec-plugin's GstTensorDecoderDef callback */ static int bb_init (void **pdata) @@ -399,10 +421,10 @@ BoundingBox::~BoundingBox () if (label_path) g_free (label_path); - if (bdata) { - delete bdata; - bdata = nullptr; - } + G_LOCK (box_properties_table); + g_hash_table_destroy (properties_table); + properties_table = nullptr; + G_UNLOCK (box_properties_table); } /** @@ -688,45 +710,15 @@ BoundingBox::checkLabelProps () int BoundingBox::setBoxDecodingMode (const char *param) { - bounding_box_modes previous = mode; - if (NULL == param || *param == '\0') { GST_ERROR ("Please set the valid mode at option1 to set box decoding mode"); return FALSE; } - mode = static_cast (find_key_strv (bb_modes, param)); - - if (mode != previous && mode != BOUNDING_BOX_UNKNOWN) { - if (previous != BOUNDING_BOX_UNKNOWN) { - delete bdata; - } - - switch (mode) { - case MOBILENET_SSD_BOUNDING_BOX: - case OLDNAME_MOBILENET_SSD_BOUNDING_BOX: - bdata = new MobilenetSSD (); - break; - case MOBILENET_SSD_PP_BOUNDING_BOX: - case OLDNAME_MOBILENET_SSD_PP_BOUNDING_BOX: - bdata = new MobilenetSSDPP (); - break; - case OV_PERSON_DETECTION_BOUNDING_BOX: - case OV_FACE_DETECTION_BOUNDING_BOX: - bdata = new OVDetection (); - break; - case YOLOV5_BOUNDING_BOX: - bdata = new YoloV5 (); - break; - case YOLOV8_BOUNDING_BOX: - bdata = new YoloV8 (); - break; - case MP_PALM_DETECTION_BOUNDING_BOX: - bdata = new MpPalmDetection (); - break; - default: - return FALSE; - } + bdata = getProperties (updateDecodingMode (param)); + if (bdata == nullptr) { + nns_loge ("Could not find box properties name %s", param); + return FALSE; } return TRUE; @@ -945,3 +937,41 @@ error_free: return GST_FLOW_ERROR; } + +/** + * @brief Get bounding box properties from hash table + */ +BoxProperties * +BoundingBox::getProperties (const gchar *properties_name) +{ + gpointer data; + G_LOCK (box_properties_table); + if (properties_table == nullptr) { + properties_table = g_hash_table_new (g_str_hash, g_str_equal); + } + data = g_hash_table_lookup (properties_table, properties_name); + G_UNLOCK (box_properties_table); + + return static_cast (data); +} + +/** + * @brief Add bounding box properties into hash table + */ +gboolean +BoundingBox::addProperties (BoxProperties *boxProperties) +{ + BoxProperties *data; + gboolean ret; + + data = getProperties (boxProperties->name); + if (NULL != data) { + return TRUE; + } + + G_LOCK (box_properties_table); + ret = g_hash_table_insert (properties_table, boxProperties->name, boxProperties); + G_UNLOCK (box_properties_table); + + return ret; +} diff --git a/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.h b/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.h index 43729ad..4a2efdb 100644 --- a/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.h +++ b/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.h @@ -241,6 +241,7 @@ class BoxProperties { return i_height; } + gchar *name; protected: guint i_width; /**< Input Video Width */ @@ -273,6 +274,9 @@ class BoundingBox GstFlowReturn decode (const GstTensorsConfig *config, const GstTensorMemory *input, GstBuffer *outbuf); + static BoxProperties *getProperties (const gchar *properties_name); + static gboolean addProperties (BoxProperties *boxProperties); + private: bounding_box_modes mode; BoxProperties *bdata; @@ -298,133 +302,9 @@ class BoundingBox gint do_log; gboolean flag_use_label; -}; - -/** - * @brief Class for MobilenetSSD box properties - */ -class MobilenetSSD : public BoxProperties -{ - public: - MobilenetSSD (); - int mobilenet_ssd_loadBoxPrior (); - - int setOptionInternal (const char *param); - int checkCompatible (const GstTensorsConfig *config); - GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); - - static const int BOX_SIZE = 4; - static const int DETECTION_MAX = 2034; /* add ssd_mobilenet v3 support */ - static const int PARAMS_MAX = 6; - - private: - char *box_prior_path; /**< Box Prior file path */ - gfloat box_priors[BOX_SIZE][DETECTION_MAX + 1]; /** loaded box prior */ - gfloat params[PARAMS_MAX]; /** Post Processing parameters */ - gfloat sigmoid_threshold; /** Inverse value of valid detection threshold in sigmoid domain */ -}; - -/** - * @brief Class for MobilenetSSDPP box properties - */ -class MobilenetSSDPP : public BoxProperties -{ - public: - MobilenetSSDPP (); - int get_mobilenet_ssd_pp_tensor_idx (int idx); - - int setOptionInternal (const char *param); - int checkCompatible (const GstTensorsConfig *config); - GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); - - static const guint MAX_TENSORS = 4U; - - private: - gint tensor_mapping[MAX_TENSORS]; /* Output tensor index mapping */ - gfloat threshold; /* Detection threshold */ -}; - -/** - * @brief Class for OVDetection box properties - */ -class OVDetection : public BoxProperties -{ - public: - int setOptionInternal (const char *param) - { - UNUSED (param); - return TRUE; - } - int checkCompatible (const GstTensorsConfig *config); - GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); - - static const guint DETECTION_MAX = 200U; - static const guint DEFAULT_MAX_TENSORS = 1; - static const guint DEFAULT_SIZE_DETECTION_DESC = 7; -}; - -/** - * @brief Class for YoloV5 box properties - */ -class YoloV5 : public BoxProperties -{ - public: - YoloV5 (); - int setOptionInternal (const char *param); - int checkCompatible (const GstTensorsConfig *config); - GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); - private: - /* From option3, whether the output values are scaled or not */ - int scaled_output; - gfloat conf_threshold; - gfloat iou_threshold; + /* Table for box properties data */ + inline static GHashTable *properties_table; }; -/** - * @brief Class for YoloV8 box properties - */ -class YoloV8 : public BoxProperties -{ - public: - YoloV8 (); - int setOptionInternal (const char *param); - int checkCompatible (const GstTensorsConfig *config); - GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); - - private: - /* From option3, whether the output values are scaled or not */ - int scaled_output; - gfloat conf_threshold; - gfloat iou_threshold; -}; - -/** - * @brief Class for MpPalmDetection box properties - */ -class MpPalmDetection : public BoxProperties -{ - public: - MpPalmDetection (); - ~MpPalmDetection (); - void mp_palm_detection_generate_anchors (); - int setOptionInternal (const char *param); - int checkCompatible (const GstTensorsConfig *config); - - GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input); - - static const int PARAMS_MAX = 13; - - private: - gint num_layers; - /** Number of stride layers */ - gfloat min_scale; /** Minimum scale */ - gfloat max_scale; /** Maximum scale */ - gfloat offset_x; /** anchor X offset */ - gfloat offset_y; /** anchor Y offset */ - gint strides[PARAMS_MAX]; /** Stride data for each layers */ - gfloat min_score_threshold; /** minimum threshold of score */ - - GArray *anchors; -}; #endif /* _TENSORDECBB_H__ */ -- 2.7.4