In this post I will show you how to compile and install OpenCV.
1. Download and compile
- Latest Java Version
- Apache Ant
First type in git clone https://github.com/opencv/opencv.git
(to get OpenCV's source code) then cd opencv
(go into the clonned directory).
Then create a build directory:
and go into it.
Here type in your Java's home directory, export JAVA_HOME=*here the directory*
then type in:
cmake -DBUILD_SHARED_LIBS=OFF ../
If everything goes well, you see that Java Tests, Java Wrappers, and Ant are passed, issue this command:
(the latter in theory runs faster, but crashed my system :( )
If everything went well you should have opencv-3xx.jar in the /opencv/build/bin directory and libopencv_java3xx.so in the /opencv/build/lib directory.
2. Install it in Eclipse
Open Eclipse and select a workspace of your choice. Create a User Library, ready to be used on all your next projects: go to Window > Preferences...
From the menu navigate under
Java > Build Path > User Libraries
Enter a name for the library (e.g., opencv) and select the newly created user library. Choose
Add External JARs...
, browse to select opencv-3xx.jar from your computer. After adding the jar, extend it, select
Native library location
and press Edit...
Select External Folder...
and browse to select the folder containing the OpenCV libraries. (opencv_directory/build/lib on Linux)