processing / processing-video

GStreamer-based video library for Processing
276 stars 130 forks source link

Get on video Capture using P2D/P3D/OPENGL renderer #203

Open lmagoncalo opened 2 years ago

lmagoncalo commented 2 years ago

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.

ffd8 commented 2 years ago

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?

ajavamind commented 2 years ago

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); }