0

そこで、このコードを使用して実行可能な JAR を作成し、自分のマシンではすべて正常に動作しましたが、他のコンピューターでテストしたところ、Web カメラのキャプチャが開始されませんでした。インジケータライトが点灯しません。これは、画像キャプチャを行うためのほとんどのチュートリアルで見られる例であり、顔認識を行っているため、別のライブラリを追加するのではなく、javaCV 関数を利用するのが最も簡単です。すべての提案に感謝します、ありがとう。

   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.");
    }
4

1 に答える 1

0

そのプログラムを実行しているマシンにOpenCVをインストールする必要があります。jarにはjavacvラッパーのみが含まれますが、opencvのdllは含まれません

于 2013-04-16T08:54:45.123 に答える