Commit 9817e5a5 authored by Fabián Orccón's avatar Fabián Orccón

videofilter: Filter ROIs by roi type and roi param

Fixes #739
parent dee5d8ab
Pipeline #130219 failed with stages
in 9 minutes and 56 seconds
......@@ -60,7 +60,9 @@ G_DEFINE_ABSTRACT_TYPE (GstVideoFilter, gst_video_filter,
enum
{
PROP_0,
PROP_ONLY_ROI
PROP_ONLY_ROI,
PROP_ROI_TYPE,
PROP_ROI_PARAM
};
/* Answer the allocation query downstream. */
......@@ -347,6 +349,22 @@ foreach_roi_meta (GstBuffer * buf, GstMeta ** meta, gpointer user_data)
roi_meta = (GstVideoRegionOfInterestMeta *) * meta;
if (filter->roi_type) {
const gchar *roi_meta_type = g_quark_to_string (roi_meta->roi_type);
if (g_strcmp0 (filter->roi_type, roi_meta_type) != 0)
return TRUE;
}
if (filter->roi_param) {
GList *l;
for (l = roi_meta->params; l != NULL; l = l->next) {
GstStructure *roi_meta_param;
roi_meta_param = (GstStructure *) l->data;
if (!gst_structure_is_equal (filter->roi_param, roi_meta_param))
return TRUE;
}
}
left = roi_meta->x;
right = roi_meta->x + roi_meta->w;
bottom = roi_meta->y + roi_meta->h;
......@@ -519,6 +537,23 @@ gst_video_filter_set_property (GObject * object, guint prop_id, const
case PROP_ONLY_ROI:
filter->only_roi = g_value_get_boolean (value);
break;
case PROP_ROI_TYPE:
{
if (filter->roi_type)
g_free (filter->roi_type);
filter->roi_type = g_value_dup_string (value);
break;
}
case PROP_ROI_PARAM:
{
const GstStructure *st = gst_value_get_structure (value);
if (filter->roi_param)
gst_structure_free (filter->roi_param);
filter->roi_param = st ? gst_structure_copy (st) : NULL;
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -535,12 +570,32 @@ gst_video_filter_get_property (GObject * object, guint prop_id,
case PROP_ONLY_ROI:
g_value_set_boolean (value, filter->only_roi);
break;
case PROP_ROI_TYPE:
g_value_set_string (value, filter->roi_type);
break;
case PROP_ROI_PARAM:
g_value_set_boxed (value, filter->roi_param);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_video_filter_finalize (GObject * object)
{
GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (object);
if (filter->roi_type)
g_free (filter->roi_type);
if (filter->roi_param)
gst_structure_free (filter->roi_param);
G_OBJECT_CLASS (gst_video_filter_parent_class)->finalize (object);
}
static void
gst_video_filter_class_init (GstVideoFilterClass * g_class)
{
......@@ -554,12 +609,23 @@ gst_video_filter_class_init (GstVideoFilterClass * g_class)
gobject_class->set_property = gst_video_filter_set_property;
gobject_class->get_property = gst_video_filter_get_property;
gobject_class->finalize = gst_video_filter_finalize;
g_object_class_install_property (gobject_class, PROP_ONLY_ROI,
g_param_spec_boolean ("only-roi", "Only ROI",
"Whether or not to filter only regions of interest.", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ROI_TYPE,
g_param_spec_string ("roi-type", "ROI Type",
"Filter ROIs by this type.", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ROI_PARAM,
g_param_spec_boxed ("roi-param", "ROI Param",
"Filter ROIs by this specified params.",
GST_TYPE_STRUCTURE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_filter_set_caps);
trans_class->propose_allocation =
GST_DEBUG_FUNCPTR (gst_video_filter_propose_allocation);
......@@ -587,6 +653,8 @@ gst_video_filter_init (GstVideoFilter * instance)
videofilter->negotiated = FALSE;
videofilter->only_roi = FALSE;
videofilter->roi_type = NULL;
videofilter->roi_param = NULL;
/* enable QoS */
gst_base_transform_set_qos_enabled (GST_BASE_TRANSFORM (videofilter), TRUE);
}
......@@ -50,6 +50,8 @@ struct _GstVideoFilter {
GstVideoInfo in_info;
GstVideoInfo out_info;
gboolean only_roi;
gchar *roi_type;
GstStructure *roi_param;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment