Detect WebCam device using with java
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
你也可以试试LTI-Civil或Xuggler。
你可能想看看这里http://fmj-sf.net/
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.
链接地址: http://www.djcxy.com/p/81012.html上一篇: 如何使用C#从Windows Service中的网络摄像头捕获帧?
下一篇: 使用java检测WebCam设备