Monday, May 31, 2010

Installing OpenCV for Java on Ubuntu 10.04

In this article I discuss how I set up OpenCV with Java on my Ubuntu 10.04. Primarily, I followed the process described at http://ubaa.net/shared/processing/opencv/ but with several changes (when I was stuck in the middle due to the old version used in the installation at the site). 

First, I installed OpenCV on Ubuntu using sudo apt-get install libcv-dev

Then, I put the openCV wrapper files known as "Processing OpenCV Library" from (this is the version that worked on my installation):

http://ubaa.net/shared/processing/opencv/download/2.0/beta/opencv-linux_2.0b.tar.gz

in a dir1 and then added to my JVM options java extensions directory as specified on the Processing page: -Djava.ext.dirs=dir1


I also had to install libcvaux-dev to resolve some link errors: sudo apt-get install libcvaux-dev.   

For the Face Detection to work, I had to set the cascade using OpenCV::cascade function before the OpenCV::detect call. After this, the example FaceDetection.java worked for me.

Sometime soon I needed the class file for PImage at run time. For this, I downloaded Processing from http://processing.org/download/processing-1.1.tgz. Then I put the directory containing core.jar (dir2) also in the java extensions setting above. That is,
-Djava.ext.dirs=dir1:dir2

No comments: