Install and use Java to develop opencv configurations in Linux

Source: Internet
Author: User

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

 
 
  1. sudo apt-get install build-essential python-dev cmake 

2) download opencv-2.4.8.zip and decompress it.

3) create a build folder

 
 
  1. cd ~/opencv 
  2. mkdir build 
  3. cd build 

4) Enter:

 
 
  1. cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..  
  2. make 
  3. 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:

 
 
  1. sudo apt-get install ant 

2) Run cmake. The key is the cmake parameter. The official website provides the following information:

 
 
  1. Export JAVA_HOME =/usr/lib/jvm/java-6-oracle # This statement should be optional.
  2. 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:

 
 
  1. cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTS=OFF .. 

3) Run cmake with the above parameters, and then: 

 
 
  1. make -j8 
  2. 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 !......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.