-
-
Save malefs/7da6bfc33e720bcceb2f1a4525864451 to your computer and use it in GitHub Desktop.
install opencv
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
# remember to launch this with sudo so that sudo does not time out halfway | |
OPENCV_VERSION='4.5.1' # Version to be installed | |
#note this install script is without cuda | |
if [ `whoami` != 'root' ]; | |
then | |
echo "This program needs to be run using 'sudo'" | |
exit | |
fi | |
sudo apt -y update | |
sudo apt-get -y remove x264 libx264-dev | |
## Install dependencies | |
sudo apt-get -y install build-essential checkinstall cmake pkg-config yasm | |
sudo apt-get -y install git gfortran | |
sudo apt-get -y install libgtk2.0-dev libtbb-dev qt5-default libvtk6-dev | |
# the good stuff | |
sudo apt install -y libatlas3-base libatlas-base-dev | |
sudo apt install -y liblapacke-dev | |
# lame codecs and stuff | |
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev | |
sudo apt-get -y install libxine2-dev libv4l-dev | |
sudo apt-get -y install zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libopenexr-dev libgdal-dev | |
sudo apt-get -y install libjpeg8-dev libjasper-dev libpng12-dev | |
sudo apt-get -y install libtiff5-dev | |
sudo apt-get -y install libtiff-dev | |
sudo apt-get -y install libmp3lame-dev libtheora-dev | |
sudo apt-get -y install libvorbis-dev libxvidcore-dev libx264-dev | |
sudo apt-get -y install libopencore-amrnb-dev libopencore-amrwb-dev | |
sudo apt-get -y install libavresample-dev | |
sudo apt-get -y install x264 v4l-utils | |
sudo apt-get -y install doxygen unzip wget | |
# Optional dependencies | |
sudo apt-get -y install libprotobuf-dev protobuf-compiler | |
sudo apt-get -y install libgoogle-glog-dev libgflags-dev | |
sudo apt-get -y install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen | |
# gstreamer | |
sudo apt install -y libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-pulseaudio libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev | |
# tesseract | |
sudo apt-get install -y tesseract-ocr libtesseract-dev libleptonica-dev | |
# structure from motion module requires ceres - https://github.com/opencv/opencv_contrib/blob/master/modules/sfm/README.md | |
sudo apt-get -y install python3-dev python3-pip | |
sudo -H pip3 install -U pip numpy | |
# install | |
cd /home/${SUDO_USER} | |
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip | |
unzip ${OPENCV_VERSION}.zip && rm ${OPENCV_VERSION}.zip | |
mv opencv-${OPENCV_VERSION} OpenCV_install | |
# opencv contrib mods | |
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip | |
unzip ${OPENCV_VERSION}.zip && rm ${OPENCV_VERSION}.zip | |
mv opencv_contrib-${OPENCV_VERSION} OpenCV_install | |
cd OpenCV_install | |
mkdir build | |
cd build | |
echo -e "cmake.....\n" | |
cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON \ | |
-DWITH_XINE=ON -DWITH_V4L=ON -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_GSTREAMER=ON\ | |
-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-${OPENCV_VERSION}/modules .. | |
echo -e "make.....\n" | |
make -j$(nproc) | |
echo -e "make install.....\n" | |
sudo make install | |
echo -e "ldconfig.....\n" | |
sudo ldconfig | |
# echo "sudo modprobe bcm2835-v4l2" >> ~/.profile for Raspi to work with VideoCapture(0)? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment