2

这是我在 stackoverflows 论坛上的第一篇文章。

我喜欢参考这个 sarxos 答案https://stackoverflow.com/a/31871593/5510077

我想我完全按照 API 的创建者 Bartosz Firyns 的说明让他的 Webcam Capture 0.3.10 API 在我的 Raspberry Pi Model B+ 上工作。

我目前包含在我的类路径中的文件是:

  • slf4j-api-1.7.2.jar
  • slf4j-simple-1.7.2.jar
  • v4l4j-0.9.1-r507.jar
  • 网络摄像头捕获-0.3.10.jar
  • 网络摄像头捕获驱动程序-v4l4j-0.3.10-20140923.154112-11.jar

我使用这个 sarxos 的示例来测试 API,但是使用 V4l4jDriver,因为我无法让 BridJ 在 Raspberry Pi 上工作:

package webcam;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.ds.v4l4j.V4l4jDriver;

public class WebCam {

    static {
        Webcam.setDriver(new V4l4jDriver()); // this is important
    }

    public static void main(String[] args) throws IOException {

        // get default webcam and open it
        Webcam webcam = Webcam.getDefault();
        webcam.open();

        // get image
        BufferedImage image = webcam.getImage();

        // save image to PNG file
        ImageIO.write(image, "PNG", new File("test.png"));
    }
}

并收到此错误:

[main] WARN com.github.sarxos.webcam.ds.v4l4j.V4l4jDriver - Modified V4L4J has not been found in classpath
Exception in thread "main" com.github.sarxos.webcam.WebcamException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at com.github.sarxos.webcam.WebcamDiscoveryService.getWebcams(WebcamDiscoveryService.java:124)
    at com.github.sarxos.webcam.Webcam.getWebcams(Webcam.java:816)
    at com.github.sarxos.webcam.Webcam.getDefault(Webcam.java:879)
    at com.github.sarxos.webcam.Webcam.getDefault(Webcam.java:856)
    at com.github.sarxos.webcam.Webcam.getDefault(Webcam.java:834)
    at webcam.WebCam.main(WebCam.java:34)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at com.github.sarxos.webcam.WebcamDiscoveryService.getWebcams(WebcamDiscoveryService.java:116)
    ... 5 more
Caused by: java.lang.NullPointerException
    at com.github.sarxos.webcam.util.NixVideoDevUtils.getVideoFiles(NixVideoDevUtils.java:19)
    at com.github.sarxos.webcam.ds.v4l4j.V4l4jDriver.getDevices(V4l4jDriver.java:46)
    at com.github.sarxos.webcam.WebcamDiscoveryService$WebcamsDiscovery.call(WebcamDiscoveryService.java:36)
    at com.github.sarxos.webcam.WebcamDiscoveryService$WebcamsDiscovery.call(WebcamDiscoveryService.java:26)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Java Result: 1

这些链接已失效,因此我无法测试这些 jar 文件:

网络摄像头-capture-0.3.11-SNAPSHOT.jar

网络摄像头捕获驱动程序-v4l4j-0.3.11-20150713.101304-10.jar

这些天有什么办法可以让这个 API 在 Raspberry Pi 上运行?

4

2 回答 2

0

当您替换两个文件时,您摆脱了错误和应用程序运行:

    网络摄像头捕获-0.3.10.jar

有了这个:

    网络摄像头捕获-0.3.11.jar

    网络摄像头捕获驱动程序-v4l4j-0.3.10-20140923.154112-11.jar

有了这个

    网络摄像头捕获驱动程序-v4l4j-0.3.11.jar

指向这些文件的链接以及 Webcam Capture API 作者对丢失链接的回复票证。

于 2015-11-02T15:33:08.683 回答
0

上面的程序在最新的 rpi 上导致了很多错误。请使用以下示例 https://blogs.msdn.microsoft.com/robert_mcmurray/2015/06/12/simple-java-wrapper-class-for-raspistill-on-the-raspberry-pi-2/

于 2017-08-30T09:51:45.453 回答