78
78
PROP_INITIAL_WIDTH,
79
79
PROP_INITIAL_HEIGHT,
80
80
PROP_ALGORITHM,
81
+ PROP_DRAW,
81
82
};
82
83
83
84
#define GST_OPENCV_TRACKER_ALGORITHM (tracker_algorithm_get_type ())
@@ -207,6 +208,11 @@ gst_cvtracker_class_init (GstCVTrackerClass * klass)
207
208
GST_OPENCV_TRACKER_ALGORITHM_MEDIANFLOW,
208
209
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
209
210
211
+ g_object_class_install_property (gobject_class, PROP_DRAW,
212
+ g_param_spec_boolean (" draw-rect" , " Display" ,
213
+ " Draw rectangle around tracked object" ,
214
+ TRUE , (GParamFlags) G_PARAM_READWRITE));
215
+
210
216
gst_element_class_set_static_metadata (element_class,
211
217
" cvtracker" ,
212
218
" Filter/Effect/Video" ,
@@ -233,6 +239,7 @@ gst_cvtracker_init (GstCVTracker * filter)
233
239
#else
234
240
filter->tracker = cv::TrackerMedianFlow::create ();
235
241
#endif
242
+ filter->draw = TRUE ;
236
243
filter->post_debug_info = TRUE ;
237
244
238
245
gst_opencv_video_filter_set_in_place (GST_OPENCV_VIDEO_FILTER_CAST (filter),
@@ -262,6 +269,9 @@ gst_cvtracker_set_property (GObject * object, guint prop_id,
262
269
case PROP_ALGORITHM:
263
270
filter->algorithm = g_value_get_enum (value);
264
271
break ;
272
+ case PROP_DRAW:
273
+ filter->draw = g_value_get_boolean (value);
274
+ break ;
265
275
default :
266
276
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
267
277
break ;
@@ -338,6 +348,9 @@ gst_cvtracker_get_property (GObject * object, guint prop_id,
338
348
case PROP_ALGORITHM:
339
349
g_value_set_enum (value, filter->algorithm );
340
350
break ;
351
+ case PROP_DRAW:
352
+ g_value_set_boolean (value, filter->draw );
353
+ break ;
341
354
default :
342
355
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
343
356
break ;
@@ -382,6 +395,8 @@ gst_cvtracker_transform_ip (GstOpencvVideoFilter * base,
382
395
filter->roi ->x , filter->roi ->y , filter->roi ->width ,
383
396
filter->roi ->height );
384
397
gst_element_post_message (GST_ELEMENT (filter), msg);
398
+ if (filter->draw )
399
+ cv::rectangle (img, *filter->roi , cv::Scalar (255 , 0 , 0 ), 2 , 1 );
385
400
if (!(filter->post_debug_info ))
386
401
filter->post_debug_info = TRUE ;
387
402
} else if (filter->post_debug_info ) {
0 commit comments