gstanalytics : Add tensor decoder element for yolo detection models
Existing tensor decoder has been bifurcated into two seperate gst element as: `yoloodv5tensordecoder`: decodes tensors output(masks) from detection-only models e.g yolov8s.onnx `yolsegv8tensordecoder`: decoder tensors output(masks and logits) from segementation models e.g FastSAM or yolov8s-seg
This commit is contained in:
parent
87b56fbf86
commit
62731c958c
@ -39,7 +39,8 @@ plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
ret |= GST_ELEMENT_REGISTER (ssd_object_detector, plugin);
|
||||
ret |= GST_ELEMENT_REGISTER (yolo_tensor_decoder, plugin);
|
||||
ret |= GST_ELEMENT_REGISTER (yolo_seg_tensor_decoder, plugin);
|
||||
ret |= GST_ELEMENT_REGISTER (yolo_od_tensor_decoder, plugin);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -33,9 +33,20 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_YOLO_TENSOR_DECODER (gst_yolo_tensor_decoder_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GstYoloTensorDecoder, gst_yolo_tensor_decoder,
|
||||
GST, YOLO_TENSOR_DECODER, GstBaseTransform)
|
||||
#define GST_TYPE_YOLO_OD_TENSOR_DECODER (gst_yolo_od_tensor_decoder_get_type ())
|
||||
#define GST_YOLO_OD_TENSOR_DECODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_YOLO_OD_TENSOR_DECODER, GstYoloOdTensorDecoder))
|
||||
#define GST_YOLO_OD_TENSOR_DECODER_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_YOLO_OD_TENSOR_DECODER, GstYoloOdTensorDecoderClass))
|
||||
#define GST_IS_YOLO_OD_TENSOR_DECODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_YOLO_OD_TENSOR_DECODER))
|
||||
#define GST_IS_YOLO_OD_TENSOR_DECODER_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_YOLO_OD_TENSOR_DECODER))
|
||||
#define GST_YOLO_OD_TENSOR_DECODER_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_YOLO_OD_TENSOR_DECODER, GstYoloOdTensorDecoderClass))
|
||||
|
||||
typedef struct _GstYoloOdTensorDecoder GstYoloOdTensorDecoder;
|
||||
typedef struct _GstYoloOdTensorDecoderClass GstYoloOdTensorDecoderClass;
|
||||
|
||||
typedef struct _BBox
|
||||
{
|
||||
@ -45,7 +56,7 @@ typedef struct _BBox
|
||||
guint h;
|
||||
} BBox;
|
||||
|
||||
struct _GstYoloTensorDecoder
|
||||
struct _GstYoloOdTensorDecoder
|
||||
{
|
||||
GstBaseTransform basetransform;
|
||||
/* Box confidence threshold */
|
||||
@ -57,52 +68,60 @@ struct _GstYoloTensorDecoder
|
||||
/* Maximum detection/mask */
|
||||
gsize max_detection;
|
||||
/* Video Info */
|
||||
GstVideoInfo video_info;
|
||||
|
||||
/* Candidates with a class confidence level above threshold. */
|
||||
GPtrArray *sel_candidates;
|
||||
|
||||
/* Final candidates selected that respect class confidence level,
|
||||
* NMS and maximum detection. */
|
||||
GPtrArray *selected;
|
||||
|
||||
/* Tensor-id identifying mask tensors out of yolo inference process. */
|
||||
GQuark mask_tensor_id;
|
||||
|
||||
/* Tensor-id identifying logits tensors out of yolo inference process. */
|
||||
GQuark logits_tensor_id;
|
||||
|
||||
/* Region of the mask that contain valid segmentation information */
|
||||
BBox mask_roi;
|
||||
|
||||
/* Scaling factor to convert bounding-box coordinates to mask coordinates */
|
||||
gfloat bb2mask_gain;
|
||||
|
||||
/* Mask width */
|
||||
guint mask_w;
|
||||
|
||||
/* Mask height */
|
||||
guint mask_h;
|
||||
|
||||
/* Mask length */
|
||||
gsize mask_length;
|
||||
|
||||
/* BufferPool for mask */
|
||||
GstBufferPool *mask_pool;
|
||||
|
||||
GstVideoInfo video_info;
|
||||
/* Labels file */
|
||||
gchar *label_file;
|
||||
|
||||
/* Labels */
|
||||
GArray *labels;
|
||||
/* GstAnalyticsODMtd data */
|
||||
GArray *od_mtds;
|
||||
/* Hash table to store the offset in the mask tensor buffer where
|
||||
* OdMtd data are stored. key is OdMtd.id */
|
||||
GHashTable *candidate_offsets;
|
||||
};
|
||||
|
||||
struct _GstYoloTensorDecoderClass
|
||||
struct _GstYoloOdTensorDecoderClass
|
||||
{
|
||||
GstBaseTransformClass parent_class;
|
||||
};
|
||||
|
||||
GST_ELEMENT_REGISTER_DECLARE (yolo_tensor_decoder)
|
||||
GType gst_yolo_od_tensor_decoder_get_type (void);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstYoloOdTensorDecoder, g_object_unref)
|
||||
|
||||
GST_ELEMENT_REGISTER_DECLARE (yolo_od_tensor_decoder)
|
||||
|
||||
/* Yolo segmentation tensor decoder */
|
||||
|
||||
#define GST_TYPE_YOLO_SEG_TENSOR_DECODER (gst_yolo_seg_tensor_decoder_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GstYoloSegTensorDecoder, gst_yolo_seg_tensor_decoder,
|
||||
GST, YOLO_SEG_TENSOR_DECODER, GstYoloOdTensorDecoder)
|
||||
|
||||
struct _GstYoloSegTensorDecoder
|
||||
{
|
||||
GstYoloOdTensorDecoder parent;
|
||||
/* Mask width */
|
||||
guint mask_w;
|
||||
/* Mask height */
|
||||
guint mask_h;
|
||||
/* Mask length */
|
||||
gsize mask_length;
|
||||
GQuark logits_tensor_id;
|
||||
gfloat bb2mask_gain;
|
||||
/* BufferPool for mask */
|
||||
BBox mask_roi;
|
||||
/* BufferPool for mask */
|
||||
GstBufferPool *mask_pool;
|
||||
};
|
||||
|
||||
GST_ELEMENT_REGISTER_DECLARE (yolo_seg_tensor_decoder)
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GST_YOLO_TENSOR_DECODER_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user