Webcam Access using Java and Maven

After lots of implementations on JMF,OpenCV and JavaCV i came across “Webcam Capture” a Generic Webcam Java Utility which has the capability of maven dependency management which is the best part i have seen. Following are the core features of the api.

Core Features

Simple and thread-safe API – write only few lines of code and start capturing images.
Work standalone – no additional software has to be installed to use it.
System independent – it will run without problems on most widely used operating systems – Windows (2k/XP/Vista/7, both 32- and 64-bit), Linux (x86, x64 and 32-bit ARM) and Mac OS X.
Built-in video driver – default built-in video grabber is provided, so you don’t need to install any additional software (such as JMF, etc).
Implementation independent – write your code once and don’t care which capture framework you will be using in future (LTI-CIVIL, JMF, QTJ, etc).
Automated resources management – you do not have to remember to deallocate resources used by your capturing device, library will always do that for you (while VM has been closed gracefully).
Motion detector – build in motion detector makes it easy to implement motion detecting features.
Available in Maven Central – it is available in Maven Central so your project can be deployed there too.
Re-streamer – simple JPEG/MJPEG re-streamer is build in, just run it and enjoy hosting your live stream.
Swing ready – contains Swing component to display images, together with painter API and thread-safe API which prevents Swing EDT from blocking issues when using camera.

How To Start

Webcam Capture is avilable in Maven Central, so if you can add its dependency to your project if you are using one of the dependency manager like Maven add the following code to your pom.xml file.


here is the code for “MotionDetection” using Webcam Capture API




 * Detect motion.
 * @author Mantha Pavan Kumar
public class DetectMotionExample implements WebcamMotionListener {

	public DetectMotionExample() {
		WebcamMotionDetector detector = new WebcamMotionDetector(Webcam.getDefault());
		detector.setInterval(100); // one check per 100 ms

	public void motionDetected(WebcamMotionEvent wme) {
		System.out.println("Detected motion I, alarm turn on you have");

	public static void main(String[] args) throws IOException {
		new DetectMotionExample();; // keep program open

and for further details please visit: and follow the site.
Happy Coding 🙂


One thought on “Webcam Access using Java and Maven

  1. I read your post regarding java that is good. please send latest video related to garbage collector, class ,object, method, constructor(which contain topic of this) also send advance video of iit delhi (computer science) who is provide video this toipc.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s