sarxos 的图书馆网络摄像头捕获不适用于树莓派 [英] library webcam-capture by sarxos not working on raspberry

查看:13
本文介绍了sarxos 的图书馆网络摄像头捕获不适用于树莓派的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 raspberry 上的 java 网络摄像头捕获库有问题.这是我的代码:

i have a problem with the webcam-capture library for java on raspberry. This is my code:

    System.out.println("start");
    List<Webcam> list = Webcam.getWebcams();

    System.out.println("checking " + list.size() + " Webcams");
    for(Webcam webcam : list) {
        //do sth
    }

在 Windows 上,我有以下输出:

On windows i have the following output:

start
[main] INFO com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture    
driver will be used
checking 0 Webcams

在我的树莓上我只得到

start
[main] INFO com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture    
driver will be used

我试图找出库中有问题的代码,我发现它退出于:

i tried to figure out the problematic code in the library and i found out that it exits at:

executor.awaitTermination(timeout, tunit);

在 WebcamDiscoveryService.getWebcams() 中

in WebcamDiscoveryService.getWebcams()

参数为 9223372036854775807 和毫秒

the parameters are 9223372036854775807 and MILLISECONDS

为什么它不起作用(该项目是可移植的(WinXP、Win7、Win8、Linux、Mac、Raspberry Pi)并且不需要在 PC 上安装任何其他软件.").

why doesn't it work ("the project is portable (WinXP, Win7, Win8, Linux, Mac, Raspberry Pi) and does not require any additional software to be installed on the PC.").

可能还有其他的图书馆那么容易吗?

is there maybe any other library that is that easy?

推荐答案

只是为了记录我在 ticket 在 Github 上的 Webcam Capture API 项目中创建,以防有人遇到同样的问题并首先尝试 stackoverflow.

Just to record the solution I provided in the ticket created in Webcam Capture API project on Github in case anyone has the same issue and tries stackoverflow first.

问题在于默认驱动程序并不总是在 Raspberry Pi 上运行良好(只有一个 BridJ版本支持 Raspberry Pi,但尚未发布到 Maven Central).要解决此问题,可以将依赖于 BridJ 的默认驱动程序替换为不同的驱动程序,例如webcam-capture-driver-v4l4j在 Raspberry Pi 上最稳定,或者将 BridJ 0.6.3-SNAPSHOT 添加到类路径而不是 0.6.2.

The problem lies in the default driver which does not always run well on Raspberry Pi (only one BridJ version supports Raspberry Pi but it hasn't been released to Maven Central). To workaround this issue one can replace default driver which depends on BridJ by a different one, e.g. webcam-capture-driver-v4l4j which is most stable on Raspberry Pi, or by adding BridJ 0.6.3-SNAPSHOT to classpath instead of 0.6.2.

对于 webcam-capture-driver-v4l4j,您必须在类路径中包含的 JAR 是:

In case of webcam-capture-driver-v4l4j the JARs you have to include in your classpath are:

对于网络摄像头捕捉 0.3.10:

For Webcam Capture 0.3.10:

或网络摄像头捕获 0.3.11:

Or Webcam Capture 0.3.11:

添加这些之后,BridJ JAR 可以从类路径中删除,因为不再需要.

After these are added, BridJ JAR can be removed from classpath as not required any more.

代码:

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

public static void main(String[] args) {
  JFrame frame = new JFrame("V4L4J Webcam Capture Driver Demo");
  frame.add(new WebcamPanel(Webcam.getDefault()));
  frame.pack();
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

有关更多详细信息,我将所有感兴趣的人重定向到问题所在已解决.

For more details I'm redirecting everyone interested to the ticket where issue has been resolved.

这篇关于sarxos 的图书馆网络摄像头捕获不适用于树莓派的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆