Windows 10
Method #1:
cam = new Capture(this, “pipeline:kvvideosrc”);
Method #2:
The following instructions are a workaround to let Processing use the webcam on Windows . This was tested on PC computers with the os version Windows 10 and using the Processing version 4.0b2.
In the code you run, instead of using the default method of
cam = new Capture(this, width, height);
You can initialize the camera using the following line:
Capture = new Capture(this, “pipeline:autovideosrc”);
Note that if you want to set the input to an external camera, you should use:
Capture = new Capture(this, “pipeline:avfvideosrc device-index=1”);
Catalina macOS
Method #1:
cam = new Capture(this, “pipeline:avfvideosrc”);
Method #2:
The following instructions are a workaround to let Processing use the webcam on macOS. This was tested on MacBook Pro 2019 with the os version Catalina 10.15.5 and using the Processing version 3.5.4.
We used the Video Library v2 installed from the menu Sketch/Import Library/Add Library. Optionally, you can also download the library from this link and expanding it inside of the Processing/libraries folder as described in these instructions.
- Open the Processing App and install “processing-java” so you can run a sketch from the terminal. You will find the option from the Tools menu. Select – install processing-java. Select For all users when prompted.
- Open the terminal and run the gettingStartedCapture sketch or any other sketch that tries to use the camera. You will need the full path to the sketch. Copy and paste the next line in the terminal (make sure you change “mg3273” to the name of your computer user):
processing-java --sketch=/Users/mg3273/Documents/Processing/libraries/video/examples/Capture/GettingStartedCapture --run
Running the “GettingStartedCapture” sketch from terminal Catalina prompts you to allow permission! You will get something like this:
Click OK and that will make your camera work from now on.
* this solution was compiled from this website: https://github.com/processing/processing-video/issues/134
Note that some examples wont work unless you specify the name of the camera. To open the camera in Processing, you should use:
import processing.video.*;
String[] cameras = Capture.list();
Capture cam;
void setup() {
size(640, 480);
cam = new Capture(this, cameras[0]);
cam.start();
}
void draw() {
if (cam.available()) {
cam.read();
}
image(cam, 0, 0);
}