We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I'm using this code for a facial recognition sketch, but it uses my inbuilt iSight camera instead of the USB camera I want to use. I tried looking for some workarounds, but no succes. How can I use my USB camera instead of the iSight?
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
import ddf.minim.*;
Minim minim;
AudioPlayer soundtrack;
Capture video;
OpenCV opencv;
void setup() {
size(640, 480);
video = new Capture(this, 640/2, 480/2);
opencv = new OpenCV(this, 640/2, 480/2);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
video.start();
// always start Minim before you do anything with it
minim = new Minim(this);
//load a file, give the AudioPlayer buffers that are 2048 samples long
soundtrack = minim.loadFile("laser.mp3");
video.settings();
}
void draw() {
scale(2);
opencv.loadImage(video);
image(video, 0, 0 );
noFill();
stroke(255, 255, 0);
strokeWeight(3);
Rectangle[] faces = opencv.detect();
println(faces.length);
for (int i = 0; i < faces.length; i++) {
println(faces[i].x + ", FACE" + faces[i].y);
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
soundtrack.play();
delay(3000);
soundtrack.rewind();
}
}
void captureEvent(Capture c) {
c.read();
}
void stop()
{
// always close Minim audio classes when you are done with them
soundtrack.close();
minim.stop();
super.stop();
}
Answers
you can't sorry
Thanks for the really helpful comment. I fixed it by finding out what the name of the usb is by using this code:
The name was "USB Webcam"
so then I added this to my original code:
And it works :)
Full code here:
Hope this is helpful for people who have the same problem.