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

set a PImage equal to a Capture frame?

$
0
0
Trying to capture a frame via webcam and then set a PImage equal to that frame. Not working!

video is my Capture
backgroundImg is a PImage

I've tried several things
backgroundImg = video;

This gives me a black screen and an error that says "waited 5000ms...."

backgroundImg = video.image();

etc.. all give me errors on run.

Any ideas?


Entire code:
  1. import processing.video.*;


    // Variables for capture device
    Capture video;  // for first frame still

    // to store images
    PImage backgroundImg;
    PImage movementImg;                 //  Creates a new PImage to hold the movement image

    boolean first_frame = true;

    void setup() {
      size(640, 480, P2D);
      frameRate(30);
      colorMode(RGB, 255, 255, 255, 100);


      video = new Capture(this, width, height);
      video.start();
     
      backgroundImg = new PImage(width, height);
      movementImg = new PImage(width, height);   //  Initialises the PImage that holds the movement image
     
      background(0);

     
    }


    void draw() {
      // get dat first frame if ya need it
      if (video.available() && first_frame == true) {
        video.read();
        backgroundImg = video;
        first_frame = false;
      }
     

      image(backgroundImg, 0, 0 );              //  Draws the camera image to the screen
     
    }


Viewing all articles
Browse latest Browse all 1768

Trending Articles