Ubuntu安裝編譯OpenCV一鍵腳本(帶FFMpeg)過程筆記。
1.切換到用戶目錄
cd ~
2.新建一個文件,命名為opencv.sh 腳本如下:
version="$(wget -q -O - http://sourceforge.net/projects/opencvlibrary/files/opencv-unix | egrep -m1 -o '\"[0-9](\.[0-9])+' | cut -c2-)"
echo "Installing OpenCV" $version
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get install unzip
sudo apt-get install cmake
sudo apt-get -qq remove ffmpeg x264 libx264-dev
echo "Installing Dependenices"
sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg
echo "Downloading OpenCV" $version
wget -O OpenCV-$version.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/opencv-"$version".zip/download
echo "Installing OpenCV" $version
unzip OpenCV-$version.zip
cd opencv-$version
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j2
sudo checkinstall
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV" $version "ready to be used"
3.修改為可執行
chmod +x opencv.sh
4.運行
./opencv.sh
注意:如果編譯完之後,在lib和bin中沒有java相關的jar和.so文件,你需要安裝jdk,並導出JAVA_HOME變量:例如,64位ubuntu,
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
(path may differ in your system), cmake generated both:
build/bin/opencv-249.jar
build/lib/libopencv_java249.so
------------------------------------------分割線------------------------------------------
Linux下編譯FFmpeg之下載源文件並編譯 http://www.linuxidc.com/Linux/2012-02/54565.htm
Linux 編譯升級 FFmpeg 步驟 http://www.linuxidc.com/Linux/2013-08/88190.htm
CentOS 5.6 上安裝 FFMPEG http://www.linuxidc.com/Linux/2011-09/42793.htm
在Ubuntu下安裝FFmpeg http://www.linuxidc.com/Linux/2012-12/75408.htm
Ubuntu Linux下安裝OpenCV2.4.1所需包 http://www.linuxidc.com/Linux/2012-08/68184.htm
Ubuntu 12.04 安裝 OpenCV2.4.2 http://www.linuxidc.com/Linux/2012-09/70158.htm
CentOS下OpenCV無法讀取視頻文件 http://www.linuxidc.com/Linux/2011-07/39295.htm
Ubuntu 12.04下安裝OpenCV 2.4.5總結 http://www.linuxidc.com/Linux/2013-06/86704.htm
Ubuntu 10.04中安裝OpenCv2.1九步曲 http://www.linuxidc.com/Linux/2010-09/28678.htm
------------------------------------------分割線------------------------------------------