SLAM环境配置--一键安装Opencv2.4脚本

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_16481211/article/details/82823374

直接运行
sh opencv_install.sh
即可成功安装opencv2

#!/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 2.4.11.zip ]; then
echo "2.4.11.zip [found]"
else
echo "Error: 2.4.11.zip not found!!!download now......"
wget -c https://github.com/opencv/opencv/archive/2.4.11.zip
fi
echo "解压缩2.4.11.zip" 
unzip 2.4.11.zip 
cd opencv-2.4.11  
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

echo "测试一个简单的程序" 
cd ../samples/c
sudo ./build_all.sh
sudo ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg
cd ../../.. 

猜你喜欢

转载自blog.csdn.net/qq_16481211/article/details/82823374