[Opencv + python in ubuntu] install opencv in ubuntu

Source: Internet
Author: User

[Opencv + python in ubuntu] install opencv in ubuntu

This article will introduce how to install opencv 2.4.10 in ubuntu 14.04. I know that it is not easy to get started. It is better to teach people to fish than to teach them to fish. I hope I can help some friends.

Prepare a stable system, select a source with good connection status (search for software & update in the upper left corner, select others, select a source with good connection status), download opencv, select the desired version to install Dependencies
Sudo apt-get install build-essential tialsudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-devsudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libang-dev libtiff-dev libjasper-dev libdc1394-22-dev (optional)

The following is for beginners:
Many installation guides write each step in this way, so we are very happy to copy and paste the photo, but why ?!
Back to the first thing, we will use opencv, so the first thing we will find in the search engineOfficial WebsiteAlthough all of them are in English, download is quite obvious, but what is the case for so many editions? The 3.x version has changed a lot. Most Common tutorials are the 2.x version. So you have a 2.4.10 version. What should I do next? You accidentally caught sight of please refer to the installation. After selecting THE corresponding system, an official INSTALLATION guide starts. Such a process is applicable to other things in the programming world, so please check the official website carefully.
PS: We use apt-get install to find resources from the source and download and install them.

Compilation and Installation

Now you have downloaded the source code and installed the dependencies. Next you need to compile the source code and install it on your system. After installation, you can easily call opencv in different languages.
1. Go to the download directory and decompress the package.

cd Downloadsunzip opencv-2.4.10.zipmv opencv-2.4.10 ~

2. Go to the source code directory and configure

cd ~/opencv-2.4.9mkdir buildcd buildcmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

3. Compile

sudo make -j4 

J4 uses four cores for make. You can check the number of cores of your cpu before deciding.

4. Installation

sudo make install

5. Add the system path

echo "# Use OpenCV and other custom-built libraries." >> ~/.bashrcecho "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/" >> ~/.bashrcsource ~/.bashrc

OK, so that the installation is complete. Note that during makefile configuration, you can install a cmake-gui to conveniently view and configure the strange options, what is the next process of compiling, installing, and adding a system path? To put it simply, everyone knows how to compile the code and convert the source code to machine code (a library that can be called, and so on). The installation is to put it under the default path of your system; as to why we need to add a path, we should consider it an extended question ~


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.