4

I coded in java on ubuntu 11.10

Laptop webcam is running correctly and locate it /dev/v4l/. Skype application can use webcam and run.

I installed JMF but i couldn't add environment variables.`

Vector deviceList = CaptureDeviceManager.getDeviceList(new RGBFormat());
System.out.println(deviceList.toString());
if(!deviceList.isEmpty()){
    System.out.println("1");
    device = (CaptureDeviceInfo) deviceList.firstElement();
}
device = (CaptureDeviceInfo) deviceList.firstElement();
ml = device.getLocator();

I want to just a capture a image in java.

What should i do solving the problem or use instead of JMF?

Nikson Kanti Paul
  • 3,394
  • 1
  • 35
  • 51
user1291468
  • 139
  • 1
  • 3
  • 7

1 Answers1

0

Before calling CaptureDeviceManager.getDeviceList(), the available devices must be loaded into the memory first.

You can do it manually by running JMFRegistry after installing JMF.

enter image description here

or do it programmatically with the help of the extension library FMJ (Free Media in Java). Here is the code:

import java.lang.reflect.Field;
import java.util.Vector;
import javax.media.*;
import javax.media.format.RGBFormat;
import net.sf.fmj.media.cdp.GlobalCaptureDevicePlugger;

public class FMJSandbox {
    static {
        System.setProperty("java.library.path", "D:/fmj-sf/native/win32-x86/");
        try {
            final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
            sysPathsField.setAccessible(true);
            sysPathsField.set(null, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void main(String args[]) {
        GlobalCaptureDevicePlugger.addCaptureDevices(); 
        Vector deviceInfo = CaptureDeviceManager.getDeviceList(new RGBFormat());
        System.out.println(deviceInfo.size());
        for (Object obj : deviceInfo ) {
            System.out.println(obj);
        }
    }
}
hoymkot
  • 438
  • 1
  • 4
  • 11