使用java检测网络摄像头设备

发布于 2024-08-13 16:23:24 字数 305 浏览 8 评论 0原文

我正在使用 JMF 操作我的网络摄像头。我的 USB 网络摄像头与 JMF 完美配合, 然而,我在 JMStudio 中使用了它,当我从我的 java 代码中进行此调用时,

deviceListVector = CaptureDeviceManager.getDeviceList( null );

我的“音频捕获设备”被检测到,我的 USB 网络摄像头位于 未检测到 vfw://0。为了澄清,音频捕获设备和 USB 摄像头是完全独立的设备。 如何从 JMF 正确检测 USB 网络摄像头及其格式?

提前致谢

I am using JMF to operate my web cam.My usb webcam works perfectly with JMF,
I used it in JMStudio however,when I make this call from my java code

deviceListVector = CaptureDeviceManager.getDeviceList( null );

my "audio capture device" is detected however, my usb webcam at
vfw://0 is not detected. To clarify, the audio capture device and the
USB cam are entirely separate devices.
How can I properly detect the usb webcam, and its formats, from JMF?

Thanks In advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

禾厶谷欠 2024-08-20 16:23:24

您也可以尝试 LTI-CivilXuggler

Also you can try LTI-Civil or Xuggler.

我一向站在原地 2024-08-20 16:23:24

检测网络摄像头,您应该将参数传递给 getDeviceList(Format) 方法(而不是 null):

Vector<Object> devices = CaptureDeviceManager.getDeviceList(new Format("RGB"));
Iterator<Object> di = devices.iterator();
while (di.hasNext()) {
    CaptureDeviceInfo info = (CaptureDeviceInfo) di.next();
    System.out.println(info);
}

这应该打印您的所有网络摄像头 - 内置网络摄像头和连接到 USB 的网络摄像头。我已经测试了这段代码,它对我有用。

如果这没有帮助(因为 JMF 非常旧并且代码的某些部分可能已经过时),您可以尝试使用我的部分 网络摄像头捕获 项目。它可以在大多数平台上正常工作 - Windows x86 和 x64、Linux x86 和 x64、Mac OS 等。如果您决定尝试它,您将必须编写类似这样的内容来列出您的所有网络摄像头设备:

List<Webcam> webcams = Webcam.getDevices();

请注意,它可以也可以在 JMF 之上工作 - 要将默认内置驱动程序替换为 JMF 驱动程序,您必须添加 JMF 驱动程序 JAR 到类路径中,并在列出网络摄像头之前调用它:

Webcam.setDriver(new JmfDriver());

希望有所帮助。

To detect only webcams you should pass argument to getDeviceList(Format) method (instead of null):

Vector<Object> devices = CaptureDeviceManager.getDeviceList(new Format("RGB"));
Iterator<Object> di = devices.iterator();
while (di.hasNext()) {
    CaptureDeviceInfo info = (CaptureDeviceInfo) di.next();
    System.out.println(info);
}

This should print all your webcams - build in and those connected to USB. I've tested this code and it works for me.

If this won't help (since JMF is veeeery old and some parts of the code can be outdated), you can try using part of my Webcam Capture project. It is working correctly with most platforms - Windows x86 and x64, Linux x86 and x64, Mac OS, etc. If you decide to try it, you will have to write something like this to list all your webcam devices:

List<Webcam> webcams = Webcam.getDevices();

Please note that it can also work on top of JMF - to replace default build-in driver to JMF one, you will have to add JMF driver JAR into the classpath and call this before listing webcams:

Webcam.setDriver(new JmfDriver());

Hope this help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文