You might want to use this distribution because it has corrected bugs from previous ones, supports your hardware better, etc.
Thanks to Leeds University for their guide on using OpenCV
- Install subversion and all the basic compilation packages such as g++ and gcc etc.
- Download ffmpeg with: svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg and then
- ./configure --enable-shared --prefix=/opt/ffmpeg (the prefix bit is optional but I prefer to store special development packages like this one on their own directory so it is simpler to locate, configure, remove)
- make
- sudo make install
- The above will install ffmpeg in /opt/ffmpeg. Now sudo vi /etc/ld.so.conf.d/ffmpeg.conf and add the line /opt/ffmpeg/lib to it. Then do sudo ldconfig
- Important: Modify file /opt/ffmpeg/include/ffmpeg/avformat.h by adding the following lines to it (otherwise you will get a compilation error when compiling OpenCV (see here for more details):
#define INT64_C
#define __STDC_CONSTANT_MACROS
#include - Install the other necessary packages: sudo apt-get install libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev
- Now download and untar version 1.0.0 of OpenCV from http://sourceforge.net/project/showfiles.php?group_id=22870&package_id=16948
- Now do
- ./configure --prefix=/opt/opencv --enable-apps --enable-shared --with-ffmpeg --with-gnu-ld --with-x --without-quicktime CXXFLAGS=-fno-strict-aliasing CFLAGS=-I/opt/ffmpeg/include CPPFLAGS=-I/opt/ffmpeg/include LDFLAGS=-L/opt/ffmpeg/lib
- Check that the above produces no error and that in particular it reports ffmpeg as yes. If this is not the case there is no point in continuing!
- make (if you have tried making other configurations you could also do a make clean before make)
- sudo make install
- sudo vi /etc/ld.so.conf.d/opencv.conf and add the line /opt/opencv/lib. Then sudo ldconfig
- Edit (as root) /etc/bash.bashrc and add the lines:
- PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/opencv/lib/pkgconfig export PKG_CONFIG_PATH (this setting will be activated if you launch a new console/terminal or if you re-login)
- So far so good? Now try running some sample programs. Donwload and untar this. Then:
- ./build-all.sh edge fruits.jpg (it shows that you can open and display a jpg file) cvplayer-v2 SEQ-003-C5_X4.mpg (it shows you can open and display an mpg video file, with ffmpeg)
0 comments:
แสดงความคิดเห็น