From d962551fb7c2efc3aeada766ea387b053cc1a147 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Tue, 2 Mar 2010 12:41:25 +0530 Subject: [PATCH] added the propery for setting x and y co-ordinates modified: ext/opencv/textwrite/gsttextwrite.c modified: ext/opencv/textwrite/gsttextwrite.h --- ext/opencv/textwrite/gsttextwrite.c | 29 ++++++++++++++++++++++++++++- ext/opencv/textwrite/gsttextwrite.h | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ext/opencv/textwrite/gsttextwrite.c b/ext/opencv/textwrite/gsttextwrite.c index 3369e92ef0..7449884525 100644 --- a/ext/opencv/textwrite/gsttextwrite.c +++ b/ext/opencv/textwrite/gsttextwrite.c @@ -69,6 +69,8 @@ GST_DEBUG_CATEGORY_STATIC (gst_textwrite_debug); #define DEFAULT_PROP_TEXT "" #define DEFAULT_PROP_WIDTH 1 #define DEFAULT_PROP_HEIGHT 1 +#define DEFAULT_PROP_XPOS 50 +#define DEFAULT_PROP_YPOS 50 /* Filter signals and args */ enum @@ -81,6 +83,8 @@ enum enum { PROP_0, + PROP_XPOS, + PROP_YPOS, PROP_TEXT, PROP_HEIGHT, PROP_WIDTH @@ -170,6 +174,15 @@ gst_textwrite_class_init (GsttextwriteClass * klass) "Text to be display.", DEFAULT_PROP_TEXT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_XPOS, + g_param_spec_int ("xpos", "horizontal position", + "Sets the Horizontal position", 0, G_MAXINT, + DEFAULT_PROP_XPOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_YPOS, + g_param_spec_int ("ypos", "vertical position", + "Sets the Vertical position", 0, G_MAXINT, + DEFAULT_PROP_YPOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_HEIGHT, g_param_spec_double ("height", "Height", "Sets the height of fonts",1.0,5.0, @@ -208,6 +221,8 @@ gst_textwrite_init (Gsttextwrite * filter, filter->textbuf = g_strdup (DEFAULT_PROP_TEXT); filter->width=DEFAULT_PROP_WIDTH; filter->height=DEFAULT_PROP_HEIGHT; + filter->xpos=DEFAULT_PROP_XPOS; + filter->ypos=DEFAULT_PROP_XPOS; } @@ -222,6 +237,12 @@ gst_textwrite_set_property (GObject * object, guint prop_id, g_free (filter->textbuf); filter->textbuf = g_value_dup_string (value); break; + case PROP_XPOS: + filter->xpos = g_value_get_int(value); + break; + case PROP_YPOS: + filter->ypos = g_value_get_int(value); + break; case PROP_HEIGHT: filter->height = g_value_get_double(value); break; @@ -244,6 +265,12 @@ gst_textwrite_get_property (GObject * object, guint prop_id, case PROP_TEXT: g_value_set_string (value, filter->textbuf); break; + case PROP_XPOS: + g_value_set_int (value, filter->xpos); + break; + case PROP_YPOS: + g_value_set_int (value, filter->ypos); + break; case PROP_HEIGHT: g_value_set_double (value, filter->height); break; @@ -298,7 +325,7 @@ gst_textwrite_chain (GstPad * pad, GstBuffer * buf) cvInitFont(&(filter->font),CV_FONT_VECTOR0, filter->width,filter->height,0,lineWidth,0); - cvPutText (filter->cvImage,filter->textbuf,cvPoint(100,100), &(filter->font), cvScalar(165,14,14,0)); + cvPutText (filter->cvImage,filter->textbuf,cvPoint(filter->xpos,filter->ypos), &(filter->font), cvScalar(165,14,14,0)); gst_buffer_set_data (buf, filter->cvImage->imageData,filter->cvImage->imageSize); diff --git a/ext/opencv/textwrite/gsttextwrite.h b/ext/opencv/textwrite/gsttextwrite.h index 8253e91fb3..af3d6af634 100644 --- a/ext/opencv/textwrite/gsttextwrite.h +++ b/ext/opencv/textwrite/gsttextwrite.h @@ -79,6 +79,8 @@ struct _Gsttextwrite CvMemStorage *cvStorage; CvFont font; + gint xpos; + gint ypos; gdouble height; gdouble width; gchar *textbuf;