Skip to content

Instantly share code, notes, and snippets.

@iwatake2222
Last active September 9, 2019 15:28
Show Gist options
  • Save iwatake2222/c7abd8098909facde9002af16b0b8e31 to your computer and use it in GitHub Desktop.
Save iwatake2222/c7abd8098909facde9002af16b0b8e31 to your computer and use it in GitHub Desktop.
Installing OpenCV4 on Cent OS 7 (AWS)
# Preparation
sudo yum upgrade
sudo yum -y groupinstall "Development Tools"
sudo yum install -y wget autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel gtk3 gtk3-devel
sudo yum install -y git gcc bzip2 bzip2-devel openssl openssl-devel readline readline-devel sqlite-devel
sudo yum install -y cmake libjpeg-devel libtiff-devel libpng-devel jasper-devel
sudo yum install -y mesa-libGL-devel libXt-devel libgphoto2-devel nasm libtheora-devel
sudo yum install -y autoconf automake gcc-c++ libtool yasm openal-devel blas blas-devel atlas atlas-devel lapack lapack-devel
sudo yum install -y tbb-devel
sudo yum install -y libv4l-devel libv4l
sudo yum install -y x264 v4l-utils
echo "/usr/local/lib64" | sudo tee /etc/ld.so.conf.d/opencv.conf
echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/usr-local-lib.conf
echo "/usr/local/lib64" | sudo tee /etc/ld.so.conf.d/usr-local-lib64.conf
export CFLAGS="-I/usr/local/include"
export LDFLAGS="-L/usr/local/lib"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
mkdir work && cd work
# Instal ffmpeg
## Install nasm
mkdir ~/work/ffmpeg
cd ~/work/ffmpeg
wget http://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.xz
tar -xf nasm-2.13.03.tar.xz
cd nasm-2.13.03
./configure --prefix=/usr && make
sudo make install
## Install yasm
cd ~/work/ffmpeg
git clone git://github.com/yasm/yasm.git
cd yasm
autoreconf -fiv
./configure
make
sudo make install
## Install x264
cd ~/work/ffmpeg
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static --enable-pic
make
sudo make install
sudo ldconfig
## Install xvid
cd ~/work/ffmpeg
wget https://downloads.xvid.com/downloads/xvidcore-1.3.5.tar.gz
tar xzvf xvidcore-1.3.5.tar.gz
chown -R root:root xvidcore
cd xvidcore/build/generic/
./configure
make
sudo make install
sudo ldconfig
## Install ffmpeg
cd ~/work/ffmpeg
git clone git://source.ffmpeg.org/ffmpeg
cd ffmpeg
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --enable-gpl --enable-libtheora --enable-libx264 --enable-libxvid --enable-nonfree --disable-static --enable-shared --enable-version3 --enable-zlib --enable-pthreads --enable-swresample --enable-avresample
make
sudo make install
sudo ldconfig
# Install OpenCV
## Install cmake3
mkdir ~/work/opencv
cd ~/work/opencv
wget https://cmake.org/files/v3.6/cmake-3.6.2.tar.gz
tar xvf cmake-3.6.2.tar.gz
cd cmake-3.6.2
./bootstrap
make
sudo make install
sudo ldconfig
## Install OpenCV
cd ~/work/opencv
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.1.1
mkdir build && cd build
/usr/local/bin/cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON \
-DWITH_LIBV4L=ON \
-DWITH_FFMPEG=ON \
..
make
sudo make install
sudo ldconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment