Install and use Java to develop opencv configurations in Linux
Inux compilation and installation of opencv
First of all, install opencv in linux is not troublesome, refer to the document can be completed: http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html
You can perform the following steps:
1) install gcc, cmake, and other messy software (however, by default, most of the software is available in ubuntu ...)
- sudo apt-get install build-essential python-dev cmake
2) download opencv-2.4.8.zip and decompress it.
3) create a build folder
- cd ~/opencv
- mkdir build
- cd build
4) Enter:
- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
- make
- sudo make install
The make command takes dozens of minutes... Then theoretically it's over... If you do not need java Development, you can run the python code in the sample folder...
However, if you want to use java for development, you need to do so .....
Install opencv-java
This step is very DT, because there is a document on the official website dedicated to how to develop with java... Http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html
1) First, install ant:
- sudo apt-get install ant
2) Run cmake. The key is the cmake parameter. The official website provides the following information:
- Export JAVA_HOME =/usr/lib/jvm/java-6-oracle # This statement should be optional.
- Cmake-DBUILD_SHARED_LIBS = OFF ..
Pay attention To the output. If "To be built" contains java, it should be OK .... Next, you only need to make-j8...
The most boring thing is that after running cmake with such a parameter, running make-j8 is always unsuccessful and there is an error .....
Found this is a BUG: http://code.opencv.org/issues/2859
Add the parameter-DBUILD_TESTS = OFF...
Therefore, the cmake parameter can be written as follows:
- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTS=OFF ..
3) Run cmake with the above parameters, and then:
- make -j8
- sudo make install
In this way, make will be successful...
How can I determine whether the installation is successful?
After the above operation, check the build folder, bin directory is not a opencv-248.jar file:
If so, the java component of opencv is successfully installed...
!! Note !! Cannot Use windows opencv installation directory that opencv-248.jar !! The jar generated just now is different from the jar in windows !! (I checked the MD5 code... In fact, the file size can also be seen !!)
Configuration in Eclipse
Here is a very good post, which is well written and I will not repeat it. Link:
Http://exintopro.net/blog/2013/10/02/setting-up-eclipse-for-using-opencv-java-in-ubuntu/
This post is very good, but I didn't introduce the part of the compilation. It took me half a day because the compilation process for installing java components is different from that on the official website !......