Difference between revisions of "GstInference/Metadatas/GstEmbeddingMeta"
< GstInference | Metadatas
Maumontero (talk | contribs) |
m |
||
Line 6: | Line 6: | ||
{{DISPLAYTITLE:GstInference - <descriptive page name>|noerror}} | {{DISPLAYTITLE:GstInference - <descriptive page name>|noerror}} | ||
--> | --> | ||
+ | |||
+ | {{DISPLAYTITLE:GstInference and GstEmbeddingMeta metadata|noerror}} | ||
This metadata consist on a variable size elements array, that is filed with the embedding produced by the net, like facenet that uses a 128 elements array size. | This metadata consist on a variable size elements array, that is filed with the embedding produced by the net, like facenet that uses a 128 elements array size. | ||
Line 11: | Line 13: | ||
[[File:gst_inference_GstEmbeddingMetaf.png|500px|center|thumb|GstEmbeddingMeta example]] | [[File:gst_inference_GstEmbeddingMetaf.png|500px|center|thumb|GstEmbeddingMeta example]] | ||
− | =Fields= | + | ==Fields== |
The facenet element and embedding overlay uses similar metadata as the classification plugins. GstEmbeddingMeta consist on the following fields: | The facenet element and embedding overlay uses similar metadata as the classification plugins. GstEmbeddingMeta consist on the following fields: | ||
Line 29: | Line 31: | ||
|} | |} | ||
− | =Access metadata= | + | ==Access metadata== |
If you want to access this metadata from your custom Gstreamer element instead the process is fairly easy: | If you want to access this metadata from your custom Gstreamer element instead the process is fairly easy: | ||
# Add the [[GstInference/Supported architectures/FaceNet|Facenet]] element to your pipeline | # Add the [[GstInference/Supported architectures/FaceNet|Facenet]] element to your pipeline |
Revision as of 13:56, 31 January 2020
Make sure you also check GstInference's companion project: R2Inference |
This metadata consist on a variable size elements array, that is filed with the embedding produced by the net, like facenet that uses a 128 elements array size.
Fields
The facenet element and embedding overlay uses similar metadata as the classification plugins. GstEmbeddingMeta consist on the following fields:
field | type | description |
---|---|---|
num_dimensions | gint | The number of labels outputted by the model. This can vary from model to model. Facenet uses 128. |
embedding | gdouble * | The embedding produced by the network |
Access metadata
If you want to access this metadata from your custom Gstreamer element instead the process is fairly easy:
- Add the Facenet element to your pipeline
- Include GstInference metadata header:
#include "gst/r2inference/gstinferencemeta.h"
- Get a GstClassificationMeta object from the buffer:
class_meta = (GstClassificationMeta *) gst_buffer_get_meta (frame->buffer, GST_CLASSIFICATION_META_API_TYPE);
FaceNet also raises a signal containing GstClassificationMeta, for details on how to use this signal please check the example applications section.
In the following section of code, we add the include like in point 2 and safe the GstClassificationMeta in the class_meta variable like in point 3.
1 #include "gst/r2inference/gstinferencemeta.h"
2 static void
3 get_buffer(GstPadProbeInfo * info)
4 {
5 GstBuffer *buffer;
6 GstDetectionMeta *meta;
7 buffer = gst_pad_probe_info_get_buffer (info);
8 class_meta = (GstClassificationMeta *) gst_buffer_get_meta (buffer,
9 GST_DETECTION_META_API_TYPE);
10
11 g_print ("Dimension: 0 has embedding %f\n", class_meta->embedding[0]);
12 }