GStreamer Video Analytics (GVA) Plugin
|
Go to the documentation of this file.
18 #include <gst/video/gstvideometa.h>
70 const std::vector<T>
data()
const {
74 return std::vector<T>();
75 return std::vector<T>((T *)
data, (T *)((
char *)
data + size));
82 std::vector<guint>
dims()
const {
83 GValueArray *arr = NULL;
84 gst_structure_get_array(
_structure,
"dims", &arr);
85 std::vector<guint>
dims;
87 for (guint i = 0; i < arr->n_values; ++i)
88 dims.push_back(g_value_get_uint(g_value_array_get_nth(arr, i)));
89 g_value_array_free(arr);
147 return std::string(
name);
148 return std::string{};
168 throw std::runtime_error(
"Detection GVA::Tensor can't have label.");
175 std::vector<std::string>
fields()
const {
176 std::vector<std::string>
fields;
177 int fields_count = gst_structure_n_fields(
_structure);
178 if (fields_count <= 0)
181 fields.reserve(fields_count);
182 for (
int i = 0; i < fields_count; ++i)
193 return gst_structure_has_field(
_structure, field_name.c_str());
203 std::string
get_string(
const std::string &field_name,
const std::string &default_value = std::string())
const {
204 const gchar *val = gst_structure_get_string(
_structure, field_name.c_str());
205 return (val) ? std::string(val) : default_value;
214 int get_int(
const std::string &field_name, int32_t default_value = 0)
const {
215 gint val = default_value;
216 gst_structure_get_int(
_structure, field_name.c_str(), &val);
226 double get_double(
const std::string &field_name,
double default_value = 0)
const {
227 double val = default_value;
228 gst_structure_get_double(
_structure, field_name.c_str(), &val);
237 void set_string(
const std::string &field_name,
const std::string &value) {
238 gst_structure_set(
_structure, field_name.c_str(), G_TYPE_STRING, value.c_str(), NULL);
246 void set_int(
const std::string &field_name,
int value) {
247 gst_structure_set(
_structure, field_name.c_str(), G_TYPE_INT, value, NULL);
255 void set_double(
const std::string &field_name,
double value) {
256 gst_structure_set(
_structure, field_name.c_str(), G_TYPE_DOUBLE, value, NULL);
274 throw std::runtime_error(
"Detection GVA::Tensor can't have label.");
283 switch (precision_value) {
289 return "UNSPECIFIED";
299 switch (layout_value) {
333 return name() ==
"detection";
343 throw std::invalid_argument(
"GVA::Tensor: structure is nullptr");
363 #endif // __TENSOR_H__
GstStructure * gst_structure() const
Get ptr to underlying GstStructure.
Definition: tensor.h:350
Precision precision() const
Get inference output blob precision.
Definition: tensor.h:98
std::string label() const
Get label. This label is set for Tensor instances produced by gvaclassify element....
Definition: tensor.h:164
Tensor(GstStructure *structure)
Construct Tensor instance from GstStructure. Tensor does not own structure, so if you use this consrt...
Definition: tensor.h:341
double get_double(const std::string &field_name, double default_value=0) const
Get double contained in value stored at field_name.
Definition: tensor.h:226
Precision
Describes tensor precision.
Definition: tensor.h:48
double confidence() const
Get confidence of detection or classification result extracted from the tensor.
Definition: tensor.h:155
bool has_field(const std::string &field_name) const
Check if Tensor instance has field.
Definition: tensor.h:192
std::string layer_name() const
Get inference result blob layer name.
Definition: tensor.h:120
void set_label(const std::string &label)
Set label. It will throw an exception if called for detection Tensor.
Definition: tensor.h:270
This class represents audio frame - object for working with AudioEvent and Tensor objects which belon...
Definition: audio_frame.h:42
std::vector< std::string > fields() const
Get vector of fields contained in Tensor instance.
Definition: tensor.h:175
void set_int(const std::string &field_name, int value)
Set field_name with int value.
Definition: tensor.h:246
std::string layout_as_string() const
Get inference result blob layout as a string.
Definition: tensor.h:297
std::string format() const
Get data format as specified in model pre/post-processing json configuration.
Definition: tensor.h:136
int label_id() const
Get label id.
Definition: tensor.h:324
int get_int(const std::string &field_name, int32_t default_value=0) const
Get int contained in value stored at field_name.
Definition: tensor.h:214
std::string element_id() const
Get inference-id property value of GVA element from which this Tensor came.
Definition: tensor.h:315
GstStructure * _structure
ptr to GstStructure that contains all tensor (inference results) data & info.
Definition: tensor.h:358
std::string name() const
Get tensor name as a string.
Definition: tensor.h:144
const std::vector< T > data() const
Get raw inference output blob data.
Definition: tensor.h:70
bool is_detection() const
Check if this Tensor is detection Tensor (contains detection results)
Definition: tensor.h:332
This class represents tensor - map-like storage for inference result information, such as output blob...
Definition: tensor.h:38
std::string get_string(const std::string &field_name, const std::string &default_value=std::string()) const
Get string contained in value stored at field_name.
Definition: tensor.h:203
std::vector< guint > dims() const
Get inference result blob dimensions info.
Definition: tensor.h:82
void set_double(const std::string &field_name, double value)
Set field_name with double value.
Definition: tensor.h:255
Layout layout() const
Get inference result blob layout.
Definition: tensor.h:109
void set_string(const std::string &field_name, const std::string &value)
Set field_name with string value.
Definition: tensor.h:237
This class represents video frame - object for working with RegionOfInterest and Tensor objects which...
Definition: video_frame.h:43
void set_name(const std::string &name)
Set Tensor instance's name.
Definition: tensor.h:262
std::string precision_as_string() const
Get inference result blob precision as a string.
Definition: tensor.h:281
std::string model_name() const
Get model name which was used for inference.
Definition: tensor.h:128
Layout
Describes tensor layout.
Definition: tensor.h:57