Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

thresholding, some cleanup

  • Loading branch information...
commit 6ae4f36ed3e0d4d957d08125999e8b407a660766 1 parent 77aee81
@x37v authored
Showing with 49 additions and 46 deletions.
  1. +46 −44 gst/gstledwallvideosink.c
  2. +3 −2 gst/test
View
90 gst/gstledwallvideosink.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) 2012 FIXME <fixme@example.com>
+ * Copyright (C) 2012 Alex Norman <alex@x37v.info>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -27,7 +27,7 @@
* |[
* gst-launch --gst-plugin-path=. -v videotestsrc ! ledwallvideosink
* ]|
- * FIXME Describe what the pipeline does.
+ * Plays a test screen on the video wall.
* </refsect2>
*/
@@ -35,8 +35,6 @@
#include "config.h"
#endif
-//#define TO_PGM
-
#include <string.h>
#include <gst/gst.h>
#include <gst/video/gstvideosink.h>
@@ -255,6 +253,11 @@ gst_led_wall_video_sink_finalize (GObject * object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+/*
+static int sr = 0;
+static int sg = 0;
+static int sb = 0;
+*/
static GstFlowReturn gst_led_wall_video_sink_show_frame(GstBaseSink * bsink, GstBuffer * buf)
{
@@ -265,20 +268,15 @@ static GstFlowReturn gst_led_wall_video_sink_show_frame(GstBaseSink * bsink, Gst
int num_leds = sink->rows * sink->cols;
int led_rows = sink->rows;
+ int color_change = FALSE;
+ //figure out the colors at the first pixel, for blue screen detection
+ int firstr, firstg, firstb;
+
+ firstr = firstb = firstg = -1;
+
//printf("width %d height %d size: %d\n", width, height, GST_BUFFER_SIZE(buf));
//printf("%d\n", data[0]);
-#ifdef TO_PGM
- //pgm
- printf("P2\n%d %d\n255\n", width, height);
- for (unsigned int row = 0; row < height; row++) {
- for (unsigned int col = 0; col < width; col++) {
- guint8 intensity = data[row * 2 * width + col * 2];
- printf("%d ", (int)intensity);
- }
- }
- printf("\n");
-#else
for (int i = 0; i < num_leds; i++) {
int row, col;
int r,g,b;
@@ -293,42 +291,52 @@ static GstFlowReturn gst_led_wall_video_sink_show_frame(GstBaseSink * bsink, Gst
//find the location row+column in the image
map_to_image(sink, col, row, &col, &row, width, height);
-#if 0
- int y, cb, cr;
- int y_off;
- //figure out the y, cr, cb
- y_off = 2 * col + (2 * row*width);
- y = data[y_off];
-
- if (col % 2 == 0) {
- cb = data[y_off + 1];
- cr = data[y_off + 3];
- } else {
- cb = data[y_off - 1];
- cr = data[y_off + 1];
- }
-
- //convert to rgb
- ycrcb2rgb(y, cb, cr, &r, &g, &b);
-#else
//direct rgb
guint32 * rgba = (guint32 *)GST_BUFFER_DATA (buf);
guint32 pixel = rgba[col + row * width];
r = (pixel >> 16) & 0xFF;
g = (pixel >> 8) & 0xFF;
b = (pixel >> 0) & 0xFF;
- //r = data[y_off + 1];
- //g = data[y_off + 2];
- //b = data[y_off + 0];
-#endif
+
+ if (i == 0) {
+ firstr = r;
+ firstg = g;
+ firstb = b;
+ } else if (r != firstr || g != firstg || b != firstb) {
+ color_change = TRUE;
+ }
+
+ /*
+ if (r != sr) {
+ sr = r;
+ printf("r = %d\n", r);
+ }
+ if (g != sg) {
+ sg = g;
+ printf("g = %d\n", g);
+ }
+ if (b != sb) {
+ sb = b;
+ printf("b = %d\n", b);
+ }
+ */
+
+ //thresholding to turn off leds
+ if (r < BLACK_THRESH && g < BLACK_THRESH && b < BLACK_THRESH)
+ r = g = b = 0;
//the colors are weird in the led output
sink->led_buffer[0 + i * 3] = gamma_map(g);
sink->led_buffer[1 + i * 3] = gamma_map(r);
sink->led_buffer[2 + i * 3] = gamma_map(b);
}
+
+ //ditching blue screen
+ if (!color_change && firstr == 0 && firstg == 1 && firstb == 192)
+ memset(sink->led_buffer, 0, 3 * num_leds);
+
+
led_write_buffer(sink->led_buffer);
-#endif
return GST_FLOW_OK;
}
@@ -342,9 +350,6 @@ gst_led_wall_video_sink_getcaps (GstBaseSink * bsink) {
return gst_caps_ref (xvimagesink->xcontext->caps);
*/
-//#ifndef TO_PGM
-// printf("get caps\n");
-//#endif
return gst_caps_copy (gst_pad_get_pad_template_caps (GST_VIDEO_SINK_PAD (ledwallvideosink)));
}
@@ -359,9 +364,6 @@ gst_led_wall_video_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
gint width, height;
ret = gst_structure_get_int (structure, "width", &width);
ret &= gst_structure_get_int (structure, "height", &height);
-//#ifndef TO_PGM
-// printf("width %d height %d\n", width, height);
-//#endif
GST_VIDEO_SINK_WIDTH(ledwallvideosink) = width;
GST_VIDEO_SINK_HEIGHT(ledwallvideosink) = height;
View
5 gst/test
@@ -1,3 +1,4 @@
#gst-launch --gst-plugin-path=. v4l2src device=/dev/video0 ! ffmpegcolorspace ! videoscale ! videorate ! video/x-raw-rgb,width=96,height=64,format='(fourcc)'RGBA,framerate=15/1 ! deinterlace ! queue ! tee name=t ! ximagesink t. ! queue ! ledwallvideosink
-gst-launch --gst-plugin-path=. v4l2src device=/dev/video0 ! ffmpegcolorspace ! videoscale ! videorate ! video/x-raw-rgb,width=96,height=64,format='(fourcc)'RGBA,framerate=20/1 ! deinterlace ! queue ! tee name=t ! ximagesink t. ! queue ! ledwallvideosink
-#gst-launch --gst-plugin-path=. v4l2src device=/dev/video0 ! ffmpegcolorspace ! videoscale ! video/x-raw-rgb,width=96,height=64,format='(fourcc)'RGBA ! deinterlace ! queue ! tee name=t ! ximagesink t. ! queue ! ledwallvideosink
+#gst-launch --gst-plugin-path=. v4l2src device=/dev/video1 ! ffmpegcolorspace ! videoscale ! videorate ! video/x-raw-rgb,width=96,height=64,format='(fourcc)'RGBA,framerate=20/1 ! deinterlace ! queue ! tee name=t ! ximagesink t. ! queue ! ledwallvideosink
+#gst-launch --gst-plugin-path=. v4l2src device=/dev/video1 ! ffmpegcolorspace ! videoscale ! video/x-raw-rgb,width=96,height=64,format='(fourcc)'RGBA ! deinterlace ! queue ! tee name=t ! ximagesink t. ! queue ! ledwallvideosink
+gst-launch --gst-plugin-path=. filesrc location=/home/alex/video/teapotassembly.mpg ! decodebin2 ! ffmpegcolorspace ! videoscale ! video/x-raw-rgb,width=96,height=64,format='(fourcc)'RGBA ! deinterlace ! queue ! tee name=t ! ximagesink t. ! queue ! ledwallvideosink
Please sign in to comment.
Something went wrong with that request. Please try again.