Forums Register Login

use the webcam in java application

+Pie Number of slices to send: Send
I am using netbeans IDE 7.1.1,JMstudio I'm making the application capture an image from a webcam, but my problem is that when I run that application first time it gives me proper output but when I run the same application again, it gives me this error:

java.io.IOException: Could not connect to capture device
javax.media.NoDataSourceException: Error instantiating class: com.sun.media.protocol.vfw.DataSource : java.io.IOException: Could not connect to capture device
at javax.media.Manager.createDataSource(Manager.java:1012)

can anyone tell me why this is happening?

my code is:

/* Grab the default web cam*/
MediaLocator ml = new MediaLocator("vfw://0");

/* Create my data source */
DataSource ds = Manager.createDataSource(ml);

requestFormatResolution(ds);

/* Create & start my player */
Player p = Manager.createRealizedPlayer(ds);

p.start();
Component videoScreen = p.getVisualComponent();
+Pie Number of slices to send: Send
can you provide the complete code?
+Pie Number of slices to send: Send
Welcome to the Ranch

You should be able to work out where things go wrong from the Exception stack trace. Maybe also put some print statements between those lines, then you can see whether each object is being constructed successfully.
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1967 times.
Similar Threads
Java Media Framework - How to capture screen activity?
JMF application not detecting web camera
video and audio capture issues
JMF application not detecting web camera
How can I run an applet for accessing the PC camera
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:59:37.