CentOS OpenCV怎样在LINUX系统中编译安装

2023-04-14 02:57:00 编译 系统 安装

CentOS OpenCV怎样在LINUX系统中编译安装

Linux系统中编译安装OpenCV,首先需要下载OpenCV的源代码,然后进行编译安装。

下载OpenCV源代码

从官网下载OpenCV的源代码,下载地址为:

编译安装

进入下载后的目录,执行如下命令进行编译安装:

sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev libavresample-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libv4l-dev libxvidcore-dev libx264-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxine2-dev yasm libopenexr-dev libgphoto2-dev libeigen3-dev libtbb-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev v4l-utils unzip

cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_TBB=ON -DBUILD_NEW_PYTHON_SUPPORT=ON -DWITH_V4L=ON -DINSTALL_C_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DENABLE_PRECOMPILED_HEADERS=OFF ..

make -j4

sudo make install

sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'

sudo ldconfig

安装完成后,可以通过如下命令来验证是否安装成功:

pkg-config --modversion opencv

如果显示的是当前安装的OpenCV的版本号,则表示安装成功。

相关文章