网络摄像头捕获 API - 如何让它在 Raspberry Pi 上工作?

Webcam Capture API -How to get it work on Raspberry Pi?

这是我在 Whosebugs 论坛中的第一个 post。

我喜欢参考这个 sarxos 答案

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

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

我使用这个 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</pre>

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

webcam-capture-0.3.11-SNAPSHOT.jar

webcam-capture-driver-v4l4j-0.3.11-20150713.101304-10.jar

这几天要让这个 API 在 Raspberry Pi 上工作有什么办法吗?

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

    webcam-capture-0.3.10.jar

这个:

    webcam-capture-0.3.11.jar

    webcam-capture-driver-v4l4j-0.3.10-20140923.154112-11.jar

用这个

    webcam-capture-driver-v4l4j-0.3.11.jar

Links to these files and answered ticket from Webcam Capture API author to missing links.

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