Ask Your Question
0

installing opencv in ubuntu

asked 2013-02-20 05:50:00 -0600

dinesh gravatar image

i am always getting this error when i am trying to run a C++ program in eclipse using opencv in ubuntu. cv.h :no such file or directory i have installed all the libraries properly

edit retag flag offensive close merge delete

Comments

it's looking for headers, set your INCLUDE path correctly

berak gravatar imageberak ( 2013-02-20 06:05:06 -0600 )edit

3 answers

Sort by » oldest newest most voted
0

answered 2013-02-20 07:28:38 -0600

Geppertm gravatar image

updated 2013-02-20 07:29:26 -0600

Use this shell script it will do anything for you. Run it as superuser. [Sorry couldn´t attache it]

[istall_opencv.sh]

arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.3"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get remove ffmpeg x264 libx264-dev
echo "Installing Dependenices"
sudo apt-get install build-essential checkinstall cmake pkg-config yasm
sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev
sudo apt-get install python-dev python-numpy
sudo apt-get install libtbb-dev
sudo apt-get install libqt4-dev libgtk2.0-dev
echo "Downloading x264"
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20121126-2245-stable.tar.bz2
tar -xvf x264-snapshot-20121126-2245-stable.tar.bz2
cd x264-snapshot-20121126-2245-stable/
echo "Installing x264"
if [ $flag -eq 1 ]; then
./configure --enable-static
else
./configure --enable-shared --enable-pic
fi
make
sudo make install
cd ..
echo "Downloading ffmpeg"
wget http://ffmpeg.org/releases/ffmpeg-0.11.2.tar.bz2
echo "Installing ffmpeg"
tar -xvf ffmpeg-0.11.2.tar.bz2
cd ffmpeg-0.11.2/
if [ $flag -eq 1 ]; then
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
else
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared
fi
make
sudo make install
cd ..
echo "Downloading v4l"
wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.9.3.tar.bz2
echo "Installing v4l"
tar -xvf v4l-utils-0.9.3.tar.bz2
cd v4l-utils-0.9.3/
make
sudo make install
cd ..
echo "Downloading OpenCV 2.4.3"
wget -O OpenCV-2.4.3.tar.bz2 http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2
echo "Installing OpenCV 2.4.3"
tar -xvf OpenCV-2.4.3.tar.bz2
cd OpenCV-2.4.3
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE ..
make
sudo make install
sudo echo “/usr/local/lib” >> /etc/ld.so.conf
sudo ldconfig
echo "OpenCV 2.4.3 ready to be used"
edit flag offensive delete link more
0

answered 2013-02-20 11:28:56 -0600

kabamaru gravatar image

updated 2013-02-20 11:29:43 -0600

The linker needs to know where your header files are and it tries to find them by looking to some places that he already knows. You need to tell him to look where you headers are. For this you have to set two environment variables C_INCLUDE_PATH (for C header files) or CPLUS_INCLUDE_PATH (for C++ header files). You can do this with the EXPORT command. A nice practice is to put this command in your .bashrc file so you don't have to do the same every time. The directory for the opencv files depend on where you've installed it but generally are /usr/local/include and /user/local/include/opencv/. Probably you will also need to set the LD_LIBRARY_PATH.

Another option is to use pkg-config with the compiler.

gcc example.c `pkg-config --libs --cflags opencv`
edit flag offensive delete link more
0

answered 2013-02-21 00:31:43 -0600

updated 2013-02-21 00:33:15 -0600

If you use OpenCV4Android then you need to replace #incldue <cv.h> on #include <opencv/cv.h> and do not forget to include OpenCV.mk to your Android.mk.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-20 05:50:00 -0600

Seen: 1,283 times

Last updated: Feb 21 '13