Running more than 2 webcams simultaneously
in
Core Library Questions
•
1 year ago
in Processing 2.0+ is there a limit to the number of webcams you can run at the same time? I have 4 webcams that I am switching between, however when I try to start them, only a max of 2 light up.
- import processing.video.*;
Capture[] cams;
int selectedIndex;
int timer;
void setup(){
size(500, 500);
println(Capture.list());
int totalCams = Capture.list().length;
cams = new Capture[totalCams];
for(int i = 0; i < cams.length; i++){
cams[i] = new Capture(this, 640, 480, Capture.list()[i], 30);
cams[i].start();
}
selectedIndex = 0;
timer = millis();
}
void draw(){
int time = millis() - timer;
if(time > 5000){
updateIndex();
}
if(cams[selectedIndex].available() == true){
cams[selectedIndex].read();
image(cams[selectedIndex], 0, 0);
}
}
void updateIndex(){
selectedIndex++;
if(selectedIndex > cams.length - 1)
selectedIndex = 0;
timer = millis();
}
I know that I could stop the current cam and then start the next cam, but it will lag a big before the next cam shows up. So my idea was to have them all running and then I can switch to them without any switching delay. Is there a limit to the number of simultaneous cameras playing at once? If so, is there a better way to approach switching between multiple webcams seamlessly?
1