OpenCV Getting Started note (i) installation under Linux

Source: Internet
Author: User

About OpenCV, there is the official site of Chinese. Translation of the official website of the tutorials and APIs. Chinese official tutorials See here: "Tutorials"

First, the installation under Ubuntu

can choose to install directly from the library, or manually compile the installation, please refer here: "Installation in Linux"

1. Installing from the Repository (library)
sudo apt-get install libopencv-dev python-opencv
2. Manually compile the installation

First of all to solve the OpenCV dependency problem, directly under the terminal execution

sudo apt-get install build-essentialsudo 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 libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

From

Source=navbar ">sourceforge" Download the source code above, just don't know why. My Ubuntu15.04 can't compile open-2.4.11, just can be next opencv-2.4.10. Go to the folder. Compile directly with cmake such as the following

mkdir buildcd buildcmake ..sudo makesudo make install
3. Examples

After compiling the first to run a sample, see here: "Linux sample", in fact, is an ordinary C + + sample, new CPP and TXT file, compile and execute.

DisplayImage.cpp

#include <cv.h>#include using namespaceCvintMainintargcChar* * argv) {Mat image; Image = Imread (argv[1],1);if(ARGC! =2|| !image.data) {printf("No image data \ n");return-1; } Namedwindow ("Display Image", cv_window_autosize); Imshow ("Display Image", image); Waitkey (0);return 0;}

CMakeLists.txt

project( DisplayImage )find_package( OpenCV REQUIRED )add_executable( DisplayImage DisplayImage )target_link_libraries${OpenCV_LIBS} )

Compile

cd <DisplayImage_directory>cmake .make

Perform

./DisplayImage lena.jpg

The famous Lena Map can give a link: "Lena map"

Ii. development of OpenCV with Python

Found in addition to C + +. Python's support for OpenCV is also particularly good.

In the official interface documentation, C + + is generally given. C and Python three kinds of interfaces.

Python support

First of all. Installing the Python OPENCV module

sudo apt-get install python-opencv

Here's a sample example

import cv2img = cv2.imread("lena.jpg"# load imagecv2.imshow("image", img)    # show imagecv2.waitKey(0)  # wait until key pressed

Name is test.py. directly in the terminal.

python test.py# orpython ./test.py

Direct execution is possible.

This example simply loads the picture in and displays it in the original size, and the functions are overloaded. Detailed use of the method will go to check.
Discover a PYTHON-OPENCV document written by Daniel on GitHub, great, Link here: "Opencv-python tutorials".

There is no use of functions, directly on the left to search.

Can be combined with the official "tutorials" to see.

OpenCV Getting Started note (i) installation under Linux

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.