How can I continuously capture images from a webcam?
I want to experiment with object recognition (by maybe using java media framework).
I was thinking of creating two threads
one thread:
- Node 1: capture live image
- Node 2: save image as "1.jpg"
- Node 3: wait 5 seconds
- Node 4: repeat...
other thread:
- Node 1: wait until image is captured
- Node 2: using the "1.jpg" get colors from every pixle
- Node 3: save data in arrays
- Node 4: repeat...
This JavaCV implementation works fine.
Code:
There is also post on configuration for JavaCV
You can modify the codes and be able to save the images in regular interval and do rest of the processing you want.
Try using JMyron How To Use Webcam Using Java. I think using JMyron is the easiest way to access a webcam using java. I tried to use it with a 64-bit processor, but it gave me an error. It worked just fine on a 32-bit processor, though.
Here is a similar question with some - yet unaccepted - answers. One of them mentions FMJ as a java alternative to JMF.
You can try Marvin Framework. It provides an interface to work with cameras. Moreover, it also provides a set of real-time video processing features, like object tracking and filtering.
Take a look!
Real-time Video Processing Demo:
http://www.youtube.com/watch?v=D5mBt0kRYvk
You can use the source below. Just save a frame using MarvinImageIO.saveImage() every 5 second.
Webcam video demo:
For those who just want to take a single picture:
WebcamPicture.java