This document documents the process of manually installing OPENCV using source code under Ubuntu. Steps from OPENCV official website
The method of installing and loading OpenCV in Python is also documented.
1. Install OpenCV required libraries (compilers, required libraries, optional libraries)
Reprint please explain http://www.cnblogs.com/llxrl/p/4471831.html
- GCC 4.4.x or later
- CMake 2.6 or higher
- Git
- gtk+2.x or higher, including headers (Libgtk2.0-dev)
- Pkg-config
- Python 2.6 or later and Numpy 1.5 or later with developer packages (Python-dev, python-numpy)
- FFmpeg or LIBAV development Packages:libavcodec-dev, Libavformat-dev, Libswscale-dev
- [Optional] libtbb2 Libtbb-dev
- [Optional] libdc1394 2.x
- [optional] Libjpeg-dev, Libpng-dev, Libtiff-dev, Libjasper-dev, Libdc1394-22-dev
1 sudo Install build-essential2sudoinstall cmake git libgtk2. 0 pkg-config libavcodec-dev libavformat-dev libswscale-Dev3sudoinstall python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22
C13>-dev
2, download the latest OPENCV source code (more than 2.4) from the official website
http://sourceforge.net/projects/opencvlibrary/
or GitHub.
3. Compiling OPENCV
Put OpenCV into any directory, unzip
Unzip opencv-3.0. 0-rc1. zip
Create a compiled directory, compile
CD ~/opencv-3.0. 0-RC1mkdir-D cmake_build_type=release-d cmake_install_prefix=/usr/ Local.. Make sudo Make Install
4. Test OPENCV1) Create working directory
mkdir ~/opencv-lena
CD ~/opencv-lena
Gedit DisplayImage.cpp
2) Edit the following code
#include <stdio.h>#include<opencv2/opencv.hpp>using namespaceCV;intMainintargcChar**argv) { if(ARGC! =2) {printf ("usage:DisplayImage.out <image_path>\n"); return-1; } Mat image; Image= Imread (argv[1],1 ); if( !image.data) {printf ("No image data \ n"); return-1; } Namedwindow ("Display Image", window_autosize); Imshow ("Display Image", image); Waitkey (0); return 0;}3) Create CMake compilation file
Gedit CMakeLists.txt
Write the following:
2.8 ) Project (displayimage) find_package (OpenCV REQUIRED) add_executable (displayimage displayimage. CPP ) target_link_libraries (DisplayImage ${opencv_libs})
4) Compiling
CD ~/opencv-lenacmake. Make
5) execution
At this time the Opencv-lena folder has produced the executable file displayimage, download lena.jpg placed under Opencv-lena, run
./displayimage lena.jpg
6) Results
5, Installation Python-opencv
Can be installed directly using apt
sudo Install python-opencvsudoinstall python-numpy
Test:
Open the Python,import CV module to succeed.
Import CV
UBUNTU14.04+OPENCV 3.0+python2.7 Installation and testing