安装工具
sudo apt-get install git
sudo apt-get install g++
sudo apt-get install vim
下载Opencv
解压
mkdir tmp
mv opencv-2.4.9.zip tmp
cd tmp
unzip opencv-2.4.9.zip
cd opencv-2.4.9
mkdir release
安装依赖库
sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev
在opencv的官方文档也有说明:
- GCC 4.4.x or later. This can be installed with:
sudo apt-get install build-essential
- CMake 2.6 or higher;
- Git;
- GTK+2.x or higher, including headers (libgtk2.0-dev);
- pkg-config;
- Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
- ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
- [optional] libdc1394 2.x;
- [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev.
ff-dev, libjasper-dev.
进入目录生成MakeFile文件
cd releaase
安装所有的lib文件都会被安装到/usr/local目录下
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
构建和安装
make
make install
加载动态连接库
sudo sh -c ‘echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf‘
sudo ldconfig
时间: 2024-12-28 14:04:44