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

OPENGL and Capture not working - reading pixels[] returns false results (2.08b) -RESOLVED-

$
0
0
Hi,
Using the Capture class and the standard renderer does work together.

If i want to use OpenGL/P2D for drawing for speed benefits, I appear to only be able to capture black, not the actual image from the webcam.

The thing is, just doing capture and displaying is no issue.
But when I want to analyze the captured image and draw eg. circles with the color of a pixel, the circles get black. With the default renderer it works fine.



here is a simplified example, default works, using P2D or OPENGL does not.

  1. import processing.video.*;
    //import processing.opengl.*;

    PImage img;
    int diameter=20;
    Capture cam;


    void setup() {
     frameRate(15);
     size(640, 480, OPENGL);
     colorMode(RGB,255);
     noStroke();

     cam = new Capture(this, 80, 60, 20);
     cam.start();
    }


    void draw() {

     if (cam.available() == true) {
       background(125);
       cam.read();
       img = cam;

       for (int w=0; w<img.width; w++) {
         for (int h=0; h<img.height; h++) {
           fill(img.pixels[w+h*img.width]);
           ellipse(w*diameter, h*diameter, diameter, diameter);
         }
       }
     }
    }


Is this a known issue? Am i missing something, or is there are workaround?

(I am using Processing 2.08b on OS X 10.7.5.)

Viewing all articles
Browse latest Browse all 1768

Trending Articles