63
63
PROP_DEPTH_MAX,
64
64
PROP_DEPTH_MODE,
65
65
PROP_DIS_SELF_CALIB,
66
+ PROP_ROI,
67
+ PROP_ROI_X,
68
+ PROP_ROI_Y,
69
+ PROP_ROI_W,
70
+ PROP_ROI_H,
66
71
// PROP_RIGHT_DEPTH_ENABLE,
67
72
PROP_DEPTH_STAB,
68
73
PROP_CONFIDENCE_THRESH,
76
81
PROP_POS_ENABLE_IMU_FUSION,
77
82
PROP_POS_ENABLE_POSE_SMOOTHING,
78
83
PROP_POS_SET_FLOOR_AS_ORIGIN,
84
+ PROP_POS_SET_GRAVITY_AS_ORIGIN,
85
+ PROP_POS_DEPTH_MIN_RANGE,
79
86
PROP_POS_INIT_X,
80
87
PROP_POS_INIT_Y,
81
88
PROP_POS_INIT_Z,
91
98
PROP_OD_CONFIDENCE,
92
99
PROP_OD_MAX_RANGE,
93
100
PROP_OD_BODY_FITTING,
101
+ PROP_OD_PREDICTION_TIMEOUT_S,
102
+ PROP_OD_ALLOW_REDUCED_PRECISION_INFERENCE,
94
103
PROP_BRIGHTNESS,
95
104
PROP_CONTRAST,
96
105
PROP_HUE,
@@ -176,6 +185,11 @@ typedef enum {
176
185
#define DEFAULT_PROP_DIS_SELF_CALIB FALSE
177
186
#define DEFAULT_PROP_DEPTH_STAB TRUE
178
187
// #define DEFAULT_PROP_RIGHT_DEPTH FALSE
188
+ #define DEFAULT_PROP_ROI FALSE
189
+ #define DEFAULT_PROP_ROI_X -1
190
+ #define DEFAULT_PROP_ROI_Y -1
191
+ #define DEFAULT_PROP_ROI_W -1
192
+ #define DEFAULT_PROP_ROI_H -1
179
193
180
194
// RUNTIME
181
195
#define DEFAULT_PROP_CONFIDENCE_THRESH 50
@@ -191,6 +205,8 @@ typedef enum {
191
205
#define DEFAULT_PROP_POS_ENABLE_IMU_FUSION TRUE
192
206
#define DEFAULT_PROP_POS_ENABLE_POSE_SMOOTHING TRUE
193
207
#define DEFAULT_PROP_POS_SET_FLOOR_AS_ORIGIN FALSE
208
+ #define DEFAULT_PROP_POS_SET_GRAVITY_AS_ORIGIN TRUE
209
+ #define DEFAULT_PROP_POS_DEPTH_MIN_RANGE -1.0
194
210
#define DEFAULT_PROP_POS_INIT_X 0.0
195
211
#define DEFAULT_PROP_POS_INIT_Y 0.0
196
212
#define DEFAULT_PROP_POS_INIT_Z 0.0
@@ -207,6 +223,8 @@ typedef enum {
207
223
#define DEFAULT_PROP_OD_CONFIDENCE 50.0
208
224
#define DEFAULT_PROP_OD_MAX_RANGE DEFAULT_PROP_DEPTH_MAX
209
225
#define DEFAULT_PROP_OD_BODY_FITTING TRUE
226
+ #define DEFAULT_PROP_OD_PREDICTION_TIMEOUT_S 0.2
227
+ #define DEFAULT_PROP_OD_ALLOW_REDUCED_PRECISION_INFERENCE FALSE
210
228
211
229
// CAMERA CONTROLS
212
230
#define DEFAULT_PROP_BRIGHTNESS 4
@@ -750,8 +768,35 @@ static void gst_zedsrc_class_init (GstZedSrcClass * klass)
750
768
" 3D Coordinate System" , GST_TYPE_ZED_COORD_SYS,
751
769
DEFAULT_PROP_COORD_SYS,
752
770
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
771
+
772
+ g_object_class_install_property ( gobject_class, PROP_ROI,
773
+ g_param_spec_boolean (" roi" , " Region of interest" ,
774
+ " Enable region of interest filtering" , DEFAULT_PROP_ROI,
775
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
776
+
777
+ g_object_class_install_property ( gobject_class, PROP_ROI_X,
778
+ g_param_spec_int (" roi-x" , " Region of interest top left 'X' coordinate" ,
779
+ " Region of interest top left 'X' coordinate (-1 to not set ROI)" ,
780
+ -1 , 2208 , DEFAULT_PROP_ROI_X,
781
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
782
+
783
+ g_object_class_install_property ( gobject_class, PROP_ROI_Y,
784
+ g_param_spec_int (" roi-y" , " Region of interest top left 'Y' coordinate" ,
785
+ " Region of interest top left 'Y' coordinate (-1 to not set ROI)" ,
786
+ -1 , 1242 , DEFAULT_PROP_ROI_Y,
787
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
753
788
789
+ g_object_class_install_property ( gobject_class, PROP_ROI_W,
790
+ g_param_spec_int (" roi-w" , " Region of interest width" ,
791
+ " Region of intererst width (-1 to not set ROI)" ,
792
+ -1 , 2208 , DEFAULT_PROP_ROI_W,
793
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
754
794
795
+ g_object_class_install_property ( gobject_class, PROP_ROI_H,
796
+ g_param_spec_int (" roi-h" , " Region of interest height" ,
797
+ " Region of interest height (-1 to not set ROI)" ,
798
+ -1 , 1242 , DEFAULT_PROP_ROI_H,
799
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
755
800
756
801
g_object_class_install_property ( gobject_class, PROP_CONFIDENCE_THRESH,
757
802
g_param_spec_int (" confidence-threshold" , " Depth Confidence Threshold" ,
@@ -828,6 +873,20 @@ static void gst_zedsrc_class_init (GstZedSrcClass * klass)
828
873
DEFAULT_PROP_POS_SET_FLOOR_AS_ORIGIN,
829
874
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
830
875
876
+ g_object_class_install_property ( gobject_class, PROP_POS_SET_GRAVITY_AS_ORIGIN,
877
+ g_param_spec_boolean (" set-gravity-as-origin" , " Set gravity as pose origin" ,
878
+ " This setting allows you to override of 2 of the 3 rotations from"
879
+ " initial-world-transform using the IMU gravity default: true" ,
880
+ DEFAULT_PROP_POS_SET_GRAVITY_AS_ORIGIN,
881
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
882
+
883
+ g_object_class_install_property ( gobject_class, PROP_POS_DEPTH_MIN_RANGE,
884
+ g_param_spec_float (" pos-depth-min-range" , " Set depth minimum range" ,
885
+ " This setting allows you to change the minmum depth used by the"
886
+ " SDK for Positional Tracking." ,
887
+ -1 , 65535 , DEFAULT_PROP_POS_DEPTH_MIN_RANGE,
888
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
889
+
831
890
g_object_class_install_property ( gobject_class, PROP_POS_INIT_X,
832
891
g_param_spec_float (" initial-world-transform-x" ,
833
892
" Initial X coordinate" ,
@@ -877,6 +936,7 @@ static void gst_zedsrc_class_init (GstZedSrcClass * klass)
877
936
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
878
937
879
938
939
+
880
940
g_object_class_install_property ( gobject_class, PROP_OD_ENABLE,
881
941
g_param_spec_boolean (" od-enabled" , " Object Detection enable" ,
882
942
" Set to TRUE to enable Object Detection" ,
@@ -924,6 +984,18 @@ static void gst_zedsrc_class_init (GstZedSrcClass * klass)
924
984
" Set to TRUE to enable body fitting for skeleton tracking" ,
925
985
DEFAULT_PROP_OD_BODY_FITTING,
926
986
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
987
+
988
+ g_object_class_install_property ( gobject_class, PROP_OD_PREDICTION_TIMEOUT_S,
989
+ g_param_spec_float (" od-prediction-timeout-s" , " Object detection prediction timeout (sec)" ,
990
+ " Object prediction timeout (sec)" , 0 .0f , 1 .0f , DEFAULT_PROP_OD_PREDICTION_TIMEOUT_S,
991
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
992
+
993
+ g_object_class_install_property ( gobject_class, PROP_OD_ALLOW_REDUCED_PRECISION_INFERENCE,
994
+ g_param_spec_boolean (" od-allow-reduced-precision-inference" , " Allow inference at reduced precision" ,
995
+ " Set to TRUE to allow inference to run at a lower precision to improve runtime" ,
996
+ DEFAULT_PROP_OD_ALLOW_REDUCED_PRECISION_INFERENCE,
997
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
998
+
927
999
928
1000
g_object_class_install_property ( gobject_class, PROP_BRIGHTNESS,
929
1001
g_param_spec_int (" brightness" , " Camera control: brightness" ,
@@ -1049,6 +1121,11 @@ static void gst_zedsrc_init (GstZedSrc * src)
1049
1121
src->texture_confidence_threshold = DEFAULT_PROP_TEXTURE_CONF_THRESH;
1050
1122
src->measure3D_reference_frame = DEFAULT_PROP_3D_REF_FRAME;
1051
1123
src->sensing_mode = DEFAULT_PROP_SENSING_MODE;
1124
+ src->roi = DEFAULT_PROP_ROI;
1125
+ src->roi_x = DEFAULT_PROP_ROI_X;
1126
+ src->roi_y = DEFAULT_PROP_ROI_Y;
1127
+ src->roi_w = DEFAULT_PROP_ROI_W;
1128
+ src->roi_h = DEFAULT_PROP_ROI_H;
1052
1129
1053
1130
src->pos_tracking = DEFAULT_PROP_POS_TRACKING;
1054
1131
src->camera_static = DEFAULT_PROP_CAMERA_STATIC;
@@ -1057,6 +1134,8 @@ static void gst_zedsrc_init (GstZedSrc * src)
1057
1134
src->enable_imu_fusion = DEFAULT_PROP_POS_ENABLE_IMU_FUSION;
1058
1135
src->enable_pose_smoothing = DEFAULT_PROP_POS_ENABLE_POSE_SMOOTHING;
1059
1136
src->set_floor_as_origin = DEFAULT_PROP_POS_SET_FLOOR_AS_ORIGIN;
1137
+ src->set_gravity_as_origin = DEFAULT_PROP_POS_SET_GRAVITY_AS_ORIGIN;
1138
+ src->depth_min_range = DEFAULT_PROP_POS_DEPTH_MIN_RANGE;
1060
1139
src->init_pose_x = DEFAULT_PROP_POS_INIT_X;
1061
1140
src->init_pose_y = DEFAULT_PROP_POS_INIT_Y;
1062
1141
src->init_pose_z = DEFAULT_PROP_POS_INIT_Z;
@@ -1072,6 +1151,8 @@ static void gst_zedsrc_init (GstZedSrc * src)
1072
1151
src->od_det_conf = DEFAULT_PROP_OD_CONFIDENCE;
1073
1152
src->od_max_range = DEFAULT_PROP_OD_MAX_RANGE;
1074
1153
src->od_body_fitting = DEFAULT_PROP_OD_BODY_FITTING;
1154
+ src->od_prediction_timeout_s = DEFAULT_PROP_OD_PREDICTION_TIMEOUT_S;
1155
+ src->od_allow_reduced_precision_inference = DEFAULT_PROP_OD_ALLOW_REDUCED_PRECISION_INFERENCE;
1075
1156
1076
1157
src->brightness = DEFAULT_PROP_BRIGHTNESS;
1077
1158
src->contrast = DEFAULT_PROP_CONTRAST;
@@ -1172,6 +1253,21 @@ void gst_zedsrc_set_property (GObject * object, guint property_id,
1172
1253
case PROP_SENSING_MODE:
1173
1254
src->sensing_mode = g_value_get_enum (value);
1174
1255
break ;
1256
+ case PROP_ROI:
1257
+ src->roi = g_value_get_boolean (value);
1258
+ break ;
1259
+ case PROP_ROI_X:
1260
+ src->roi_x = g_value_get_int (value);
1261
+ break ;
1262
+ case PROP_ROI_Y:
1263
+ src->roi_y = g_value_get_int (value);
1264
+ break ;
1265
+ case PROP_ROI_W:
1266
+ src->roi_w = g_value_get_int (value);
1267
+ break ;
1268
+ case PROP_ROI_H:
1269
+ src->roi_h = g_value_get_int (value);
1270
+ break ;
1175
1271
case PROP_POS_TRACKING:
1176
1272
src->pos_tracking = g_value_get_boolean (value);
1177
1273
break ;
@@ -1194,6 +1290,12 @@ void gst_zedsrc_set_property (GObject * object, guint property_id,
1194
1290
case PROP_POS_ENABLE_POSE_SMOOTHING:
1195
1291
src->enable_pose_smoothing = g_value_get_boolean (value);
1196
1292
break ;
1293
+ case PROP_POS_SET_GRAVITY_AS_ORIGIN:
1294
+ src->set_gravity_as_origin = g_value_get_boolean (value);
1295
+ break ;
1296
+ case PROP_POS_DEPTH_MIN_RANGE:
1297
+ src->depth_min_range = g_value_get_float (value);
1298
+ break ;
1197
1299
case PROP_POS_INIT_X:
1198
1300
src->init_pose_x = g_value_get_float (value);
1199
1301
break ;
@@ -1236,6 +1338,12 @@ void gst_zedsrc_set_property (GObject * object, guint property_id,
1236
1338
case PROP_OD_BODY_FITTING:
1237
1339
src->od_body_fitting = g_value_get_boolean (value);
1238
1340
break ;
1341
+ case PROP_OD_PREDICTION_TIMEOUT_S:
1342
+ src->od_prediction_timeout_s = g_value_get_float (value);
1343
+ break ;
1344
+ case PROP_OD_ALLOW_REDUCED_PRECISION_INFERENCE:
1345
+ src->od_allow_reduced_precision_inference = g_value_get_boolean (value);
1346
+ break ;
1239
1347
case PROP_BRIGHTNESS:
1240
1348
src->brightness = g_value_get_int (value);
1241
1349
break ;
@@ -1366,6 +1474,21 @@ gst_zedsrc_get_property (GObject * object, guint property_id,
1366
1474
case PROP_SENSING_MODE:
1367
1475
g_value_set_enum ( value, src->sensing_mode );
1368
1476
break ;
1477
+ case PROP_ROI:
1478
+ g_value_set_boolean ( value, src->roi );
1479
+ break ;
1480
+ case PROP_ROI_X:
1481
+ g_value_set_int ( value, src->roi_x );
1482
+ break ;
1483
+ case PROP_ROI_Y:
1484
+ g_value_set_int ( value, src->roi_y );
1485
+ break ;
1486
+ case PROP_ROI_W:
1487
+ g_value_set_int ( value, src->roi_w );
1488
+ break ;
1489
+ case PROP_ROI_H:
1490
+ g_value_set_int ( value, src->roi_h );
1491
+ break ;
1369
1492
case PROP_POS_TRACKING:
1370
1493
g_value_set_boolean ( value, src->pos_tracking );
1371
1494
break ;
@@ -1387,6 +1510,12 @@ gst_zedsrc_get_property (GObject * object, guint property_id,
1387
1510
case PROP_POS_ENABLE_POSE_SMOOTHING:
1388
1511
g_value_set_boolean ( value, src->enable_pose_smoothing );
1389
1512
break ;
1513
+ case PROP_POS_SET_GRAVITY_AS_ORIGIN:
1514
+ g_value_set_boolean ( value, src->set_gravity_as_origin );
1515
+ break ;
1516
+ case PROP_POS_DEPTH_MIN_RANGE:
1517
+ g_value_set_float ( value, src->depth_min_range );
1518
+ break ;
1390
1519
case PROP_POS_INIT_X:
1391
1520
g_value_set_float ( value, src->init_pose_x );
1392
1521
break ;
@@ -1429,6 +1558,12 @@ gst_zedsrc_get_property (GObject * object, guint property_id,
1429
1558
case PROP_OD_BODY_FITTING:
1430
1559
g_value_set_boolean ( value, src->od_body_fitting );
1431
1560
break ;
1561
+ case PROP_OD_PREDICTION_TIMEOUT_S:
1562
+ g_value_set_float ( value, src->od_prediction_timeout_s );
1563
+ break ;
1564
+ case PROP_OD_ALLOW_REDUCED_PRECISION_INFERENCE:
1565
+ g_value_set_boolean ( value, src->od_allow_reduced_precision_inference );
1566
+ break ;
1432
1567
1433
1568
case PROP_BRIGHTNESS:
1434
1569
g_value_set_int ( value, src->brightness );
@@ -1751,6 +1886,37 @@ static gboolean gst_zedsrc_start( GstBaseSrc * bsrc )
1751
1886
GST_INFO (" * Depth Texture Confidence threshold: %d" , src->texture_confidence_threshold );
1752
1887
GST_INFO (" * 3D Reference Frame: %s" , sl::toString ((sl::COORDINATE_SYSTEM)src->measure3D_reference_frame ).c_str ());
1753
1888
GST_INFO (" * Sensing Mode: %s" , sl::toString ((sl::SENSING_MODE)src->sensing_mode ).c_str ());
1889
+
1890
+
1891
+ if (src->roi ) {
1892
+ if (src->roi_x != -1 &&
1893
+ src->roi_y != -1 &&
1894
+ src->roi_w != -1 &&
1895
+ src->roi_h != -1 ) {
1896
+ int roi_x_end = src->roi_x + src->roi_w ;
1897
+ int roi_y_end = src->roi_y + src->roi_y ;
1898
+ sl::Resolution resolution = sl::getResolution (init_params.camera_resolution );
1899
+ if (src->roi_x < 0 || src->roi_x >= resolution.width ||
1900
+ src->roi_y < 0 || src->roi_y >= resolution.height ||
1901
+ roi_x_end >= resolution.width || roi_y_end >= resolution.height ) {
1902
+ sl::Mat roi_mask (resolution, sl::MAT_TYPE::U8_C1);
1903
+ roi_mask.setTo (0 .f );
1904
+ for (int i = src->roi_x ; i < roi_x_end; i++)
1905
+ for (int j = src->roi_y ; j < roi_y_end; j++)
1906
+ roi_mask.setValue (i, j, 1 .f );
1907
+
1908
+ GST_INFO (" * ROI mask: (%d,%d)-%dx%d" ,
1909
+ src->roi_x , src->roi_y , src->roi_w , src->roi_h );
1910
+
1911
+ ret = src->zed .setRegionOfInterest (roi_mask);
1912
+ if (ret!=sl::ERROR_CODE::SUCCESS) {
1913
+ GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
1914
+ (" Failed to set region of interest, '%s'" , sl::toString (ret).c_str () ), (NULL ));
1915
+ return FALSE ;
1916
+ }
1917
+ }
1918
+ }
1919
+ }
1754
1920
// <---- Runtime parameters
1755
1921
1756
1922
// ----> Positional tracking
@@ -1772,6 +1938,10 @@ static gboolean gst_zedsrc_start( GstBaseSrc * bsrc )
1772
1938
GST_INFO (" * Pose smoothing: %s" , (pos_trk_params.enable_pose_smoothing ?" TRUE" :" FALSE" ));
1773
1939
pos_trk_params.set_floor_as_origin = (src->set_floor_as_origin ==TRUE );
1774
1940
GST_INFO (" * Floor as origin: %s" , (pos_trk_params.set_floor_as_origin ?" TRUE" :" FALSE" ));
1941
+ pos_trk_params.set_gravity_as_origin = (src->set_gravity_as_origin ==TRUE );
1942
+ GST_INFO (" * Gravity as origin: %s" , (pos_trk_params.set_gravity_as_origin ?" TRUE" :" FALSE" ));
1943
+ pos_trk_params.depth_min_range = src->depth_min_range ;
1944
+ GST_INFO (" * Depth min range: %f" , (pos_trk_params.depth_min_range ));
1775
1945
1776
1946
sl::Translation init_pos (src->init_pose_x ,src->init_pose_y , src->init_pose_z );
1777
1947
sl::Rotation init_or;
@@ -1809,6 +1979,10 @@ static gboolean gst_zedsrc_start( GstBaseSrc * bsrc )
1809
1979
GST_INFO (" * Max range: %g" , od_params.max_range );
1810
1980
od_params.enable_body_fitting = src->od_body_fitting ;
1811
1981
GST_INFO (" * Body fitting: %s" , (od_params.enable_body_fitting ?" TRUE" :" FALSE" ));
1982
+ od_params.prediction_timeout_s = src->od_prediction_timeout_s ;
1983
+ GST_INFO (" * Prediction timeout (sec): %f" , (od_params.prediction_timeout_s ));
1984
+ od_params.allow_reduced_precision_inference = src->od_allow_reduced_precision_inference ;
1985
+ GST_INFO (" * Allow reduced precision inference: %s" , (od_params.allow_reduced_precision_inference ?" TRUE" :" FALSE" ));
1812
1986
1813
1987
ret = src->zed .enableObjectDetection ( od_params );
1814
1988
if (ret!=sl::ERROR_CODE::SUCCESS) {
0 commit comments