Ciprian Amaritei
Ciprian Amaritei

Reputation: 113

Capture video from multiple cameras in Processing

I am trying to display in the same Processing window 2 (or more) different captures from cameras attached to the computer: the default built-in camera and a USB Camera.

It seems that if I start both cameras at a time nothing is displayed. Would it even be possible to have 2 (or more) different captures ? Here's the code:

import processing.video.*;
Capture camA;
Capture camB;
String[] cameras;

void setup(){
cameras=Captures.list();
camA = new Capture(this,1280,960,cameras[15]);
camB = new Capture(this,1280,960,cameras[1]);
camA.start(); 
camB.start();
}
void draw() {
  image(camA, 100, 100, 360,240);
  image(camB, 500, 100, 360,240);
}

void captureEvent(Capture c) {
  if(c==camA){   
    camA.read();
  }else if(c==camB) {
    camB.read();
  }
}

Upvotes: 2

Views: 2071

Answers (1)

Ciprian Amaritei
Ciprian Amaritei

Reputation: 113

Fixed by choosing other camera resolutions from the list. Having both at the higher resolutions won't render them. It worked with one at 640x320 and the other at 320x180, which was enough for me.

Upvotes: 1

Related Questions