Wednesday, 3 April 2013

Setup JavaCV in Windows

Hello Guys ,

Many of us struggled to get Video capture to work through Java , because of JMF , Oracle shut down the development of JMF after 2009 , it was difficult to capture video from Webcam as with JMF , it always gives Exception : Video Not Found

JavaCV , an OpenCV Java API , is easy to use and working API to do video manipulation with Java language without JMF.

Marvin Framework uses JMF in file MarvinVideoManager.Java 

But i have made it working with JavaCV.

First of all ,let us take a look at

Installation of OpenCV , JavaCV and setting work-space in Eclipse.

1) Download OpenCV from Link1 and JavaCV from Link2.

Also do check the pre-requisite of Open-CV , u need to have Microsoft Visual C++ redistributable package installed and check JDK also , its path and other things.

Microsoft Visual C++ redistributable

For 32 bit: click here
For 64 bit: click here

2) After Downloading Extract the Open CV to this Location :- C:\Opencv\

Please do not extract in other folder because some dll's point to the directory c:\opencv ,so , it can create a problem.

3) Now run this exact command at CMD - SETX /M OPENCV_DIR c:\Opencv\build

This sets the path of OpenCV in Environment .

After that go to Environment Variables in System Properties and set the path accordingly

the path is MyComputer->System Properties->Advanced System Properties.

At Advanced tab click on Environment Variables , there you will find a variable as path , if its not there , click on add make a path variable and enter the value as explained below.

Go to the very last position of the “Path” value and add one of the following strings:

For the 64 bit version, use - ;%OPENCV_DIR%\x64\vc10\bin;
For the 32 bit version, use - ;%OPENCV_DIR%\x86\vc10\bin;

more help here for example setting Environment variable.

look out for semicolon , its important.

4) Next thing is to set up JavaCV , you need to just extract the zip file downloaded , when you make any project in Eclipse using Marvin Framework , add the jars javacpp.jar and javacv.jar into build path.

One more jar is needed , jna-3.0.4 , download from here - LINK

Add all these into Build path of your project.

Try this Tutorial program to Capture through Webcam , Download from here.

After Downloading add these files in Eclipse Project and add all the jars i have already talked about.

See here the next post to use MarvinFramework with JavaCV.

In this tutorial you have seen how to:

  • Install OpenCV
  • Install JavaCV
  • Set up the System Environment Variables
  • Link JavaCV into the project.
  • Link JNA (Java Native Access) into the project.


  1. Hello Anshul. Firstly nice blog. I am a final year student and I wanted to ask for some help in Java related to ip camera streaming. The way in which you are grabbing video using JavaCV from a webcam, is it possible to add a URL to grab feed from an IP camera? Could you please point me in the right direction here? Would really appreciate your help!

    1. HI , in few days i will be posting the same , i will keep you posted.


  2. Hello Sir! I want to work on face detection in java .please guide me how to make this.

  3. Hello Sir! I want to work on face detection in java .please guide me how to make this.

  4. Hello Sir! I want to work on face detection in java .please guide me how to make this.