Loading...
Logo
Processing Forum
Hey,

I'm getting sigsegv with a simple gsvideo based program. Processing is 1.0.9, gsvideo is 0.6 pre5, linux is ubuntu 8.10.

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0xb7dea896, pid=7246, tid=2691038096
#
# JRE version: 6.0_16-b01
# Java VM: Java HotSpot(TM) Client VM (14.2-b01 mixed mode linux-x86 )
# Problematic frame:
# C  [libc.so.6+0x79896]  memcpy+0x46
#
# An error report file with more information is saved as:
# /home/matthew/processing-1.0.9/hs_err_pid7246.log
#
# If you would like to submit a bug report, please visit:
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Copy code
  1. import codeanticode.gsvideo.*;

  2. color black = color(0);
  3. color white = color(255);

  4. float boundaries, thresh;
  5. static int controlsWidth = 200;
  6. int numPixels;
  7. GSCapture video;

  8. static int maxBoundaries = 4;
  9. static int vidWidth, vidHeight;

  10. void setup()
  11. {
  12.   vidWidth = 320;
  13.   vidHeight = 240;
  14.   size(640, 480, P2D); // Change size to 320 x 240 if too slow at 640 x 480

  15.   fs = new FullScreen(this); 
  16.   strokeWeight(5);
  17.   // Uses the default video input, see the reference if this causes an error
  18.   video = new GSCapture(this, vidWidth, vidHeight, 8);
  19.   numPixels = video.width * video.height;
  20. }

  21. void draw()
  22.   int threshold = (int)map( mouseX, 0, width, 0, 255 ); 
  23.   if (video.available() && mousePressed) 
  24.   {
  25.     video.read();
  26.     video.loadPixels();

  27.     // int threshold = (int)thresh; //map( (float)mouseX, 0, width, 0, 255 ); // Set the threshold value
  28.     float pixelBrightness; // Declare variable to store a pixel's color
  29.     // Turn each pixel in the video frame black or white depending on its brightness
  30.     loadPixels();
  31.   
  32.     for (int i = 0; i < numPixels; i++)
  33.     {
  34.       pixelBrightness = brightness(video.pixels[i]);
  35.       if (pixelBrightness > threshold)
  36.       { // If the pixel is brighter than the
  37.         video.pixels[i] = white; // threshold value, make it white
  38.       } 
  39.       else 
  40.       { // Otherwise,
  41.         video.pixels[i] = black; // make it black
  42.       }
  43.     }
  44.   
  45.     copy(video, 0, 0 , vidWidth, vidHeight ,0, 0, width , height );
  46.     updatePixels( );
  47.   }
  48. }

Replies(6)

bump! Any help with this would be much appreciated, I want to get it working by Wednesday for a graffiti stencil workshop!
I tested the code with Processing 1.1, ubuntu 9.04. It worked ok for me, maybe you can try the following things:

1) Different capture devices:
cam = new GSCapture(this, 640, 480, "/dev/video0", 8);
cam = new GSCapture(this, 640, 480, "/dev/video1", 8);
...

2) Instead of running capture with a GSCapture object, you can also try a GSPipeline:

pipe = new GSPipeline(this, "v4l2src ! ffmpegcolorspace ! video/x-raw-rgb, width=320, height=240, bpp=32, depth=24");

The advantage of this is that you can also run this pipeline from the command line, i.e.:

gst-launch v4l2src ! ffmpegcolorspace ! video/x-raw-yuv, width=640, height=480, bpp=32, depth=24 ! xvimagesink

(note that x-raw-yuv is used in the command line instead of x-raw-rgb as the video format). If you get video capture with gst-launch, then the problem is in gsvideo, otherwise it is probably an issue with your installation of gstreamer.


thanks Andres!

I'm at work now without a webcam so I'll check tonight and post back.

The program is a part of a graffiti stencil workshop I'm running for young people starting on Wednesday. Last minute idea - hope I can get it stable!

Here's an example!

Hello again, I'm back with the same problem. I've never managed to get reliable video with gsvideo. I still get the above crash and now I'm on ubuntu10.10 processing1.2.1 and gsvideo 0.7.


Matt
Version 0.6 is slightly outdated. I recommend you try 0.7 instead.

A recent bug that affects video capture was recently discovered, this might the source of the problem you are experiencing. There is a fix available, but still not included in the stable version of gsvideo. Read this post for more details.
Hey thanks! Yes I found that thread yesterday but forgot to update this one! I used the patched jar file with the latest download and that's fixed it all!

Matt