Use eclipse on Ubuntu to create an opencv Project

Source: Internet
Author: User

I have been tossing Ubuntu recently. I will summarize some things and hope to help you. Because I am also a beginner, please correct me if any error occurs in the content.

Software Version

Ubuntu10.04

Opencv2.2.0

Eclipse
3.6 (Helios) CDT

This article mainly introduces how to use eclipse to create an opencv project on Ubuntu. To introduce the integrity, we will first introduce how to download, compile, and install opencv.

1) create a folder named opencv2_2 under the Home directory, and then create two folders in opencv2_2, one being opencv2_2_src and the other being opencv2_2_build for later cmake.

2) To http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.2/
Download opencv-2.2.0.tar.bz2, decompress it, and copy it to opencv2_2_src.

3) input at the terminal
The cmake-Gui opens the cmake graphical window. Click Browse source, select opencv2_2_src created in the previous step, Click Browse build, and select opencv2_2_build created in the previous step. Click Configure. If the window turns red, click Configure again until the window is unavailable. Click Generate. (Note: if an error window pops up after configure, it means that some necessary software is not installed yet. You need to install the software first)

4) enter the opencv2_2_build folder on the terminal CD and enter
Make should be successful after waiting for a while. Enter make on the terminal.
Install. Then opencv is installed to the default/usr/local directory. Enter usr/local/lib. You can see libopencv_ml.so
Libopencv_highgui.so

So far, the installation is complete.

 

Create a project in eclipse and use opencv

1) Open eclipse, file-> New-> C ++
Project, enter the project name, such as opencvtest,
Select "Hello World C ++ project" under "executable" in "project type" and run "Next" until "finish. In this case, eclipse creates a file named opencvtest. cpp for us.

2) Take the drawing. cpp provided by opencv as an example. Go to the previously created opencv2_2_src, go to samples-> CPP, open drawing. cpp, and copy all the content to opencvtest. cpp.

3) Use Visual
Similar to Studio, we need to tell the project include path, lib path, and corresponding lib file. Find the created opencvtest in the project explorer on the left of Eclipse, right-click it, and select Properties, C/C ++ build-> Settings-> gcc C ++
Compiler-> nodes, add path/usr/local/include Note: because in the drawing. CPP writes # include <opencv2/CORE/core. HPP>, so we only need to add the path to the/usr/local/include layer, instead of the/usr/local/include/opencv2 layer. Continue to set the Lib path. In gcc C ++
In linker-> libraries, add/usr/local/lib in the library search path below to opencv_cv opencv_cxcore opencv_highgui in the libraries. Note: we can see libopencv_highgui.so in/usr/local/lib.
Libopencv_cv.so libopencv_cxcore.so, but we only need to fill in opencv_cv in eclipse.
Opencv_cxcore: opencv_highgui. Do not use the preceding lib and later. So.

For the sake of clarity, borrow a picture from someone else

4) Right-click the opencvtest project and select build.
Project, run as local C/C ++ application, you should be able to see the beautiful things drawn by opencv!

In addition, when I searched the internet, many people said that after installing opencv, they need to go to/etc/lD. So. conf
Add a line of/usr/local/lib to the file and run the command sudo ldconfig. However, I did not need to do this myself. The system should have done this well when making install.

Related Article

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.