To detect webcams only , you must pass an argument to the 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 - built-in and connected to USB. I tested this code and it works for me.
If this does not help (since JMF is veeeery old, and some parts of the code are outdated), you can try to use part of my Capture Webcam . It works correctly with most platforms - Windows x86 and x64, Linux x86 and x64, Mac OS, etc. If you decide to try, you will have to write something like this to list all the devices of your webcam:
List<Webcam> webcams = Webcam.getDevices();
Note that it can also work on top of JMF - to replace the default built-in driver with JMF one, you will need to add the JMF JAR driver to the class path and call this before listing the webcams:
Webcam.setDriver(new JmfDriver());
I hope for this help.
Bartosz firyn
source share