Configure CodeBlocks to compile OpenCV codes

CodeBlocks is one of the IDE(s) that i prefer using due to its simplicity and fast interface. Plus the benefit of having MATLAB like command suggestions. The steps are outlined below:

  • Search the path where opencv is installed in your system.. you can do a :

locate cv.h

  • in my system, this returns : /usr/local/include/opencv/cv.h. Copy the path till the opencv directory, i.e : /usr/local/include/opencv/
  • Now, open CodeBlocks > New Project > (any project type of your choice.. for starters, Console Project is a good beginning) . Now goto,

Project > Build Options > Linker Settings tab

  • Under “Other Linker options” add the following, one below the other:

-lopencv_core
-lopencv_highgui
-lopencv_contrib
-lopencv_ml
-lopencv_legacy
-lopencv_imgproc
-lopencv_video
-lopencv_features2d
-lopencv_calib3d
-lopencv_objdetect
-lopencv_flann

  • Now, in the same window, under “Search directories tab”, add the opencv directory you copied above, i.e. for my system, it’ll be :

/usr/local/include/opencv/

  • Now, Project > Properties > C/C++ Parser options, again add the same directory path.

And you are done !! Enjoy compiling OpenCV codes in CodeBlocks 🙂

Advertisements

Install OpenCV 2.3 with video support in Fedora 15

Much has changed since OpenCV 2.0.. android support, CUDA support, etc are up and running. So is the change in the method of installing OpenCV. So, i though to quickly jot down the steps to follow for a painless install.

I must add, due to changes in gcc, removal of libv4l support from linux kernel, etc.. OpenCV 2.1 and 2.2 give loads of issues during install. I just couldnt manage installing v2.1, though v2.2 needed few hacks as mentioned in the link : https://code.ros.org/trac/opencv/ticket/324 . So, for people wanting to install v2.2, can follow exactly same steps mentioned below after making the above hack. Note that, even UVC-webcams dont work with v2.2. So, if you’re like me, needing lots of webcam feed for vision-based tasks, its best to avoid v2.2. Moral of the story : Go for v2.3..

1. Install the following :

sudo yum install eigen2-devel, CTL, CTL-devel, OpenEXR_CTL-libs, tbb, yasm, yasm-devel, tbb-devel, OpenEXR CTL-devel, OpenEXR CTL, perl-URI, perl-Compress-Raw-Zlib, perl-Compress-Raw-Bzip2, perl-l0-Compress, libucil-clevel, perl-HTML-Tagset, perl-HTML-Parser, perl-Iibwww-perl, perl-XML-Parser, gstreamer-plugins-base-devel, libsigc++20-devel, glibmm24-devel, libxml++-devel, gstreamermm, xine-lib, libunicapgtk-devel, xine-lib-devel, gstreamermm-devel, python-devel, sip-macros, sip, vamp-plugin-sdk, audacity, sip-devel

sudo yum install libXext-clevel, glib2-devel, libXrender-devel, libXfixes-devel, Iibunicap, freetype-devel, boost-system, fontconfig-devel, libpng-devel, boost-filesystem, boost-serialization, boost-thread, boost-date-time, boost-regex, libXt-devel, libXdamage-devel, libXcomposite-devel, libXcursor-devel, libXrandr-devel, atk-devel, libXinerama-devel, libXxf86vm-devel, libXi-devel, libxml2-devel, blas-devel, libjpeg-turbo-devel, pixman-clevel, cairo-devel, pango-devel, libdrm-devel, mesa-libGL-devel, boost-graph, boost-wave, libucil, boost-signals, boost-python, boost-iostreams, boost-program-options, boost-random, boost-test, boost, mesa-libGLU-devel, ilmbase-devel, libunicapgtk, gdk-pixbuf2-devel, libibverbs, libmlx4, librdmacm, check, check-devel, boost-jam, rarian, rarian-compat, cmake, plpa-libs, numactl, environment-modules, boost-devel, boost-build, OpenEXR-devel, jasper-devel, lapack-devel, libunicap-devel, libtifl-devel, atlas-devel, openmpi, boost-openmpi, ucview, gstreamer-devel, gtk2-devel, jasper, 0penEXR

sudo yum install xorg-x11-proto-devel, libXau-devel, Iibxcb-devel, libX11-devel, libram1394-devel, automake, libogg-devel, libtheora-devel, libvorbis-devel, libdc1394-devel, x264-devel, faac-devel, xvidcore-devel, dirac-devel, gsm-devel, zlib-devel, faad2-devel, speex-devel, lame-devel, orc-compiler, orc-devel, libvdpau, cppunit, libvdpau-devel, schroedinger-devel, dirac, x264, lame, faad2, amrwb-devel, opencore-amr-devel, amrnb, amrnb-devel

(i have tried copying the package names via OCR software and some editing as much as could be possible from the screenshot below)

OR

Install from Add/Remove Programs (PackageKit)

List of Packages to install for OpenCV dependency resolution

2. Now, download and Install FFMPEG

  • Eventhough FFMPEG is at v0.8.. its best to go for v0.7.. thats coz of several dependency issues. Many things like VLC, etc are based on ffmpeg v0.69 code, and v0.8 MAY give lots of issues..
  • Download ffmpeg 0.7 from : http://ffmpeg.org/releases/ffmpeg-0.7.1.tar.bz2
  • extract the above file (say files get extracted to /home/user/ffmpeg)
  • Open terminal and cd to above location.. i.e. : cd /home/user/ffmpeg
  • Now type the following :

./configure –enable-gpl –enable-version3 –enable-nonfree –enable-postproc –enable-libfaac –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvorbis –enable-libxvid –enable-x11grab –enable-swscale –enable-shared

make

sudo make install

  • And you are done.. FFMPEG is ready to be integrated with OpenCV.

3. Download OpenCV 2.3 . Extract to a folder (say /home/user/Opencv-2.3)

  • There still are a few packages of ffmpeg like libavcodec-dev, libavutil-dev, etc which need to be present in /usr/local/ffmpeg/ . But, the above  install of ffmpeg doesnt create this. So, open Add/Remove Programs and install following or install using yum:

sudo yum -y install ffmpeg ffmpeg-devel ffmpeg-libs

  • Now, the requisite libraries are all present in the location OpenCV can find them. Open terminal and cd to the OpenCV folder.. i.e.

cd /home/user/OpenCV-2.3

  • Create a folder called Release

mkdir Release

  • cd to the Release folder and type the following to install OpenCV

cd Release/

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_CUDA=OFF -D WITH_V4L=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_FFMPEG_BUILD=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D WITH_IPP=OFF -D BUILD_EXAMPLES=ON ..

make -j 2

sudo make install

  • Few more steps need to be done to ensure flawless build.

sudo gedit /etc/ld.so.conf.d/opencv.conf

(Type the following and save-close the file) : /usr/local/lib

sudo ldconfig

sudo gedit /etc/bashrc

(Type the following and save-close the file) :

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

And you are done !!! 🙂 OpenCV 2.3 with ffmpeg support is ready to be used on Fedora 15 with full webcam support.. ENJOY !!

NOTE : due to requests for Ubuntu specific steps, i’ll put the changed steps in this post itself in a few days

EAGLE Layout editor

EAGLE ( Easily Applicable Graphics Layout Editor), a product from CADSOFT, has been the standard for Schematic layout and PCB fabrication for quite sometime now. Amongst its various features, the autorouting feature is amongst the best in class. Though the GUI takes time getting used to, the ease of use is surely addictive.

A note about similar tool in Linux – KiCAD ( extremely painful for your finger, needs TONS n TONS of clicks for a small thing like placing Resistor !! ), gEDA ( is basically a PSPICE equivalent, while the PCB-NEW software bundled along with gEDA has no autoroute feature )

Many people often inquire often – is autorouting  feature available in the FREEWARE version of EAGLE.. The answer is a definitive YES !! You just need to click the right buttons (as i said, it takes time getting used to the GUI ).. I will list out the basic steps:

  • Get your schematic ready in LAYOUT EDITOR
  • click on “Schematic to Board” in the LAYOUT EDITOR
  • Now, EAGLE takes you to the BOARD EDITOR.
  • Click on GROUP button on the left panel
  • Select the complete circuit using the group tool
  • Select the MOVE button on the left panel
  • Right Click on the selected circuit, Choose “Move : Group” option
  • Drag the mouse to drag the circuit onto the pcb
  • Select GROUP button on the left panel again
  • Select the complete circuit
  • NOW, Click on Autoroute and OK in the window that opens. Tralaah… the circuit is ready for sending for PCB fabrication..
Eagle Layout Editor Icon

The Download link For EAGLE is given below :

  1. Windows Version
  2. Linux Version
  3. Mac Version