Update: These instructions are also applicable for 2.4+ version of opencv and javacv.
I was looking for image processing library for Java. My search stopped at
JavaCV.
JavaCV provides wrappers for
OpenCV. so you can directly use
OpenCV functions in Java.
JavaCV also provides hardware accelerated full screen Image display with CanvasFrame and GLCanvasFrame.
JavaCV provides jar files which can be used with
OpenCV installation. Following steps can be followed to setup
JavaCV with
Eclipse on Windows 7.
1.Install Java Development Kit (JDK) from the link below. Make sure to install 32bit or 64 bit as per your processor.
http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html
2. Install Microsoft Visual C++ redistributable package
For 32 bit:
http://www.microsoft.com/download/en/details.aspx?id=5555
For 64 bit:
http://www.microsoft.com/download/en/details.aspx?id=14632
3. Download OpenCV super-pack from Sourceforge and extract it in you C:\Opencv
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/
4. Set OpenCV .dll in systems path so that JavaCV can access it.
Go to Control Panel > System Security > System > Advanced System Settings > Environment Variables
In
System variable select
path and click on
Edit. Now add following address in Variable address. I have extracted opencv package in C:\ directory. If you have installed at different location please update address accordingly.
For OpenCV 2.4.2 and earlier version
For 32 bit:
C:\opencv\build\x86\vc10\bin;C:\opencv\build\common\tbb\ia32\vc10\
For 64 bit:
C:\opencv\build\x64\vc10\bin;C:\opencv\build\common\tbb\intel64\vc10\
For OpenCV 2.4.3 and later version
For 32 bit:
C:\opencv\build\x86\vc10\bin
For 64 bit:
C:\opencv\build\x64\vc10\bin
Once this is done, the most important step is to
Restart Windows.
5. Download JavaCV- bin from link below and extract it.
http://code.google.com/p/javacv/downloads/list
6. Create New Java Project 'demo' in Eclipse.
Once created, go to Project > Properties > Java Build Path > Libraries > Add External JARs .
Go to your JavaCV Extracted folder and add all jar files. It should look like the pic below
7. Now create demo.java in src folder of the project.
Paste following code and run the project.Put your image in project folder. In my case it is
'img1.png'
Result will look like this