Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Processing core video error: "gstvideo: failed to get caps of pad nat:sink"

$
0
0
Hey folks,

I'm taking my first crack at using video capture in a Processing sketch. I have a sketch that's already working fine without video input, and I'm trying to add video capture to it. (Specifically, I've got an array of PVectors that I'm using to stuff color values into the vertices of a grid of quads.) I've cut and pasted what I think are the relevant lines of code from the "AsciiVideo" and "GettingStartedCapture" examples, but I can't seem to make it work.

Here's what I've got at the head of the sketch:

  1. import processing.video.*;

  2. Capture video;
  3. int vidWidth = 160;
  4. int vidHeight = 128;
  5. int cellSize = 4;  // pixels per grid cell
  6. boolean show_diagnostics = true;
  7. boolean show_video = true;

  8. void setup() {
  9.   size((vidWidth-1) * cellSize, (vidHeight-1) * cellSize, P3D);
  10.   noStroke();
  11.   fill(255);

  12.   xres = width/cellSize+1;
  13.   yres = height/cellSize+1;
  14.   dw = (float)width / (xres-1);
  15.   dh = (float)height / (yres-1);
  16.   initGrid();

  17.   println("grid res: " + xres + ", " + yres);
  18.   video = new Capture(this, xres, yres);
  19.   video.start();
  20. }

I know the camera's working, and I can get the video to display in the lower right corner just fine...
  1. void drawVideo() {
  2.   // lower right corner
  3.   image(video, width-video.width, height-video.height);
  4. }

...but for some reason, when I try to access the pixels directly, their values all seem to be zero. The example code below never gets to the println() statement:

  1. void colorGridFromVideo() {
  2.   video.read();
  3.   for (int j=0; j<yres; j++) {
  4.     for (int i=0; i<xres; i++) {
  5.       color vc = video.pixels[j*xres+i];
  6.       if(vc > 0) {
  7.         println("color is " + vc);
  8.       }
  9.       //colors[j*xres+i] = new PVector((vc >> 16) & 0xff, (vc >> 8) & 0xff, vc & 0xff);
  10.       colors[j*xres+i] = new PVector(red(vc), green(vc), blue(vc));
  11.     }
  12.   }
  13. }

Here's the error that comes up when I try to do this:

** (Processing core video:39451): WARNING **: gstvideo: failed to get caps of pad nat:sink

Has anyone else encountered this problem? Am I doing anything obviously wrong or silly?

I'm running Processing 2.0b9 on an elderly MacBook Pro, in OS X 10.8.3.

-Cassidy




Viewing all articles
Browse latest Browse all 1768

Trending Articles