How to compile and install OpenCV in Eclipse

(65 Views)


In this post I will show you how to compile and install OpenCV.

OpenCV logo

1. Download and compile

Prerequisites:

  • Latest Java Version
  • CMake
  • Apache Ant

Download

Github logo

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).

Compile

Then create a build directory:

mkdir build
and go into it.
cd build

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:

make
or
make -j8
(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

Eclipse's logo

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
and choose
New...
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)

Solution Worked 0 UpvotesUpvote

        

Solution Didn't Worked 0 DownvotesDownvote



Comments



Search