-
JFM Registry error
Hi all,
I've just installed JMF and i wanted to add a device(a webcam) so i could use it in my app,because if I don't add it I cannot use it as a data source.
After the installation i opened JMF Registry and tryed to click the "add" button in "capture devices" and it keeps sending my error "could not add item".
What should I do?(I've tried to click add in other tabs but it keeps sending me that error).
Thanks
-
Re: JFM Registry error
Hi again,
Recently i've been succesful in capturing the camera with jmf studio and see myself.
but when i try to capture the device with java code it doest allow me, it shows that there are no devices.
But I am able to catch the device with my jmf studio.
what should i do?
-
Re: JFM Registry error
Hi again
My jmf studio is recognizing my web cam but I use this code: CaptureDeviceInfo deviceInfo = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
if(deviceInfo==null)
{
System.out.println("null");
}
else
System.out.println(deviceInfo.getName());
and i allways get null.
why?
-
Re: JFM Registry error
Hi i wanted to post my code that i am using so you can see what is the problem
public static void main(String[] args) throws Exception
{
// Create capture device
CaptureDeviceInfo deviceInfo = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
Player player = Manager.createRealizedPlayer(deviceInfo.getLocator ());
player.start();
// Wait a few seconds for camera to initialise (otherwise img==null)
Thread.sleep(2500);
//
// // Grab a frame from the capture device
FrameGrabbingControl frameGrabber = (FrameGrabbingControl)player.getControl("javax.med ia.control.FrameGrabbingControl");
Buffer buf = frameGrabber.grabFrame();
// Convert frame to an buffered image so it can be processed and saved
Image img = (new BufferToImage((VideoFormat)buf.getFormat()).create Image(buf));
BufferedImage buffImg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics2D g = buffImg.createGraphics();
g.drawImage(img, null, null);
// Overlay curent time on image
g.setColor(Color.RED);
g.setFont(new Font("Verdana", Font.BOLD, 16));
g.drawString((new Date()).toString(), 10, 25);
// Save image to disk as PNG
ImageIO.write(buffImg, "png", new File("c:\\webcam.png"));
// Stop usin webcam
player.close();
player.deallocate();
System.exit(0);
CaptureDeviceInfo device = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
if(device==null)
{
System.out.println("no device");
}
else
System.out.println("device exists");
Ignore the "//". when i am trying it it says "Exception in thread "main" java.lang.NullPointerException
at capture.main(capture.java:25)"
its like it doesnt know the device exists even though i can use it through the JMF studio.
what should i do?
-
Re: JFM Registry error