Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Hi i create one project using java swing. i want to take a snap picture using web cam when the button click event get generated.

I got some info as JMF is the best way to integrate java with web cam. But i cant have any knowledge in jmf. so please help me friends.

if you know another way to integrate java swing with web cam means please inform me.

else if you know how to use jmf means please help me... :)
Posted
Updated 27-Apr-17 4:57am

JMF sucks! It's completely outdated, not maintained any more and terribly complicated. The only good thing I can say about it is the fact it is pretty fast.

I'm the author of open source Webcam Capture project available on Github. It s goal is to give users access to build-in or USB connected webcams, same as for network or IP cameras, directly from Java code. You don't need to implement any additional software (as you have to do in case of JMF), it works standalone. It's pretty fast - in my case I was able t stream 250 FPS in BufferedImage objects.

The API I provided in Webcam Capture is really simple, there are many examples, so you can start developing your app and don;t care if it will be working on Linux, Windows, or Mac OS. Webcam Capture will run everywhere.

Here is a simple code. Assume you have two cameras connected to your PC (but of course, you can have only one).

Java
Webcam buildin = Webcam.getWebcams().get(0); // build-in laptop camera
Webcam usb = Webcam.getWebcams().get(1); // usb camera
BufferedImage image1 = buildin.getImage();
BufferedImage image2 = usb.getImage();
// do with image1 and image2 whatever you want
 
Share this answer
 
Hope this[^] will give you an idea.
 
Share this answer
 
Comments
Member 12056141 17-Oct-15 17:10pm    
I have written a code myself but it is not running it giving error can't find dependent libraries
Member 12056141 17-Oct-15 17:10pm    
can u plzz tell me the soln of this problem
Member 13156632 27-Apr-17 10:59am    
Why I have been encountered with this error????

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
[no name] 27-Apr-17 12:59pm    
Because you have something wrong with your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900