Real time video processing
How to use a Logitech WebCam in Java
With a bit of effort I was able to get Java Media Framework running. There were two key problems I ran into
1) The web-cam I was using wasn’t working. If you run the JMF app that comes with the API from Sun and your web-cam isn’t detected, make sure your camera actually works. The other issue may be that your camera was not detected because it was plugged in after you ran the tool the first time. You can run
java VFWAuto
from the command line (provided that the JMF classpaths are set properly) which will force Java to redetect all cameras connected to your system. Java doesn’t care what USB web-cam you use as long as it’s installed and working properly.
2) Eclipse was not seeing the classes. I had to add the JARs for the JMF just like I had to add the java runtime environment.
Once you have all that sorted out you’re ready to start using Test.java to get started playing with your web-cam. One other thing is that my video capture card was not detected. There may be a way to make use of your capture card but I havn’t figured that one out yet. The code that’s given at the above site and JMF appears to only detect USB web-cams.
So far I’ve been able to draw the frames real time in black and white, with a limited color set, and have created a simple algorithm for motion detection. Back when I was doing this with C++ I couldn’t get access to the raw frame data. This meant that anything that was displayed over the screen was considered part of the screen. With this you don’t have to render the actual video buffer. You can easily just render your modified frame.
If you have gone through the Real Time Software rendering tutorials for Java you will find a number of concepts that will come in very handy for real time video processing. The person who wrote the original code used an infinite loop (while(true)) with a thread which is not the proper Java way to do things. Doing it the right way (as seen in the RTSR tutorials) nets a very good performance boost. I’m able to render 320×240 with a reasonable frame rate using a cheap web-cam. I can get as high as 640×480.
Also, every time I exit the program it dumps an error log. I havn’t looked into how to fix that yet. I’ll probably do some official tutorials on real time video processing to show off some effects you can do but I’m not sure the time frame. There are a number of other projects I’m currently working on.
Leave a comment
You must be logged in to post a comment.