在ubuntu12.04上配置opencv2.4.8+ffmpeg环境

目的

在ubuntu12.04 amd64上配置opencv2.4.8+ffmpeg环境。


实施步骤

1,安装编译工具包

$ sudo apt-get install build-essential cmake


2,配置ffmpeg库

参考内容:http://trac.ffmpeg.org/wiki

2.1 安装依赖

/* $ sudo apt-get install make automake g++ bzip2 python unzip patch subversion ruby build-essential git-core checkinstall yasm texi2html libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvdpau-dev libvorbis-dev libvpx-dev

*/

 2.1,安装yasm

可以选择下载yasm-1.2.0.tar.gz或者用git下载

# git clone git://github.com/yasm/yasm.git
# cd yasm
# ./autogen.sh
# ./configure
# make
# make install

2.2,安装x264编码库

# cd /my/path/where/i/keep/compiled/stuff
# git clone git://git.videolan.org/x264.git
# cd x264
# ./configure --enable-static --enable-shared
# make
# make install
# ldconfig

引用:http://trac.ffmpeg.org/wiki/How%20to%20quickly%20compile%20libx264、

2.3,配置ffmpeg库

下载了ffmpeg-2.1.5.tar.bz2或者用git下载

# cd /my/path/where/i/keep/compiled/stuff
# git clone git://source.ffmpeg.org/ffmpeg.git
# cd ffmpeg
# ./configure --enable-static --enable-shared --enable-gpl --enable-libx264
# make
# make install
# ldconfig

]引用:http://trac.ffmpeg.org/wiki/How%20to%20quickly%20compile%20FFmpeg%20with%20libx264%20%28x264%2C%20H.264%29


3,安装opencv2.4.8


官网下载open2.4.8

$ unzip open-2.4.8.zip

$ cd open-2.4.8

$ mkdir build

$ cd build

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

编译后的配置选项如下,可以看到支持ffmpeg

Linker flags (Release):      
--     Linker flags (Debug):        
--     Precompiled headers:         YES
--
--   OpenCV modules:
--     To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib stitching superres ts videostab
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera dynamicuda java python
--
--   GUI:
--     QT:                          NO
--     GTK+ 2.x:                    NO
--     GThread :                    YES (ver 2.32.4)
--     GtkGlExt:                    NO
--     OpenGL support:              NO
--
--   Media I/O:
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.3.4)
--     JPEG:                        libjpeg (ver 62)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.46)
--     TIFF:                        build (ver 42 - 4.0.2)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      YES
--       codec:                     YES (ver 55.39.101)
--       format:                    YES (ver 55.19.104)
--       util:                      YES (ver 52.48.101)
--       swscale:                   YES (ver 2.5.101)

--       gentoo-style:              YES
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    NO/YES
--     XIMEA:                       NO
--     Xine:                        NO
--
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use Eigen:                   NO
--     Use TBB:                     NO
--     Use OpenMP:                  NO
--     Use GCD                      NO
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
--
--   OpenCL:
--     Version:                     dynamic
--     Include path:                /home/havstack/tools/opencv-2.4.8/3rdparty/include/opencl/1.2
--     Use AMD FFT:                 NO
--     Use AMD BLAS:                NO
--
--   Python:
--     Interpreter:                 /usr/bin/python (ver 2.7.3)
--
--   Java:
--     ant:                         NO
--     JNI:                         /usr/lib/jvm/jdk1.7.0_60/include /usr/lib/jvm/jdk1.7.0_60/include/linux /usr/lib/jvm/jdk1.7.0_60/include
--     Java tests:                  NO
--
--   Documentation:
--     Build Documentation:         NO
--     Sphinx:                      NO
--     PdfLaTeX compiler:           NO
--
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              NO
--
--   Install path:                  /usr/local
--
--   cvconfig.h is in:              /home/havstack/tools/opencv-2.4.8/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/havstack/tools/opencv-2.4.8/build

$ make -j8

$ sudo make install

# sudo gedit /etc/ld.so.conf.d/opencv.conf   # 添加下面这句命令到文件中,文件是空的,不影响。
/usr/local/lib
# ldconfig

# sudo vim /etc/profile  # 添加下面两行到文件的末尾。
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH


路径配置完毕进行测试:
# cd opencv-2.4.5/samples/c
# chmod +x build_all.sh
# ./build_all.sh
# ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg



参考

http://neicole.blog.51cto.com/5621716/1369620

http://www.2cto.com/os/201309/245506.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值