processing-video icon indicating copy to clipboard operation
processing-video copied to clipboard

Get on video Capture using P2D/P3D/OPENGL renderer

Open lmagoncalo opened this issue 3 years ago • 2 comments

When using the function get() in a video capture, the returned PImage is all black when using the P2D/P3D/OPENGL renderer. However, if I switch the renderer to JAVA2D it works fine.

Code to reproduce:

import processing.video.*;

Capture cam;
PImage img;

void setup() {
  size(640, 480, P2D); // Change to JAVA2D to work

  String[] cameras = Capture.list();
 
  cam = new Capture(this, cameras[1]);
  cam.start();        
}

void draw() {
  if (cam.available() == true) {
    cam.read();
    img = cam.get();
  }
  image(img, 0, 0);
}

I am using the macOS Monterey but it also happens using a Windows 10.

lmagoncalo avatar Jul 19 '22 13:07 lmagoncalo

Not sure if it's related, but I could only get the camera to work (using P3D mode) when displaying the video image one, ie image(cam, 0, 0);.. I only wanted the pixel brightness, so it worked to place it once within the setup... but made me check issues as to why this was needed and might be connected to your issue?

ffd8 avatar Sep 04 '22 22:09 ffd8

This issue also occurs with Windows 11 Pro. And cam.copy() has the same problem. I also used the Video library TimeDisplacement example, changing to size(640, 480, P2D) to verify the issue exists.

Also this code shows video but the camera image cannot be modified:

import processing.video.*;

Capture cam; PImage img;

void setup() { size(640, 480, P2D); // Change to JAVA2D to work

String[] cameras = Capture.list();

cam = new Capture(this, cameras[1]); cam.start();
}

void draw() { if (cam.available() == true) { cam.read(); img = cam; //img = cam.get(); } image(img, 0, 0); }

ajavamind avatar Sep 20 '22 19:09 ajavamind