Black Magic
Black Magic

Reputation: 2766

OpenCV not working in JAR file

I have a program that uses OpenCV to make some pictures with the webcam. When I run the application in my IDE(NetBeans) it works like a charm, but when I try to run the jar file it doesn't even show what the webcam sees in our JFrame. Does anyone know how to solve this?

public void run(){
        try {
            grabber = new VideoInputFrameGrabber(0); 
            grabber.start();
            while (active) {
                IplImage originalImage = grabber.grab();
                Label.setIcon(new ImageIcon( originalImage.getBufferedImage() ));
            }
            grabber.stop();
            grabber.flush();

        } catch (Exception ex) {
            //Logger.getLogger(ChPanel.class.getName()).log(Leve l.SEVERE, null, ex);
        }

    }

    public BufferedImage saveImage(){
        IplImage img;
        try {
            //capture image
            img = grabber.grab();
            // save to file
            File outputfile = new File(Project.getInstance().getFileURLStr() + " capture" + fotoCount++ + ".jpg");
            ImageIO.write(img.getBufferedImage(), "jpg", outputfile);    

            //get file and set it in the project library
            BufferedImage ImportFile = ImageIO.read(outputfile);
            Project p = Project.getInstance();
            MainScreen ms = MainScreen.getInstance();
            ImageIcon takenPhoto = new ImageIcon(ImportFile);
            p.setNextImage(takenPhoto);
            ms.setPanels();
            return ImportFile;
        } catch (com.googlecode.javacv.FrameGrabber.Exception e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;

    }

When I run it out of CMD, it does show the image on my JFrame. But when I try to take the picture it shows this message: "Failed to write core dump. Minidumps are not enabled by default on client version of windows"

Upvotes: 0

Views: 501

Answers (1)

Black Magic
Black Magic

Reputation: 2766

I already found the problem, I had about 3 versions of Java installed, wich propably wasn't okay :p

Upvotes: 1

Related Questions