How to detect whether the Web cam is attached to computer or not by using Java?
+2
A:
JMF (Java Media Framework) should be able to detect any media, including a webcam.
Potentially through CaptureDeviceManager.getDeviceList();
For "installing JMF on Linux", one way is simply to:
- download it.
- Change directories to the install location.
- Run the command
:
% /bin/sh ./jmf-2_1_1e-linux-i586.bin
VonC
2009-09-07 11:49:46
Need to know how to install JMF on Linux .Any idea about this ?
om
2009-09-07 13:05:49
A:
Here is a piece of code I use in a simple Webcam client with JMF:
Format format = new RGBFormat();
MediaLocator cameraLocator = null;
// get device list
Vector deviceList = CaptureDeviceManager.getDeviceList(format);
// if devices available
if(deviceList != null && deviceList.size() > 0) {
// pick first
CaptureDeviceInfo device = (CaptureDeviceInfo) deviceList.get(0);
cameraLocator = device.getLocator();
}
It picks the first available webcam. Of course, after having the webcam you can store the cameraLocator and try to re-open it on the 2nd run.
cringe
2009-09-07 13:32:06