templatematch: rename conflicting variable

With the switch of gstopencv.c to C++, all OpenCV elements are built with
g++. The template variable clashes with C++'s feature of the same name.
Rename template to templ to avoid any clash.
This commit is contained in:
Luis de Bethencourt 2015-07-31 16:40:07 +01:00
parent 78d0c5f01e
commit 2111f50a6f
2 changed files with 15 additions and 15 deletions

View file

@ -140,7 +140,7 @@ gst_template_match_class_init (GstTemplateMatchClass * klass)
"Specifies the way the template must be compared with image regions. 0=SQDIFF, 1=SQDIFF_NORMED, 2=CCOR, 3=CCOR_NORMED, 4=CCOEFF, 5=CCOEFF_NORMED.", "Specifies the way the template must be compared with image regions. 0=SQDIFF, 1=SQDIFF_NORMED, 2=CCOR, 3=CCOR_NORMED, 4=CCOEFF, 5=CCOEFF_NORMED.",
0, 5, DEFAULT_METHOD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 0, 5, DEFAULT_METHOD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_TEMPLATE, g_object_class_install_property (gobject_class, PROP_TEMPLATE,
g_param_spec_string ("template", "Template", "Filename of template image", g_param_spec_string ("templ", "Template", "Filename of template image",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_DISPLAY, g_object_class_install_property (gobject_class, PROP_DISPLAY,
g_param_spec_boolean ("display", "Display", g_param_spec_boolean ("display", "Display",
@ -179,7 +179,7 @@ gst_template_match_init (GstTemplateMatch * filter)
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
filter->template = NULL; filter->templ = NULL;
filter->display = TRUE; filter->display = TRUE;
filter->cvTemplateImage = NULL; filter->cvTemplateImage = NULL;
filter->cvDistImage = NULL; filter->cvDistImage = NULL;
@ -243,7 +243,7 @@ gst_template_match_get_property (GObject * object, guint prop_id,
g_value_set_int (value, filter->method); g_value_set_int (value, filter->method);
break; break;
case PROP_TEMPLATE: case PROP_TEMPLATE:
g_value_set_string (value, filter->template); g_value_set_string (value, filter->templ);
break; break;
case PROP_DISPLAY: case PROP_DISPLAY:
g_value_set_boolean (value, filter->display); g_value_set_boolean (value, filter->display);
@ -298,7 +298,7 @@ gst_template_match_finalize (GObject * object)
GstTemplateMatch *filter; GstTemplateMatch *filter;
filter = GST_TEMPLATE_MATCH (object); filter = GST_TEMPLATE_MATCH (object);
g_free (filter->template); g_free (filter->templ);
if (filter->cvImage) { if (filter->cvImage) {
cvReleaseImageHeader (&filter->cvImage); cvReleaseImageHeader (&filter->cvImage);
} }
@ -405,12 +405,12 @@ gst_template_match_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
static void static void
gst_template_match_match (IplImage * input, IplImage * template, gst_template_match_match (IplImage * input, IplImage * templ,
IplImage * dist_image, double *best_res, CvPoint * best_pos, int method) IplImage * dist_image, double *best_res, CvPoint * best_pos, int method)
{ {
double dist_min = 0, dist_max = 0; double dist_min = 0, dist_max = 0;
CvPoint min_pos, max_pos; CvPoint min_pos, max_pos;
cvMatchTemplate (input, template, dist_image, method); cvMatchTemplate (input, templ, dist_image, method);
cvMinMaxLoc (dist_image, &dist_min, &dist_max, &min_pos, &max_pos, NULL); cvMinMaxLoc (dist_image, &dist_min, &dist_max, &min_pos, &max_pos, NULL);
if ((CV_TM_SQDIFF_NORMED == method) || (CV_TM_SQDIFF == method)) { if ((CV_TM_SQDIFF_NORMED == method) || (CV_TM_SQDIFF == method)) {
*best_res = dist_min; *best_res = dist_min;
@ -427,28 +427,28 @@ gst_template_match_match (IplImage * input, IplImage * template,
/* We take ownership of template here */ /* We take ownership of template here */
static void static void
gst_template_match_load_template (GstTemplateMatch * filter, gchar * template) gst_template_match_load_template (GstTemplateMatch * filter, gchar * templ)
{ {
gchar *oldTemplateFilename = NULL; gchar *oldTemplateFilename = NULL;
IplImage *oldTemplateImage = NULL, *newTemplateImage = NULL, *oldDistImage = IplImage *oldTemplateImage = NULL, *newTemplateImage = NULL, *oldDistImage =
NULL; NULL;
if (template) { if (templ) {
newTemplateImage = cvLoadImage (template, CV_LOAD_IMAGE_COLOR); newTemplateImage = cvLoadImage (templ, CV_LOAD_IMAGE_COLOR);
if (!newTemplateImage) { if (!newTemplateImage) {
/* Unfortunately OpenCV doesn't seem to provide any way of finding out /* Unfortunately OpenCV doesn't seem to provide any way of finding out
why the image load failed, so we can't be more specific than FAILED: */ why the image load failed, so we can't be more specific than FAILED: */
GST_ELEMENT_WARNING (filter, RESOURCE, FAILED, GST_ELEMENT_WARNING (filter, RESOURCE, FAILED,
(_("OpenCV failed to load template image")), (_("OpenCV failed to load template image")),
("While attempting to load template '%s'", template)); ("While attempting to load template '%s'", templ));
g_free (template); g_free (templ);
template = NULL; templ = NULL;
} }
} }
GST_OBJECT_LOCK (filter); GST_OBJECT_LOCK (filter);
oldTemplateFilename = filter->template; oldTemplateFilename = filter->templ;
filter->template = template; filter->templ = templ;
oldTemplateImage = filter->cvTemplateImage; oldTemplateImage = filter->cvTemplateImage;
filter->cvTemplateImage = newTemplateImage; filter->cvTemplateImage = newTemplateImage;
oldDistImage = filter->cvDistImage; oldDistImage = filter->cvDistImage;

View file

@ -79,7 +79,7 @@ struct _GstTemplateMatch
gint method; gint method;
gboolean display; gboolean display;
gchar *template; gchar *templ;
IplImage *cvImage, *cvGray, *cvTemplateImage, *cvDistImage; IplImage *cvImage, *cvGray, *cvTemplateImage, *cvDistImage;
}; };