Last active
December 28, 2021 22:12
-
-
Save donghee/15d7272885ac3505e0f20a63678e7ba3 to your computer and use it in GitHub Desktop.
Install OpenCV 3.4.4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "OpenCV installation by learnOpenCV.com" | |
# Delete installed opencv in system. | |
apt-get uninstall libopencv-dev -y | |
#Specify OpenCV version | |
cvVersion="3.4.4" | |
# Clean build directories | |
rm -rf opencv/build | |
rm -rf opencv_contrib/build | |
# Create directory for installation | |
mkdir installation | |
mkdir installation/OpenCV-"$cvVersion" | |
# Save current working directory | |
cwd=$(pwd) | |
sudo apt -y update | |
sudo apt -y upgrade | |
sudo apt -y remove x264 libx264-dev | |
## Install dependencies | |
sudo apt -y install build-essential checkinstall cmake pkg-config yasm | |
sudo apt -y install git gfortran | |
sudo apt -y install libjpeg8-dev libpng-dev | |
sudo apt -y install software-properties-common | |
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" | |
sudo apt -y update | |
sudo apt -y install libjasper1 | |
sudo apt -y install libtiff-dev | |
sudo apt -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev | |
sudo apt -y install libxine2-dev libv4l-dev | |
cd /usr/include/linux | |
sudo ln -s -f ../libv4l1-videodev.h videodev.h | |
cd "$cwd" | |
sudo apt -y install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev | |
sudo apt -y install libgtk2.0-dev libtbb-dev qt5-default | |
sudo apt -y install libatlas-base-dev | |
sudo apt -y install libfaac-dev libmp3lame-dev libtheora-dev | |
sudo apt -y install libvorbis-dev libxvidcore-dev | |
sudo apt -y install libopencore-amrnb-dev libopencore-amrwb-dev | |
sudo apt -y install libavresample-dev | |
sudo apt -y install x264 v4l-utils | |
# Optional dependencies | |
sudo apt -y install libprotobuf-dev protobuf-compiler | |
sudo apt -y install libgoogle-glog-dev libgflags-dev | |
sudo apt -y install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen | |
sudo apt -y install python3-dev python3-pip python3-venv | |
sudo -H pip3 install -U pip numpy | |
sudo apt -y install python3-testresources | |
cd $cwd | |
############ For Python 3 ############ | |
# create virtual environment | |
#python3 -m venv OpenCV-"$cvVersion"-py3 | |
#echo "# Virtual Environment Wrapper" >> ~/.bashrc | |
#echo "alias workoncv-$cvVersion=\"source $cwd/OpenCV-$cvVersion-py3/bin/activate\"" >> ~/.bashrc | |
#source "$cwd"/OpenCV-"$cvVersion"-py3/bin/activate | |
# | |
## now install python libraries within this virtual environment | |
#pip install wheel numpy scipy matplotlib scikit-image scikit-learn ipython dlib | |
# | |
## quit virtual environment | |
#deactivate | |
###################################### | |
git clone https://github.com/opencv/opencv.git | |
cd opencv | |
git checkout $cvVersion | |
cd .. | |
git clone https://github.com/opencv/opencv_contrib.git | |
cd opencv_contrib | |
git checkout $cvVersion | |
cd .. | |
cd opencv | |
mkdir build | |
cd build | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=$cwd/installation/OpenCV-"$cvVersion" \ | |
-D INSTALL_C_EXAMPLES=ON \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D WITH_TBB=ON \ | |
-D WITH_V4L=ON \ | |
-D OPENCV_PYTHON3_INSTALL_PATH=$cwd/OpenCV-$cvVersion-py3/lib/python3.6/site-packages \ | |
-D WITH_QT=ON \ | |
-D WITH_OPENGL=ON \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ | |
-D BUILD_EXAMPLES=ON .. | |
make -j$(nproc) | |
make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solve to build error from https://github.com/opencv/opencv_contrib/pull/1905/files/c4419e4e65a8d9e0b5a15e9a5242453f261bee46
72, 73번 줄의 COLOR_BGR2HSV을 cv::COLOR_BGR2HSV 로 바꾼다.