Processing Forum
- import processing.video.*;
- Capture cam1, cam2;
- void setup() {
- size(640, 480);
- String[] cameras = Capture.list();
- println("Available cameras:");
- for (int i = 0; i < cameras.length; i++) {
- println(cameras[i]);
- }
- if (cameras.length < 1) {
- println("There are not enough cameras available.");
- exit();
- }
- // The camera can be initialized directly using an
- // element from the array returned by list():
- cam1 = new Capture(this, cameras[0]);
- cam2 = new Capture(this, cameras[1]);
- cam1.start();
- cam2.start();
- }
- void draw() {
- if (cam1.available() == true) {
- cam1.read();
- }
- if (cam2.available() == true) {
- cam2.read();
- }
- image(cam1, 0, 0);
- if( keyPressed ){ image(cam2,0,0); }
- }
Press and hold any key to view second cam.