Tested environment:
- Centos 6.3 32bit
- 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
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} )
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.
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.