0

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.");
    }
user1088595
  • 151
  • 2
  • 16

1 Answers1

0

you need to have OpenCV installed in the machine where you are running that program , jar only will contain javacv wrapper , but doesnt contains dll of opencv

anshulkatta
  • 2,044
  • 22
  • 30
  • how to add these opencv dlls into android's project? Even I am using JavaCV, ffmpeg, Windows 7, Java 1.7 and Eclipse. My `grabber.start()` method just won't work. – Autonomous Jul 17 '14 at 22:49
  • download opencv and extract in c:\openccv , its the default location for installation and also ad the path to environment variables – anshulkatta Jul 20 '14 at 06:25