From 0c5153fbc977d988e675790b352bc504af94d57f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 28 Jun 2007 09:36:20 +0000 Subject: [PATCH] gst/videosignal/gstvideodetect.*: Add property to adjust the center, sensitivity is now the distance from this center. Original commit message from CVS: * gst/videosignal/gstvideodetect.c: (gst_video_detect_420), (gst_video_detect_set_property), (gst_video_detect_get_property): * gst/videosignal/gstvideodetect.h: Add property to adjust the center, sensitivity is now the distance from this center. --- ChangeLog | 8 ++++++++ gst/videosignal/gstvideodetect.c | 26 +++++++++++++++++++------- gst/videosignal/gstvideodetect.h | 1 + 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd31a3386f..083494b14e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-06-28 Wim Taymans + + * gst/videosignal/gstvideodetect.c: (gst_video_detect_420), + (gst_video_detect_set_property), (gst_video_detect_get_property): + * gst/videosignal/gstvideodetect.h: + Add property to adjust the center, sensitivity is now the distance from + this center. + 2007-06-27 Wim Taymans * gst/videosignal/gstvideodetect.c: (gst_video_detect_420), diff --git a/gst/videosignal/gstvideodetect.c b/gst/videosignal/gstvideodetect.c index e26e156114..2e8b0d37a9 100644 --- a/gst/videosignal/gstvideodetect.c +++ b/gst/videosignal/gstvideodetect.c @@ -120,7 +120,8 @@ #define DEFAULT_PATTERN_HEIGHT 16 #define DEFAULT_PATTERN_COUNT 4 #define DEFAULT_PATTERN_DATA_COUNT 5 -#define DEFAULT_PATTERN_SENSITIVITY 0.2 +#define DEFAULT_PATTERN_CENTER 0.5 +#define DEFAULT_PATTERN_SENSITIVITY 0.3 #define DEFAULT_LEFT_OFFSET 0 #define DEFAULT_BOTTOM_OFFSET 0 @@ -132,6 +133,7 @@ enum PROP_PATTERN_HEIGHT, PROP_PATTERN_COUNT, PROP_PATTERN_DATA_COUNT, + PROP_PATTERN_CENTER, PROP_PATTERN_SENSITIVITY, PROP_LEFT_OFFSET, PROP_BOTTOM_OFFSET @@ -273,12 +275,16 @@ gst_video_detect_420 (GstVideoDetect * videodetect, GstBuffer * buffer) GST_DEBUG_OBJECT (videodetect, "brightness %f", brightness); if (i & 1) { - /* odd pixels must be white */ - if (brightness < (1.0 - videodetect->pattern_sensitivity)) + /* odd pixels must be white, all pixels darker than the center + + * sensitivity are considered wrong. */ + if (brightness < + (videodetect->pattern_center + videodetect->pattern_sensitivity)) goto no_pattern; } else { - /* even pixels must be black */ - if (brightness > videodetect->pattern_sensitivity) + /* even pixels must be black, pixels lighter than the center - sensitivity + * are considered wrong. */ + if (brightness > + (videodetect->pattern_center - videodetect->pattern_sensitivity)) goto no_pattern; } } @@ -300,9 +306,9 @@ gst_video_detect_420 (GstVideoDetect * videodetect, GstBuffer * buffer) /* calc brightness of width * height box */ brightness = gst_video_detect_calc_brightness (videodetect, d, pw, ph, stride); - /* update pattern */ + /* update pattern, we just use the center to decide between black and white. */ pattern_data <<= 1; - if (brightness > 0.5) + if (brightness > videodetect->pattern_center) pattern_data |= 1; } @@ -361,6 +367,9 @@ gst_video_detect_set_property (GObject * object, guint prop_id, case PROP_PATTERN_DATA_COUNT: videodetect->pattern_data_count = g_value_get_int (value); break; + case PROP_PATTERN_CENTER: + videodetect->pattern_center = g_value_get_double (value); + break; case PROP_PATTERN_SENSITIVITY: videodetect->pattern_sensitivity = g_value_get_double (value); break; @@ -400,6 +409,9 @@ gst_video_detect_get_property (GObject * object, guint prop_id, GValue * value, case PROP_PATTERN_DATA_COUNT: g_value_set_int (value, videodetect->pattern_data_count); break; + case PROP_PATTERN_CENTER: + g_value_set_double (value, videodetect->pattern_center); + break; case PROP_PATTERN_SENSITIVITY: g_value_set_double (value, videodetect->pattern_sensitivity); break; diff --git a/gst/videosignal/gstvideodetect.h b/gst/videosignal/gstvideodetect.h index 99912a28a3..0c39f3285f 100644 --- a/gst/videosignal/gstvideodetect.h +++ b/gst/videosignal/gstvideodetect.h @@ -54,6 +54,7 @@ struct _GstVideoDetect { gint pattern_height; gint pattern_count; gint pattern_data_count; + gdouble pattern_center; gdouble pattern_sensitivity; gint left_offset; gint bottom_offset;