sarxos 的图书馆网络摄像头捕获不适用于覆盆子
library webcam-capture by sarxos not working on raspberry
我在 raspberry 上 java 的网络摄像头捕获库有问题。这是我的代码:
System.out.println("start");
List<Webcam> list = Webcam.getWebcams();
System.out.println("checking " + list.size() + " Webcams");
for(Webcam webcam : list) {
//do sth
}
在 windows 我有以下输出:
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
我试图找出库中有问题的代码,我发现它退出于:
executor.awaitTermination(timeout, tunit);
在 WebcamDiscoveryService.getWebcams()
参数为9223372036854775807和
毫秒
为什么它不起作用 ("the project is portable (WinXP, Win7, Win8, Linux, Mac, Raspberry Pi) and does not require any additional software to be installed on the PC.")。
有没有其他库这么简单?
仅记录我在 Github 上的 Webcam Capture API 项目中创建的 ticket 中提供的解决方案,以防有人遇到相同问题并先尝试 Whosebug。
问题出在默认驱动程序上,它并不总是 运行 在 Raspberry Pi 上运行良好(只有一个 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 在 Raspberry Pi 上最稳定,或者通过添加BridJ 0.6.3-快照到类路径而不是 0.6.2。
如果是 webcam-capture-driver-v4l4j,您必须包含在类路径中的 JAR 是:
对于网络摄像头捕捉 0.3.10:
或网络摄像头捕捉 0.3.11:
添加这些后,可以从类路径中删除不再需要的 BridJ JAR。
代码:
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);
}
有关更多详细信息,我会将所有感兴趣的人重定向到 ticket,问题已得到解决。
我在 raspberry 上 java 的网络摄像头捕获库有问题。这是我的代码:
System.out.println("start");
List<Webcam> list = Webcam.getWebcams();
System.out.println("checking " + list.size() + " Webcams");
for(Webcam webcam : list) {
//do sth
}
在 windows 我有以下输出:
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
我试图找出库中有问题的代码,我发现它退出于:
executor.awaitTermination(timeout, tunit);
在 WebcamDiscoveryService.getWebcams()
参数为9223372036854775807和 毫秒
为什么它不起作用 ("the project is portable (WinXP, Win7, Win8, Linux, Mac, Raspberry Pi) and does not require any additional software to be installed on the PC.")。
有没有其他库这么简单?
仅记录我在 Github 上的 Webcam Capture API 项目中创建的 ticket 中提供的解决方案,以防有人遇到相同问题并先尝试 Whosebug。
问题出在默认驱动程序上,它并不总是 运行 在 Raspberry Pi 上运行良好(只有一个 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 在 Raspberry Pi 上最稳定,或者通过添加BridJ 0.6.3-快照到类路径而不是 0.6.2。
如果是 webcam-capture-driver-v4l4j,您必须包含在类路径中的 JAR 是:
对于网络摄像头捕捉 0.3.10:
或网络摄像头捕捉 0.3.11:
添加这些后,可以从类路径中删除不再需要的 BridJ JAR。
代码:
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);
}
有关更多详细信息,我会将所有感兴趣的人重定向到 ticket,问题已得到解决。