Linux下OpenCV的安装配置

Linux下OpenCV的安装配置

1 安装cmake及一些依赖库

sudo apt-get install cmake
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev

CentOS或RedHat:

yum install cmake gcc gcc-c++ gtk+-devel gimp-devel gimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devel libpng-devel gstreamer-devellibavc1394-devel libraw1394-devel libdc1394-devel jasper-devel jasper-utils swig Python libtool nasm

2 安装opencv

从官网下载opencv并解压,cd命令进入opencv的目录

下载地址:http://opencv.org/downloads.html

cmake .
(cmake时间较长,约半小时)

sudo make

sudo makeinstall

3 配置

将opencv的库加入到路径,从而让系统可以找到,没第一个就加第二个

sudo gedit /etc/ld.so.conf.d/opencv.conf

sudo gedit /etc/ld.so.conf

末尾加入/usr/local/lib,保存退出

sudo ldconfig #使配置生效

sudo gedit /etc/bash.bashrc

末尾加入
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

保存退出
sudo source /etc/bash.bashrc #使配置生效

OpenCV的详细介绍:请点这里
OpenCV的下载地址:请点这里

相关推荐