Академический Документы
Профессиональный Документы
Культура Документы
https://help.ubuntu.com/community/OpenCV
Partners
Support
Community
Ubuntu.com
Page History
Login to edit
Search
OpenCV
Introduction
OpenCV (open source computer vision) is released under a BSD license and hence its free for both academic and commercial use. It has C++, C, Python and Java interfaces and supports Ubuntu Linux. OpenCV was designed for computational efficiency and with a strong focus on real-time applications.
OpenCV is the most popular and advanced code library for Computer Vision related applications today, spanning from many very basic tasks (capture and pre-processing of image data) to high-level algorithms (feature extraction, motion tracking, machine learning). It is free software and provides a rich API
in C, C++, Java and Python. Other wrappers are available. The library itself is platform-independent and often used for real-time image processing and computer vision.
Tabla de Contenidos
Version Note
Ubuntu's latest incarnation, Utopic Unicorn, comes with a new version of libav, and opencv sources will fail to build with this new library version. Likewise, some packages required by the script no longer exist (libxine-dev, ffmpeg) in the standard repositories. The procedures and script described below will
therefore not work at least since Ubuntu 14.10!
Installation
1. Introduction
2. Version Note
3. Installation
1. Step 1
2. Step 2
4. Running OpenCV
1. Python
2. in C
3. In C++
Many people are having problem with installing OpenCV even from Ubuntu Software Centre. Here a simple .sh script file get all dependancy files from internet and compile the source finally install opencv on your system. So that users can easily write their CV files from C,C++, and Python
Step 1
Download the latest opencv.sh from https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/ or Copy the following script to gedit and save as opencv.sh
[des]activar nros. de lnea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Note: If you are running 13.10 and you don't have a nvidia card then ensure you install ocl-icd-libopencl1 (sudo apt-get install ocl-icd-libopencl1) before running this script. Ubuntu 13.10 will install nvidia-319-updates as a dependency for libopencv-dev by default if ocl-icd-libopencl1 is not installed (see bug report).
Step 2
Open terminal.
[des]activar nros. de lnea
1 $ chmod +x opencv.sh
2 $ ./opencv.sh
Running OpenCV
Python
Loading an image in Python
[des]activar nros. de lnea
1 from cv2.cv import *
2
3 img = LoadImage("/home/USER/Pictures/python.jpg")
4 NamedWindow("opencv")
5 ShowImage("opencv",img)
6 WaitKey(0)
Note that the test program waits for a key press to end.
in C
Loading an image file in C
[des]activar nros. de lnea
1
2
3
4
5
6
7
8
9
10
11
12
#include
#include<opencv2/highgui/highgui.hpp>
int main()
{
IplImage* img = cvLoadImage("/home/USER/Pictures/python.jpg",CV_LOAD_IMAGE_COLOR);
cvNamedWindow("opencvtest",CV_WINDOW_AUTOSIZE);
cvShowImage("opencvtest",img);
cvWaitKey(0);
cvReleaseImage(&img);
return 0;
}
In C++
Loading an image file in C++
[des]activar nros. de lnea
1
2
3
4
5
6
7
8
9
10
11
12
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
int main()
{
Mat img = imread("/home/USER/Pictures/python.jpg",CV_LOAD_IMAGE_COLOR);
imshow("opencvtest",img);
waitKey(0);
return 0;
}
to compile in C++
[des]activar nros. de lnea
1 $ g++ -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.cpp .cpp` opencvtest.cpp `pkg-config --libs opencv`
2 $ ./opencvtest
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
"opencv2/core/core_c.h"
"opencv2/core/core.hpp"
"opencv2/flann/miniflann.hpp"
"opencv2/imgproc/imgproc_c.h"
"opencv2/imgproc/imgproc.hpp"
"opencv2/video/video.hpp"
"opencv2/features2d/features2d.hpp"
"opencv2/objdetect/objdetect.hpp"
"opencv2/calib3d/calib3d.hpp"
"opencv2/ml/ml.hpp"
"opencv2/highgui/highgui_c.h"
"opencv2/highgui/highgui.hpp"
"opencv2/contrib/contrib.hpp"
#!/bin/bash
echo "compiling $1"
if [[ $1 == *.c ]]
then
gcc -ggdb `pkg-config --cflags opencv` -o `basename $1 .c` $1 `pkg-config --libs opencv`;
elif [[ $1 == *.cpp ]]
then
g++ -ggdb `pkg-config --cflags opencv` -o `basename $1 .cpp` $1 `pkg-config --libs opencv`;
else
echo "Please compile only .c or .cpp files"
fi
echo "Output file => ${1%.*}"
Note that the .bashrc is a hidden file. Do not include the '$' characters at the beginning of each line. The alias will work after you log out and back. You can type the alias opencv... command at the prompt to set the alias for the current session.
CategoryProgramming CategoryInstallation
OpenCV (ltima edicin 2015-03-16 23:49:10 efectuada por reut-sharabani @ dsl212-143-38-222.bb.netvision.net.il[212.143.38.222]:reut-sharabani)
1 de 1
04/07/15 13:04