Fedora15 + opencv2.2 + eclipse

Source: Internet
Author: User

1. Install opencv

First of all, I use a 64-bit fedora15 system.

Method 1: many methods on the Internet are to manually download the opencv installation package, decompress the package, cmake, and configure the path. This method should be generic, as well as in the opencv Chinese forum.

Write down the steps to install opencv2.2 in fedorar15 (I use the following method, which is simpler, but it does not seem to work for video processing, need to process video to friend can refer to opencv Chinese forum on another article http://www.opencv.org.cn/forum/viewtopic.php? F = 1 & t = 4670), in case you need to consult with your friends.

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ///////////

Install the dependency package: (need rpmfusion)
<Code bash>
Yum-builddep opencv
The yum install libv4l-devel FFMPEG-devel
</Code>
Decompress opencv2.2 to a directory, and then
<Code bash>
Cd ~ /Projects/opencv # The Directory containing install, cmakelists.txt etc.
</Code>
In this case, patch is required. Otherwise, the compilation fails.
Patch download: [[http://ge.tt/6D5aI6o? C]
<Code bash>
# Gcc4.6
Patch-np3-I "../opencv_patch/gcc46.patch"
# Kernel 2.6.38
Patch-Np1-I "../opencv_patch/v4l_2.6.38.patch"
# Https://code.ros.org/trac/opencv/ticket/731
Patch-np0-I "../opencv_patch/ptrcvcapture. Patch"
</Code>
After completing patch
<Code bash>
Mkdir release
CD release
Cmake-D cmake_build_type = release \
-D cmake_install_prefix =/usr/local \
-D cmake_skip_rpath = on \
-D with_xine = on \
-D with_qt = on \
-D with_unicap = off \
-D build_examples = on \
-D build_tests = off \
-D install_c_examples = on \
-D install_python_examples = on \
..
</Code>
The with_qt option enables highgui to use the QT backend, which is of little use and does not need to be used.

If everything is normal, you can make the next step.
<Code>
Make
Sudo make install # Install without selecting
</Code>
Configure the environment after installation:
<Code bash>
Export pkg_config_path =/usr/local/lib/pkgconfig: $ pkg_config_path
Export LD_LIBRARY_PATH =/usr/local/lib: $ LD_LIBRARY_PATH
Sudo ldconfig
</Code>
Then, place the two export statements in ''. Profile ''.

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ////////////////////////////////////////

Method 2 (recommended ):

Use yum in the terminal:

<Code bash>
Yum install opencv-Python opencv-devel-docs
</Code> (the directory/usr/share/opencv/samples is displayed after the installation is successful. The first installation prompt is successful. This will not be available after the installation is re-installed)
Modify ''/usr/lib64/pkgconfig/opencv. pc'' and add"-lm "at the end of libs"

Go to the '/usr/share/opencv/samples/C' directory and make. Success! Then you can run the program.

Or enter the CPP directory, G ++ 'pkg-config -- cflags -- libs opencv 'Drawing. cpp-o Draw, and then run./draw. If the system prompts that no header file exists, Run "ldconfig" under "root.

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////

2. Build a project under ecplise

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////

Reference someone else to a method: http://www.cnblogs.com/yangyangcv/archive/2011/04/20/2022359.html

1) Open eclipse, file-> New-> C ++ project, enter the project name, such as opencvtest, and select "Hello World C ++ project" under "project type, 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) similar to using Visual Studio in windows, 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 des, add path/usr/local/include. Note. 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
In C ++ linker-> libraries, add/usr/local/lib to library search path and add opencv_cv opencv_cxcore opencv_highgui to libraries. Note: we can see libopencv_highgui.so libopencv_cv.so libopencv_cxcore.so and other files under/usr/local/lib, but we only need to fill in opencv_cv opencv_cxcore opencv_highgui in eclipse, instead of LIB and later. so

4) Right-click the project opencvtest and select buildproject. After the project is successfully run as local C/C ++ application, you can see the beautiful things drawn by opencv!

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

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////

The third step in the method listed above is cumbersome. You can use this simple point to the method: after the project is created, in Project-> C ++ build-> setting, add 'pkg-config -- cflags opencv 'to miscellaneous in C ++ complier and add 'pkg-' to the same position of C ++ link- config -- libs opencv ', this operation can be compiled and run successfully. Here is the quotation mark, which is next to number key 1.

Summary: Lib File Location: 32-bit system:/usr/local/lib 64-bit system:/usr/lib64

. H header file: 32-bit system:/usr/local/include/64-bit system:/usr/include/opencv

If the problem persists, run the "find" command and configure it in eclipse.

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////

Below are some links I think are helpful. Thank you!

Http://www.2cto.com/ OS /201109/104671.html

Http://www.cnblogs.com/yangyangcv/archive/2011/04/20/2022359.html

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.