OPENCV 2.4.9 Configuration installation under Ubuntu

Source: Internet
Author: User

Reproduced from

OPENCV 2.4.9 Configuration installation under Ubuntu

Every time you learn something new or change a new computer, the most annoying thing is the installation of the environment. There are a lot of tutorials on the Internet, but in general, it's confusing, some even misleading, and of course some quality blogs. To make it easier for you to repeat the installation later and to help friends in need, here are some useful blogs to sort out.

Here are some of the main ways to install OpenCV (2.4.9) under Ubuntu (12.04). OpenCV source code can be downloaded in its official website, can also be downloaded in Baidu Network disk. Some of the most recent versions of OPENCV are compiled using CMake, and the configuration process is basically the same.

One, dependent package installation

Installing software under Ubuntu is more or less required to install some dependent packages (software). OPENCV is no exception.

1. The Build-essential software package, which provides the compiler with a list of required packages, so that the package knows where the header file and library functions are. It also downloads dependent packages, installs basic programming tools such as Gcc/g++/gdb/make, and finally makes up a development environment.

[Plain]View Plaincopy
    1. sudo apt-get install build-essential

2. The following dependencies are primarily designed to support reading and writing pictures and videos.

[Plain]View Plaincopy
    1. sudo apt-get install Libgtk2.0-dev libavcodec-dev libavformat-dev libtiff4-dev libswscale-dev Libjasper-dev

3. Install CMake, can download the source code compiled online, you can also download the Baidu Network 2.8.12 version, of course, you can use the Apt-get method directly.

[Plain]View Plaincopy
    1. sudo apt-get install CMake

4. Install Pkg-config, which is a computer software that provides a unified interface for querying an installed library when compiling software from source code.

[Plain]View Plaincopy
    1. sudo apt-get install Pkg-config

Second, compile the installation process

1. Using CMake to detect the compilation environment and to generate makefile and other project information, you can set some parameters using the CMake procedure.

Using CMake in this directory, note that the following points indicate looking for CMakeLists.txt in the current directory.

[Plain]View Plaincopy
    1. CMake.

You can also create a folder in a different directory, the most common is a subdirectory. Of course, some parameters can be configured at the time of construction:

[Plain]View Plaincopy
    1. CD opencv-2.4.9
    2. mkdir Release
    3. CD release
    4. Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local.

2. Compiling with Make

[Plain]View Plaincopy
    1. Make

3. Install with make install

[Plain]View Plaincopy
    1. sudo make install

4. The above procedure basically completes the installation of the OPENCV. However, it is not possible to use it immediately, OPENCV also contains many dynamic link libraries. You can add/usr/local/lib to the file/etc/ld.so.conf (this is related to the installation directory, {cmake_install_prefix}/lib), or in/ETC/LD.SO.CONF.D Add a conf file to the directory (which can be named opencv.conf), adding the same/usr/local/lib

Use the following Dynamic Library Management command Ldconfig to let the relevant link libraries of OPENCV be shared by the system

[Plain]View Plaincopy
    1. sudo ldconfig-v


5. The sharing of dynamic libraries has been completed, it is not possible to program using OPENCV, and the OPENVC header file location for the program needs to be specified. This is done using the Pkg-config command. First, add the/etc/profile in the

[Plain]View Plaincopy
    1. Export Pkg_config_path= $PKG _config_path:/usr/local/lib/pkgconfig

Pkg-config maintains a configuration file about OpenCV, a file (opencv.pc) in the directory/usr/local/lib/pkgconfig, which records some of the OPENCV's dynamic library information, as well as header file information

You can list configuration information about OpenCV by using the Pkg-config command:

Third, testing

1. Locate samples/c/build_all.sh in the extracted OpenCV directory and run the file

[Plain]View Plaincopy
    1. ./build_all.sh

2. Find one to run a look at the effects, such as the Find_obj program:

At this point, about OPENCV in the installation of Ubuntu successfully, enjoy the world of computer vision to swim!

OPENCV 2.4.9 Configuration installation under Ubuntu

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.