GStreamer - ZED Metadata

Open in ClaudeOpen in ChatGPT

The stream of data injected in a GStreamer pipeline by the zedsrc element contains color and depth information plus metadata with sensors and object detection data.

The ZED metadata are defined in the GStreamer library gstzedmeta.

Metadata information

  • GstZedSrcMeta: metadata global container
  • ZedInfo: general information about the ZED camera that acquired the data.
  • ZedPose: Positional Tracking information.
  • ZedSensors: data from the camera sensors (if available).
  • ZedImu: 6 DOF inertial data (if available).
  • ZedMag: 3 DOF magnetic field data (if available).
  • ZedEnv: environmental data, atmospheric pressure and internal temperature (if available).
  • ZedCamTemp: camera CMOS temperatures (if available).
  • ZedObjectData: object detection data (if available).

Data Structures

GstZedSrcMeta

C++
1struct _GstZedSrcMeta {
2 GstMeta meta;
3
4 ZedInfo info;
5
6 ZedPose pose;
7 ZedSensors sens;
8
9 gboolean od_enabled;
10 guint8 obj_count;
11 guint64 frame_id;
12 ZedObjectData objects[256];
13};
  • meta: metadata identifier field.
  • info: camera information.
  • pose: camera pose.
  • sens: sensors data.
  • od_enabled: indicates if object detection data are available.
  • obj_count: the number of detected objects [max 256].
  • frame_id: track the meta/buffer throughout the GStreamer pipeline (when working with source code)
  • objects: array of detected objects.

ZedInfo

C++
1struct _ZedInfo {
2 gint cam_model;
3 gint stream_type;
4 guint grab_single_frame_width;
5 guint grab_single_frame_height;
6};
  • cam_model: camera model (0 : ZED, 1 : ZED Mini, 2 : ZED2).
  • stream_type: type of stream (0 : Left Image, 1 : Right image, 2 : Stereo couple, 3 : 16 bit depth map, 4 : Left + Depth).
  • grab_single_frame_width: original width of image data.
  • grab_single_frame_height: original height of image data.

ZedPose

C++
1struct _ZedPose {
2 gboolean pose_avail;
3 gint pos_tracking_state;
4 gfloat pos[3];
5 gfloat orient[3];
6};
  • pose_avail: indicates if camera pose is available.
  • pos_tracking_state: status of the Positional Tracking algorithm (0 : SEARCHING, 1 : OK, 2 : OFF, 3 : FPS_TOO_LOW)
  • pos: camera position
  • orient: camera orientation (Eurel Angles).

ZedSensors

C++
1struct _ZedSensors {
2 gboolean sens_avail;
3 ZedImu imu;
4 ZedMag mag;
5 ZedEnv env;
6 ZedCamTemp temp;
7};
  • sens_avail: indicates if sensors data are available (only with ZED2 and ZED Mini).
  • imu: IMU data.
  • mag: Magnetometer data.
  • env: environment data.
  • temp: camera temperatures data

An example about how to retrieve Sensors data is provided with the gstzeddatacsvsink element source code

ZedImu

C++
1struct _ZedImu {
2 gboolean imu_avail;
3 gfloat acc[3];
4 gfloat gyro[3];
5 gfloat temp;
6};
  • imu_avail: indicates if IMU data are available (only with ZED2 and ZED Mini).
  • acc: 3 DOF accelerometer data in [m/s²].
  • gyro: 3 DOF gyroscope data in [rad/sec].
  • temp: IMU temperature in [°C].

ZedMag

C++
1struct _ZedMag {
2 gboolean mag_avail;
3 gfloat mag[3];
4};
  • mag_avail: indicates if magnetometer data are available (only with ZED2).
  • mag: 3 DOF magnetic field data in [µT].

ZedEnv

C++
1struct _ZedEnv {
2 gboolean env_avail;
3 gfloat press;
4 gfloat temp;
5};
  • env_avail: indicates if environment data are available (only with ZED2).
  • press: atmospheric pressure in [hPa].
  • temp: internal camera temperature in [°C].

ZedCamTemp

C++
1struct _ZedCamTemp {
2 gboolean temp_avail;
3 gfloat temp_cam_left;
4 gfloat temp_cam_right;
5};
  • env_avail: indicates if CMOS temperatures data are available (only with ZED2).
  • temp_cam_left: temperature of the left CMOS sensor in [°C].
  • temp_cam_right: temperature of the right CMOS sensor in [°C].

ZedObjectData

C++
1struct _ZedObjectData {
2 gint id;
3
4 OBJECT_CLASS label;
5 OBJECT_SUBCLASS sublabel;
6 OBJECT_TRACKING_STATE tracking_state;
7 OBJECT_ACTION_STATE action_state;
8
9 gfloat confidence;
10
11 gfloat position[3];
12 gfloat position_covariance[6];
13
14 gfloat velocity[3];
15
16 unsigned int bounding_box_2d[4][2];
17
18 /* 3D bounding box of the person represented as eight 3D points
19 1 ------ 2
20 / /|
21 0 ------ 3 |
22 | Object | 6
23 | |/
24 4 ------ 7
25 */
26 gfloat bounding_box_3d[8][3];
27
28 gfloat dimensions[3]; // 3D object dimensions: width, height, length
29
30 gboolean skeletons_avail;
31
32 gfloat keypoint_2d[18][2]; // Negative coordinates -> point not valid
33 gfloat keypoint_3d[18][3]; // Nan coordinates -> point not valid
34
35 gfloat head_bounding_box_2d[4][2];
36 gfloat head_bounding_box_3d[8][3];
37 gfloat head_position[3];
38};
39
40```bash
41* `id`: univoque identifier of the tracked object.
42* `label`: class of the identified object.
43* `sublabel`: subclass of the identified object [only for MULTICLASS models]
44* `tracking_state`: tracking status of the object.
45* `confidence`: confidence level of the detection [0, 100].
46* `position`: 3D position of the center of the object.
47* `position_covariance`: covariance matrix of the position.
48* `velocity`: velocity of the object
49* `bounding_box_2d`: 2D image coordinates of the four corners of the bounding box
50* `bounding_box_3d`: 3D world coordinates of the eight corners of the bounding box
51* `dimensions`: 3D dimensions of the 3D bounding box
52* `skeletons_avail`: indicates if a skeleton tracking detection was enabled and if skeleton data are available
53* `keypoint_2d`: 2D image coordinates of the eighteen skeleton joints
54* `keypoint_3d`: 3D world coordinates of the eighteen skeleton joints
55* `head_bounding_box_2d`: 2D image coordinates of the four corners of the bounding box of the head
56* `head_bounding_box_3d`: 3D world coordinates of the eight corners of the bounding box of the head
57* `head_position`: 3D world coordinates of the position of the center of the head
58
59```cpp C++
60enum class OBJECT_CLASS {
61 PERSON = 0,
62 VEHICLE = 1,
63 BAG = 2,
64 ANIMAL = 3,
65 ELECTRONICS = 4,
66 FRUIT_VEGETABLE = 5,
67 LAST
68};
69
70enum class OBJECT_SUBCLASS {
71 PERSON = 0, /**< PERSON */
72 BICYCLE = 1, /**< VEHICLE */
73 CAR = 2, /**< VEHICLE */
74 MOTORBIKE = 3, /**< VEHICLE */
75 BUS = 4, /**< VEHICLE */
76 TRUCK = 5, /**< VEHICLE */
77 BOAT = 6, /**< VEHICLE */
78 BACKPACK = 7, /**< BAG */
79 HANDBAG = 8, /**< BAG */
80 SUITCASE = 9, /**< BAG */
81 BIRD = 10, /**< ANIMAL */
82 CAT = 11, /**< ANIMAL */
83 DOG = 12, /**< ANIMAL */
84 HORSE = 13, /**< ANIMAL */
85 SHEEP = 14, /**< ANIMAL */
86 COW = 15, /**< ANIMAL */
87 CELLPHONE = 16, /**< ELECTRONIC */
88 LAPTOP = 17, /**< ELECTRONIC */
89 BANANA = 18, /**< FRUIT/VEGETABLE */
90 APPLE = 19, /**< FRUIT/VEGETABLE */
91 ORANGE = 20, /**< FRUIT/VEGETABLE */
92 CARROT = 21, /**< FRUIT/VEGETABLE */
93 LAST = 22
94};
95
96enum class OBJECT_TRACKING_STATE {
97 OFF, /**< The tracking is not yet initialized, the object ID is not usable */
98 OK, /**< The object is tracked */
99 SEARCHING, /**< The object couldn't be detected in the image and is potentially occluded, the trajectory is estimated */
100 TERMINATE, /**< This is the last searching state of the track, the track will be deleted in the next retreiveObject */
101 LAST
102};
103
104enum class OBJECT_ACTION_STATE {
105 IDLE = 0, /**< The object is staying static. */
106 MOVING = 1, /**< The object is moving. */
107 LAST
108};
C++
1namespace skeleton {
2
3enum class BODY_PARTS {
4 NOSE = 0,
5 NECK = 1,
6 RIGHT_SHOULDER = 2,
7 RIGHT_ELBOW= 3,
8 RIGHT_WRIST = 4,
9 LEFT_SHOULDER = 5,
10 LEFT_ELBOW = 6,
11 LEFT_WRIST = 7,
12 RIGHT_HIP = 8,
13 RIGHT_KNEE = 9,
14 RIGHT_ANKLE = 10,
15 LEFT_HIP = 11,
16 LEFT_KNEE = 12,
17 LEFT_ANKLE = 13,
18 RIGHT_EYE = 14,
19 LEFT_EYE = 15,
20 RIGHT_EAR = 16,
21 LEFT_EAR = 17,
22 LAST = 18
23};
24
25inline int getIdx(BODY_PARTS part) {
26 return static_cast<int>(part);
27}
28
29static const std::vector<std::pair< BODY_PARTS, BODY_PARTS>> BODY_BONES{
30 {BODY_PARTS::NOSE, BODY_PARTS::NECK},
31 {BODY_PARTS::NECK, BODY_PARTS::RIGHT_SHOULDER},
32 {BODY_PARTS::RIGHT_SHOULDER, BODY_PARTS::RIGHT_ELBOW},
33 {BODY_PARTS::RIGHT_ELBOW, BODY_PARTS::RIGHT_WRIST},
34 {BODY_PARTS::NECK, BODY_PARTS::LEFT_SHOULDER},
35 {BODY_PARTS::LEFT_SHOULDER, BODY_PARTS::LEFT_ELBOW},
36 {BODY_PARTS::LEFT_ELBOW, BODY_PARTS::LEFT_WRIST},
37 {BODY_PARTS::RIGHT_SHOULDER, BODY_PARTS::RIGHT_HIP},
38 {BODY_PARTS::RIGHT_HIP, BODY_PARTS::RIGHT_KNEE},
39 {BODY_PARTS::RIGHT_KNEE, BODY_PARTS::RIGHT_ANKLE},
40 {BODY_PARTS::LEFT_SHOULDER, BODY_PARTS::LEFT_HIP},
41 {BODY_PARTS::LEFT_HIP, BODY_PARTS::LEFT_KNEE},
42 {BODY_PARTS::LEFT_KNEE, BODY_PARTS::LEFT_ANKLE},
43 {BODY_PARTS::RIGHT_SHOULDER, BODY_PARTS::LEFT_SHOULDER},
44 {BODY_PARTS::RIGHT_HIP, BODY_PARTS::LEFT_HIP},
45 {BODY_PARTS::NOSE, BODY_PARTS::RIGHT_EYE},
46 {BODY_PARTS::RIGHT_EYE, BODY_PARTS::RIGHT_EAR},
47 {BODY_PARTS::NOSE, BODY_PARTS::LEFT_EYE},
48 {BODY_PARTS::LEFT_EYE, BODY_PARTS::LEFT_EAR}
49};
50}

An example about how to use Object Detection data is provided with the gstzedodoverlay element source code