Compiling and installing OpenCV 3.1.0 in Ubuntu
Opencv compilation and installation in Ubuntu
Install the compiling environment:
Sudo apt-get install build-essential
Required package installation:
Sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
Optional package installation:
Sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
Opencv download:
Stable version
Wget https://github.com/Itseez/opencv/archive/3.1.0.zip
Github source code
Git clone git: // github.com/Itseez/opencv.git
Create a temporary directory for compilation:
Cd ~ /Opencv
Mkdir build
Cd build
Note: we assume that the source code directory extracted by opencv or obtained from github is in the user's main directory.
Generate cmake compilation Configuration:
Cmake-D CMAKE_BUILD_TYPE = Release-D CMAKE_INSTALL_PREFIX =/usr/local ..
Compile:
Make-j4 # runs 4 jobs in parallel
Install opencv:
Sudo make install
Run the test:
Git clone https://github.com/Itseez/opencv_extra.git
OPENCV_TEST_DATA_PATH = ~ /Opencv_extra
~ /Opencv/build/bin/opencv_test_core
Example:
First, create a directory test and enter the directory:
Mkdir test
Cd test
Create the DisplayImage. cpp file as follows:
# Include <stdio. h>
# Include <opencv2/opencv. hpp>
Using namespace cv;
Int main (int argc, char ** 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;
}
Create the cmake configuration file CMakeLists.txt as follows:
Cmake_minimum_required (VERSION 2.8)
Project (DisplayImage)
Find_package (OpenCV REQUIRED)
Include_directories ($ {OpenCV_INCLUDE_DIRS })
Add_executable (DisplayImage. cpp)
Target_link_libraries (DisplayImage $ {OpenCV_LIBS })
Last run:
./DisplayImage bkjia.jpg # any image is required.
Refer:
Http://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html
Http://docs.opencv.org/3.1.0/db/df5/tutorial_linux_gcc_cmake.html
OpenCV official tutorial Chinese version (For Python) PDF
Install the required OpenCV2.4.1 package in Ubuntu Linux
Install OpenCV2.4.2 on Ubuntu 12.04
OpenCV in CentOS cannot read Video Files
Summary of installing OpenCV 2.4.5 in Ubuntu 12.04
Install OpenCv2.1 in Ubuntu 10.04
Face Recognition System Based on QT and OpenCV
Install OpenCV 2.4.9 in Ubuntu 14.04 and 13.10
OpenCV details: click here
OpenCV: click here