本文介绍了图书馆摄像头捕获sarxos不在树莓上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的覆盆子上的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

在我的覆盆子上我只得到

On my raspberry i only get

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和
MILLISECONDS

the parameters are 9223372036854775807 andMILLISECONDS

为什么它不起作用(该项目是可移植的(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?

推荐答案

只是为了记录我在,以防任何人遇到相同问题并首先尝试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上运行良好(只有一个版本支持Raspberry Pi但它尚未发布到Maven Central)。要解决此问题,可以替换默认驱动程序,该驱动程序依赖于不同的BridJ,例如在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:




  • v4l4j-0.9.1-r507.jar
  • webcam-capture-driver-v4l4j-0.3.10-20140923.154112-11.jar

或网络摄像头捕获0.3.11:

Or Webcam Capture 0.3.11:




  • v4l4j-0.9.1-r507.jar
  • webcam-capture-driver-v4l4j-0.3.11-20150713.101304-10.jar

添加这些后,可以从类路径中删除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不在树莓上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 19:38