Processing core video error: "gstvideo: failed to get caps of pad nat:sink"
in
Core Library Questions
•
4 months ago
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:
- import processing.video.*;
- Capture video;
- int vidWidth = 160;
- int vidHeight = 128;
- int cellSize = 4; // pixels per grid cell
- boolean show_diagnostics = true;
- boolean show_video = true;
- void setup() {
- size((vidWidth-1) * cellSize, (vidHeight-1) * cellSize, P3D);
- noStroke();
- fill(255);
- xres = width/cellSize+1;
- yres = height/cellSize+1;
- dw = (float)width / (xres-1);
- dh = (float)height / (yres-1);
- initGrid();
- println("grid res: " + xres + ", " + yres);
- video = new Capture(this, xres, yres);
- video.start();
- }
I know the camera's working, and I can get the video to display in the lower right corner just fine...
- void drawVideo() {
- // lower right corner
- image(video, width-video.width, height-video.height);
- }
...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:
- void colorGridFromVideo() {
- video.read();
- for (int j=0; j<yres; j++) {
- for (int i=0; i<xres; i++) {
- color vc = video.pixels[j*xres+i];
- if(vc > 0) {
- println("color is " + vc);
- }
- //colors[j*xres+i] = new PVector((vc >> 16) & 0xff, (vc >> 8) & 0xff, vc & 0xff);
- colors[j*xres+i] = new PVector(red(vc), green(vc), blue(vc));
- }
- }
- }
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
1