在树莓派Ubuntu Mate中安装OpenCV
2015-11-19 00:09
134 查看
在树莓派Ubuntu Mate中配置opencv与在ubuntu 14.04中配置opencv的过程没有什么大的差别,如果看过在ubuntu中配置opencv的话可以不用再看这篇了,这篇博文只是作为学习笔记。
1. Install OpenCV in Ubuntu:
(1) Update the list of package repositories:
(2) Remove previously installed FFMPEG and x264 libraries:
(3) Install the necessary packages for compiling the OpenCV sources:
(4) Make a directory to download and build OpenCV:
(5) Download the OpenCV sources for Linux, then unzip it:
(6) Create a directory to compile the OpenCV sources:
(7) Building OpenCV sources with CMake and install:
(8) Make and install:
(9) Restart the system for everything to take effect:
2. Test OpenCV in Ubuntu:
(1) Create a directory DisplayImage for test project:
(2) Create DisplayImage.cpp and edit it:
Then edit the DisplayImage.cpp:
(3) Create a CMake file:
Then edit the CMakeLists.txt:
(4) Generate the executable file:
(5) Execute it:
lena.jpg is the test image
本文根据www.Micro_Studios.com的视频教程整理。特此感谢!
1. Install OpenCV in Ubuntu:
(1) Update the list of package repositories:
sudo apt-get update sudo apt-get upgrade
(2) Remove previously installed FFMPEG and x264 libraries:
sudo apt-get remove ffmpeg x264-dev
(3) Install the necessary packages for compiling the OpenCV sources:
sudo apt-get install ocl-icd-libopencl1 build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils
(4) Make a directory to download and build OpenCV:
mkdir opencv cd opencv
(5) Download the OpenCV sources for Linux, then unzip it:
wget -O opencv-2.4.10.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.10/opencv-2.4.10.zip/download unzip opencv-2.4.10.zip cd opencv-2.4.10
(6) Create a directory to compile the OpenCV sources:
mkdir build cd build
(7) Building OpenCV sources with CMake and install:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
(8) Make and install:
make sudo make install sudo sh -c 'echo "/usr/local/lib">/etc/ld.so.conf.d/opencv.conf' sudo ldconfig
(9) Restart the system for everything to take effect:
sudo shutdown -r now
2. Test OpenCV in Ubuntu:
(1) Create a directory DisplayImage for test project:
mkdir DisplayImage cd DisplayImage
(2) Create DisplayImage.cpp and edit it:
gedit DisplayImage.cpp
Then edit the DisplayImage.cpp:
#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("Noimage data\n"); return -1; } namedWindow("DisplayImage",CV_WINDOW_AUTOSIZE); imshow("DisplayImage", image); waitKey(0); return 0; }
(3) Create a CMake file:
gedit CMakeLists.txt
Then edit the CMakeLists.txt:
cmake_minimum_required(VERSION 2.8) project(DisplayImage) find_package(OpenCV REQUIRED) add_executable(DisplayImage DisplayImage.cpp) target_link_libraries(DisplayImage ${OpenCV_LIBS})
(4) Generate the executable file:
cmake . make
(5) Execute it:
./DisplayImage lena.jpg
lena.jpg is the test image
本文根据www.Micro_Studios.com的视频教程整理。特此感谢!
相关文章推荐
- Linux下MySQL数据库常用基本操作 一
- 决策树和opencv实现,随机森林,随机蕨
- javascript电商网站抢购倒计时效果实现
- laravel git上传问题 php升级 nginx修改
- centos安装apache的apr
- Tomcat中server.xml各个元素关系与配置
- linux简单磁盘操作
- J2EE开发 MVC 电子商务网站
- Linux 下java jdk安装
- linux shellScripts-1
- linux shellScripts-2
- linux shellScripts-3
- 在线实用工具网站
- 【原】Centos 6 搭建WordPress所需要的软件包
- 【转】搭建Apache时重启报错(小错误集合)
- Android Linux 常用命令
- tensorflow网站
- nginx之nginx.cof详解
- Apache 一个ip多个域名设置(虚拟主机)
- Linux/Ubuntu下限制用户在特定目录的权限