JavaCV Getting Started on Mac OSX with Eclipse

Hey everyone, I wanted to do a post on javacv because I’m a java frc programmer and we used a java wrapper last year for smart dashboard but this is a lot nicer. I’m hoping FRC teams can really start taking advantage of how easy camera vision seems to be getting every day. There is not a lot of documentation out there on it and the tutorial skips a few things to I wrote my own little guide to setting it up. This is for setting it up in eclipse, but it wouldn’t be much different in Netbeans and the OpenCV tutorial gives it’s description of setting it up barebones style.

 So first things first, we want to jump to the website where they give a pretty decent tutorial on setting up opencv for java. This tutorial is currently written for JavaCV 2.4.4. That is fine as nothing really changes as far as installation goes in recent updates : [](

 There are two options for installation. One is all through terminal and requires that you have git installed and clone into the github directory containing the folder with opencv. The other is that you download your OS specific folder from the sourceforge page where opencv has stored their folders. 

 The first option is pretty straightforward. In terminal you first need to navigate to the folder where you would like to store your opencv directory. In my case, I stored it in ~/Desktop/opencv. 

In terminal type:

cd desktop

(Then to clone from github)

git clone git://

(^ That will take a second.)

(now we go into the directory)

cd opencv

(checkout the version of the source that we want)

git checkout 2.4

 The second option is too simply download the opencv source from your browser. Navigate to []( . We will want to click on opencv-unix and then get the latest version which right now is . When you’ve downloaded that you may place it in any directory. 

  The next part is to compile/build all of the opencv source. For this we will need a terminal application called cmake. If you don’t already have it, it’s a quick install and can be obtained here : (Make sure to get the binary distribution for Mac OSX) 

  Once you have cmake, you will go into terminal and navigate to wherever you’ve placed you folder. Once there, type in: 

mkdir build

(make a directory for our build)

(go into that directory)

cd build

(now make the cmake file to build the source)


(^This command will generate a build file with the setting to build OpenCV as a set of static libraries in the directory back one from where you are.)

 There should be some output upon generation of this file. Check to see that java is in the OpenCV Modules to be built list. If it isn’t there, you might be missing a dependency in which case you should parse through the output to look for any java-related things that weren’t found.

 If all is well, then you can now type in terminal:

make -j8

(This will take a little bit, so maybe go make some coffee or something. However, when it’s complete, it will create all of the libraries you need for writing opencv in java!)

Now on to Eclipse

Eclipse is an IDE used by many java developers. It can be found here: . Once you have it downloaded and installed, you can follow the tutorial on OpenCV as they do a very good job at explaining how to set up in Eclipse. The one thing that they leave out is where the files/folder you need are. When you go to set your user library, the external jar is located in the opencv folder inside build/bin. When you edit the native library, the library is located in the opencv folder inside build/lib (You can just link it to the lib folder).

Now when you compile your project, all of your libraries should match up and you will compile your first program!

At the bottom of the page, the tutorial goes into how to make a facial recognition software. This is a great way to get started, but they leave out to make sure that you put the resource files into your bin folder in your project.

-Carter Henderson, Team 3929