So I created an executable JAR using this code and everything works fine on my machine however I tested it on some other computers and the webcam capture never starts. The indicator light doesn't come on. This is the example I see in most tutorials for doing image capture and I'm doing face recognition so it's easiest to utilize the javaCV function rather than adding another library. All suggestions appreciated, thank you.
CanvasFrame canvas = new CanvasFrame("Webcam");
//Set Canvas frame to close on exit
canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
try {
//Start grabber to capture video
grabber.start();
//Declare img as IplImage
IplImage img;
long starttime = System.currentTimeMillis();
while (temptime < 4000) {
//inser grabed video fram to IplImage img
img = grabber.grab();
//Set canvas size as per dimentions of video frame.
canvas.setCanvasSize(grabber.getImageWidth(), grabber.getImageHeight());
if (img != null) {
//Flip image horizontally
cvFlip(img, img, 1);
//Draw text over the canvas
Graphics g = canvas.createGraphics();
g.setFont(camfont);
g.setColor(Color.red);
//Show video frame in canvas
canvas.showImage(img);
if (temptime > 2000 && tempcount == 1) {
//take and save the picture
cvSaveImage("User-cap.jpg", img);
tempcount++;
}
temptime = System.currentTimeMillis() - starttime;
}
}
} catch (Exception e) {
}
try {
grabber.stop();
canvas.dispose();
} catch (Exception e) {
System.out.println("Grabber couldn't close.");
}