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

时间:2015-10-31 14:21:41

标签: java raspberry-pi webcam-capture

这是我在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-简单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,因为我无法在Raspberry Pi上使用BridJ:

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文件:

webcam-capture-0.3.11-SNAPSHOT.jar

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

这些天有没有办法让这个API在Raspberry Pi上运行?

2 个答案:

答案 0 :(得分:0)

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

    的网络摄像头捕获-0.3.10.jar

这一个:

    的网络摄像头捕获-0.3.11.jar

    的网络摄像头捕获-驾驶员v4l4j-0.3.10-20140923.154112-11.jar

这一个

    的网络摄像头捕获-驾驶员v4l4j-0.3.11.jar

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

答案 1 :(得分:0)