Capture working in IDE but not in OpenProcessing?

edited October 2017 in JavaScript Mode

In the Processing IDE I used

    import processing.video.*;
    Capture video;

    void setup() {
    frameRate(700);
    size(640, 480);
    x = width/2;
    y = height/2;
    background(255);
    video = new Capture(this, width, height);
    video.start();
    }

in the first part of my code because I'm trying to make a sketch that draws using the image produced from a webcam. It works perfectly but when I copy paste the same code to OpenProcessing the error message in the console reads "Capture is not defined". How do I fix this problem?

Tagged:

Answers

  • edited November 2017

    Check the next code:

      import processing.video.*;
      Capture cam;
    
      void setup() {
    
      size(1280,960);
    
      String[] cameras = Capture.list();
    
      if (cameras.length == 0) {
      println("There are no cameras available for capture.");
      exit();
      } else {
         println("Available cameras:");
         for (int i = 0; i < cameras.length; i++) {
           println(cameras[i]);
         }
    
      // The camera can be initialized directly using an
      // element from the array returned by list():
        cam = new Capture(this, cameras[1]);
        cam.start();
       }
      }
    
     void draw() {
      if (cam.available() == true) {
        cam.read();
      }
      image(cam, 0, 0);
    }
    
Sign In or Register to comment.