ubuntu 安装opencv3.4.9 脚本

#!/bin/bash

sysInstall='apt-get'
echo "安装unzip" 
sudo apt-get --yes --force-yes install unzip 
echo "安装cmake" 
sudo  apt-get --yes --force-yes install cmake 
echo "安装build-essential" 
sudo  apt-get --yes --force-yes install build-essential
echo "安装gcc-c++" 
sudo  apt-get --yes --force-yes install gcc-c++
echo "安装gcc" 
sudo  apt-get --yes --force-yes  install gcc
echo "安装gtk+-devel" 
sudo apt-get --yes --force-yes install gtk+-devel
echo "安装gimp-devel" 
sudo apt-get --yes --force-yes install gimp-devel
echo "安装gimp-devel-tools" 
sudo apt-get --yes --force-yes install gimp-devel-tools
sudo  apt-get --yes --force-yes install zlib-devel
sudo  apt-get --yes --force-yes install gimp-help-browser
sudo  apt-get --yes --force-yes  install libtiff-devel
sudo  apt-get --yes --force-yes install libjpeg-devel
sudo  apt-get --yes --force-yes install libpng-devel
sudo  apt-get --yes --force-yes  install gstreamer-devel
sudo  apt-get --yes --force-yes  install libavc1394-devel
sudo  apt-get --yes --force-yes  install jasper-devel
sudo  apt-get --yes --force-yes  install swig
sudo  apt-get --yes --force-yes install libtool
sudo  apt-get --yes --force-yes  install nasm
sudo  apt-get --yes --force-yes  install libgtk2.0-dev
sudo  apt-get --yes --force-yes  install libavcodec-dev
sudo  apt-get --yes --force-yes  install libavformat-dev
sudo  apt-get --yes --force-yes  install libjpeg62-dev
sudo  apt-get --yes --force-yes  install libtiff4-dev
sudo  apt-get --yes --force-yes  install libswscale-dev
sudo  apt-get --yes --force-yes  install libjasper-dev
#sudo --force-yes  $sysInstall install git 
sudo  apt-get --yes --force-yes  install pkg-config 
sudo  apt-get --yes --force-yes install ibavcodec-dev 
sudo  apt-get --yes --force-yes  install libavformat-dev 
sudo  apt-get --yes --force-yes install libswscale-dev 
sudo  apt-get --yes --force-yes install libtbb2 
sudo  apt-get --yes --force-yes  install libtbb-dev
#用摄像头才需要安装
sudo  apt-get --yes --force-yes  install libv4l-dev
sudo  apt-get --yes --force-yes  install v4l2ucp
sudo  apt-get --yes --force-yes  install v4l-utils
#!/bin/bash
cd ~

sudo apt-get --yes --force-yes install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev  

echo "检查当前路径下是否有opencv压缩包,没有的话需要下载" 
if [ -s 3.4.2.zip ]; then
echo "3.4.2.zip [found]"
else
echo "Error: 3.4.2.zip not found!!!download now......"
wget -c https://github.com/opencv/opencv/archive/3.4.2.zip
fi
echo "解压缩3.4.2.zip" 
unzip 3.4.2.zip
cd opencv-3.4.2  
mkdir build
cd build
echo "cmake当前工程"
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
echo "make当前工程" 
#4线程这个看自己电脑配置
make j4
echo "sudo make install"  
sudo make install

echo "对opencv进行配置" 
echo '/usr/local/lib'>>/etc/ld.so.conf.d/opencv.conf
sudo ldconfig

echo "对环境变量进行配置"
echo 'PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig'>>/etc/bash.bashrc
echo 'export PKG_CONFIG_PATH'>>/etc/bash.bashrc
source /etc/bash.bashrc

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据