How to connect a webcam or not. Using java
2 answers
JMF ( Java Media Framework ) should be able to detect any media including a webcam.
Potentially through CaptureDeviceManager.getDeviceList();
To "install JMF on Linux" one way is as follows:
- download .
- Change directories to the installation location.
- Run the command
:
% /bin/sh ./jmf-2_1_1e-linux-i586.bin
+2
source to share
Here is a piece of code I am using 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();
}
He chooses the first available webcam. Of course, after the webcam, you can save the CameraLocator and try to reopen it in a second run.
0
source to share