简体   繁体   English

OpenCV无法在JAR文件中工作

[英]OpenCV not working in JAR file

I have a program that uses OpenCV to make some pictures with the webcam. 我有一个使用OpenCV用网络摄像头制作一些图片的程序。 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. 当我在IDE(NetBeans)中运行该应用程序时,它的工作原理像一个超级按钮,但是当我尝试运行jar文件时,它甚至不显示网络摄像机在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. 当我用完CMD时,它确实会在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" 但是,当我尝试拍照时,它显示以下消息:“无法写入核心转储。默认情况下,Windows客户端版本未启用小型转储”

我已经发现了问题,我安装了大约3个Java版本,但可能还不行:p

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM