Thursday, January 14, 2010

Installation - Fedora 11, ffmpeg, OpenCV

Before starting with Computer Vision , I had to install OpenCV on my Laptop.
I decided to reformat my whole dual-boot OS , installing Vista after backing up my data was a straight deal. Then I installed Fedora - 11 on a different partition.
The slightly tricky thing in the otherwise simple Fedora installation is getting yum working. In my case I was able to connect to internet directly but on running
# yum list all
I continuously got error like
# [Errno 4] IOError : < urlopen error (111, 'Connection refused') >

after looking around a bit on forums and making changes in these files /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo  as given here 
as well as changing the /etc/hosts file to include the extra mirror sites.
In my case I added the mirror site of IIT-K as it being the nearby server.
But the same error persisted, some more searching and a quick-fix to the problem was found. The problem being of yum being not able to access the servers through default proxy server, hence to just correct the proxy problem, we do
# export http_proxy=xxx.xxx.xx.xxx:8080

So this finally worked and Yum started to install. later I added the proxy setting in .bashrc file.


Now for OpenCV,  FFmpeg is to be installed before that. Since I had a new installation of Fedora , so first I installed gcc and gcc-c++ compiler through Yum , to be able to install FFmpeg & OpenCV. The process of installation of later is as follows(Courtsey: Gaganpreet)

[ the ftp is on IIIT's Intranet , so is not accessible outside]
A small modification is mentioned at the end of these instructions


wget ftp://10.3.3.52/ffmpeg.tar.bz2ftp://10.3.3.52/opencv-1.0.0.tar.gz
tar xvjf ffmpeg.tar.bz2
cd ffmpeg
mkdir /home/{ffmpeg,opencv}
./configure --prefix=/home/ffmpeg/ --enable-shared
make
make install
export LD_LIBRARY_PATH=/home/ffmpeg/lib

wget 
tar xvzf opencv-1.0.0.tar.gz
cd opencv-1.0.0/ 
 
./configure --prefix=/home/opencv CXXFLAGS=-fno-strict-aliasing 
CFLAGS=-I/home/ffmpeg/include/ CPPFLAGS=-I/home/ffmpeg/include/ LDFLAGS=-L/home/ffmpeg/lib/ 
 
make
 
I got an error at this point 
# ../../cxcore/include/cxmisc.h:133:6: error: #elif with no expression
to fix that goto the file /cxcore/include/cxmisc.h, line no 133  and
change the routine to [note the extra +/- sign and else statement added] 
 
#include 
#elif defined HAVE_ALLOCA
     #include 
-#elif
+#else
     #error
 #endif 
 
You will get errors like: cvcap_ffmpeg.cpp: cvcap_ffmpeg.cpp: error:
integer constant is too large for 'long' type etc.
For that do:

vim otherlibs/highgui/cvcap_ffmpeg.cpp

Add these two lines to the beginning:

#define INT64_C
#define __STDC_CONSTANT_MACROS

and change this line:
url_fclose(&mywriter->oc->pb);
to
url_fclose(mywriter->oc->pb);

make install


To compile a code now:
export LD_LIBRARY_PATH=/home/ffmpeg/lib:/home/opencv/lib    #You can
put this in ~/.bashrc
gcc code.c -lcv -lhighgui -I/home/opencv/include/
-I/home/ffmpeg/include/ -L/home/ffmpeg/lib/ -L/home/opencv/lib/


This will install FFmpeg and OpenCV in your Linux , enjoy :-)

1 comment: