OpenCV-2.3.1 and ffmpeg-2.1.2 compilation and installation on centos

Source: Internet
Author: User
Tags gtk

Tested environment:

  1. Centos 6.3 32bit
  2. Centos 6.5 64bit

We have installed opencv in centos 6.3 32bit. For more information, see install opencv2.3.1 in centos 6.3. Now we have changed the 64-bit system.

Check and install related programs to ensure that GTK is successfully installed. Otherwise, the image cannot be displayed.
Yum install gcc-C ++ # G ++ compile Yum install GTK-devel # It's actually GTK, not necessarily GTK-devel, you can use * GTK-devel * to match the yum install gimp-develyum install gimp-devel-toolsyum install gimp-help-browseryum install zlib-develyum install LibTIFF-devel # TIFF Format Image Support Yum install libjpeg-devel # JPEG images support Yum install libpng-devel # PNG images support Yum install gstreamer-devel # Processing MP3, Ogg, mpeg1, MPEG2, Avi and other formats of multimedia data Yum install libavc1394-devel #1394 audio interface control command set Yum install libraw1394-develyum install libdc1394-develyum install Jasper-develyum install Jasper-utilsyum install cmake # Yum install swigyum install Python # Python environment support yum install libtoolyum install NASM # Assembly Tool
Install ffmpeg2.1.2

FFmpeg does not have ready-made RPM packages for centos. Therefore, you must use the source code for compilation and installation,

./configure --enable-shared –disable-yasmmakemake install

In this case, FFmpeg is installed under/usr/local by default.

Install OpenCV-2.3.1
  1. Use VI to open the cmakelists.txt file, find the following line, and comment it (#)

    set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS${CMAKE_CONFIGURATION_TYPES} )# set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS${CMAKE_CONFIGURATION_TYPES} )
  2. Use VI to open the cmakelists.txt file, search for the keyword FFMPEG, and find the corresponding location,

    if(EXISTS /usr/include/ffmpeg/libavformat/avformat.hOR HAVE_FFMPEG_SWSCALE)

    Make sure that the directory above is/usr/include. If the path is modified when FFmpeg is installed, modify the directory accordingly.

  3. Go to the main directory of the opencv source code, and execute

    mkdir releasecd releasecmake ../makemake install

    Wait until the installation is complete. The default installation path is/usr/local /.

Test
#include <cv.h>#include 

Write makefile,

SRC=DisplayImage.cppLIB=-L/usr/local/lib/INC=-I/usr/local/include/opencv/Test:$(SRC)   g++ -o Test $(LIB)$(INC) -lopencv_core -lopencv_highgui -lopencv_ml $^

No error occurred while executing make. Continue running./test {imagepathname}. The error "cannot link to dynamic library" is displayed, which is roughly as follows:

error while loading shared libraries: libopencv_core.so.2.3: cannot open shared object file: No such file or directory

Solution:

CD/etc/lD. So. conf. d/# The Directory stores the path information of various dynamic link libraries Vim usr-lib.conf

Add the following information (path of the Lib of opencv)

/usr/local/lib

Save the file and run the ldconfig command.

Run the task again. No problem. Close the job.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.