Sign in to follow this  
Eskhan

[java] Java plug-in doesn't enumerate my webcam

Recommended Posts

I'm developing an applet that uses the webcam to transmit video. It runs fine when I run it in eclipse, but when I try to run it with java plug-in (in either IE or Firefox) It can't find any camera devices. My applet is signed and I have full permissions. I enumerate the webcam devices using
CaptureDeviceManager.getDeviceList( new VideoFormat(VideoFormat.RGB,
            new Dimension(viewSize), VideoFormat.NOT_SPECIFIED, byte[].class, VideoFormat.NOT_SPECIFIED));
I also tried getting the device directly by using the cameras name like this
    
CaptureDeviceInfo device = CaptureDeviceManager.getDevice("vfw:Creative WebCam NX (VFW):0");

Share this post


Link to post
Share on other sites
If it works in your IDE, but not in the browser, some exception is being thrown by the JRE. Get the stack of the java console and post here, if you don't identify the problem yourself, someone here on the forums will ;)

Son Of Cain

Share this post


Link to post
Share on other sites
Well, that is the not so amusing part, the only exception being thrown is my own that I throw because I can't find any device, the jmf api methods that I use simply state that no camera device exists and returns.

Anyways, this is the stack trace.


number of devices 0
Searching for [vfw:Creative WebCam NX (VFW):0]
webcam.VideoTransmitException: No device found [ vfw:Creative WebCam NX (VFW):0]
at webcam.VideoTransmitNew.<init>(VideoTransmitNew.java:108)
at webtvclient.WebTVClient.getVideoTransmitNew(WebTVClient.java:377)
at webtvclient.ChildWindow$ChildWindowMessageHandler.actionPerformed(ChildWindow.java:244)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at webtvclient.ChildWindow$ChildWindowMessageHandler.actionPerformed(ChildWindow.java:245)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


the 0 in "number of devices 0" is the number returned by calling cameraDevices.size()
where cameraDevices is the Vector that was assigned by this call:

cameraDevices = CaptureDeviceManager.getDeviceList( new VideoFormat(VideoFormat.RGB,
new Dimension(viewSize), VideoFormat.NOT_SPECIFIED, byte[].class, VideoFormat.NOT_SPECIFIED));


When I run the applet in eclipse cameraDevices contains two CaptureDeviceInfo objects after this call.

Share this post


Link to post
Share on other sites
I'm not sure about it, it is just a guess, but isn't access to the webcam denied to the browser? If I'm not wrong, I suppose you have to enable it somewhere on IE, or the browser you're using.

Despite that, your code seems ok... isn't there any "register-like" operation for the manager before you can start catching devices?

Son Of Cain

Share this post


Link to post
Share on other sites
Son of Cain - Thank you for taking your time to help me!

I ran the JMF diagnostics tool in http://java.sun.com/products/java-media/jmf/2.1.1/jmfdiagnostics.html
and it said it couldn't find the jmf class files, so I reinstalled jmf and this time put it in c:\java\jmf (it used to be c:\program files\jmf2.1.1.e), because I suspect that spaces and dots screws up the classpath variables, now I am able to see video in a browser applet.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this