diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2007-06-28 09:36:20 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2007-06-28 09:36:20 +0000 |
commit | 0c5153fbc977d988e675790b352bc504af94d57f (patch) | |
tree | 4ccea4250c6be31280b99ac4581abec84a496756 /gst/videosignal | |
parent | d66b7e9f26de94b3cff5fe361c62b88185f241ad (diff) |
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.
Diffstat (limited to 'gst/videosignal')
-rw-r--r-- | gst/videosignal/gstvideodetect.c | 26 | ||||
-rw-r--r-- | gst/videosignal/gstvideodetect.h | 1 |
2 files changed, 20 insertions, 7 deletions
diff --git a/gst/videosignal/gstvideodetect.c b/gst/videosignal/gstvideodetect.c index e26e15611..2e8b0d37a 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 99912a28a..0c39f3285 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; |