Your Ad Here
Your Ad Here

Sunday, January 4, 2009

How to install openCV in ubuntu 8.04/8.10

Thanks to this site and Leeds University:
1.# sudo apt-get install build-essential to get compiler, ld, make, ....
2.# Install the other necessary packages:
sudo apt-get install libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev
3.# Now download and untar version 1.0.0 of OpenCV from
SourceForge
4.# Now do
* ./configure --prefix=/opt/opencv --enable-apps --enable-shared --with-ffmpeg --with-gnu-ld --with-x --without-quicktime CXXFLAGS=-fno-strict-aliasing
* 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

5.# sudo vi /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)
Now to check your installation download this untar it and then do:
1)./build-all.sh
2)./edge fruits.jpg (it shows that you can open and display a jpg file)
3)./cvplayer-v2 SEQ-003-C5_X4.mpg (it shows you can open and display an mpg video file, with ffmpeg)

7 comments:

ansimal said...

I was so glad to see this post, as I was going in circles trying to install opencv 1.0.0 on ubuntu 8.10(intrepid) that I have installed on my sony Vaio laptop. Pls help further, as I got stuck in 'Make', with the following error :


g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I. -I../../cxcore/include -I../../cv/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DNDEBUG -Wall -fno-rtti -pipe -O3 -g -march=i686 -ffast-math -fomit-frame-pointer -fno-strict-aliasing -MT cvcap_ffmpeg.lo -MD -MP -MF .deps/cvcap_ffmpeg.Tpo -c cvcap_ffmpeg.cpp -fPIC -DPIC -o .libs/cvcap_ffmpeg.o
cvcap_ffmpeg.cpp: In function 'int icvOpenAVI_FFMPEG(CvCaptureAVI_FFMPEG*, const char*)':
cvcap_ffmpeg.cpp:121: warning: comparison between signed and unsigned integer expressions
cvcap_ffmpeg.cpp: In function 'const IplImage* icvRetrieveFrameAVI_FFMPEG(CvCaptureAVI_FFMPEG*)':
cvcap_ffmpeg.cpp:218: warning: 'int img_convert(AVPicture*, int, const AVPicture*, int, int, int)' is deprecated (declared at /usr/include/ffmpeg/avcodec.h:2463)
cvcap_ffmpeg.cpp:222: warning: 'int img_convert(AVPicture*, int, const AVPicture*, int, int, int)' is deprecated (declared at /usr/include/ffmpeg/avcodec.h:2463)
cvcap_ffmpeg.cpp: In function 'int cvWriteFrame(CvVideoWriter*, const IplImage*)':
cvcap_ffmpeg.cpp:716: warning: 'int img_convert(AVPicture*, int, const AVPicture*, int, int, int)' is deprecated (declared at /usr/include/ffmpeg/avcodec.h:2463)
cvcap_ffmpeg.cpp:718: warning: 'int img_convert(AVPicture*, int, const AVPicture*, int, int, int)' is deprecated (declared at /usr/include/ffmpeg/avcodec.h:2463)
cvcap_ffmpeg.cpp: In function 'void cvReleaseVideoWriter(CvVideoWriter**)':
cvcap_ffmpeg.cpp:777: warning: comparison between signed and unsigned integer expressions
cvcap_ffmpeg.cpp:784: error: cannot convert 'ByteIOContext**' to 'ByteIOContext*' for argument '1' to 'int url_fclose(ByteIOContext*)'
make[3]: *** [cvcap_ffmpeg.lo] Error 1
make[3]: Leaving directory `/home/anupama/Software/opencv-1.0.0/otherlibs/highgui'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/anupama/Software/opencv-1.0.0/otherlibs'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/anupama/Software/opencv-1.0.0'
make: *** [all] Error 2


pls tell me if u need any other info abt the system

shankhs said...

Hi ansimal did you do as said.There is one more catch and it is you have to "make" (quotes 4 clarity) openCv as "su"(quotes 4 clarity) try again and post the output.
mail me if u have any more problem.

Anonymous said...

As ansimal I was really glad to see this post...
I'm trying to install the latest stable version of upencv (got by cvs) under an Ubuntu 8.10.
I've installed the OpenCV libraries from Debian Stable. As far as I can
see, it all went fine.
But when I'm trying to compile OpenCV programs I get the following
error:
" make
g++ `pkg−config opencv −−cflags` −Wall −c eksempel1.cc
Package opencv was not found in the pkg−config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
..."
I don't have `opencv.pc' on the system.


So I found your How To... I've tried to use it to 'reinstall' and I had the same problem as ansimal... I've tried to do the 'make' as 'su' and it didn't work...

Do you have any idea?
thank you very much!

shankhs said...

Becinha do you pkg-config installed?
If not then install it.

dharam said...

hiii..i was installing it but after * ./configure --prefix=/opt/opencv --enable-apps --enable-shared --with-ffmpeg --with-gnu-ld --with-x --without-quicktime CXXFLAGS=-fno-strict-aliasing

this command...nothng happening n its showing that bad commnd...tell me whats d solution for dis ?

shankhs said...

no *./configure
only ./configure

Unknown said...

Just FYI, this won't work on ubuntu Lucid with the latest ffmpeg