Sunday, June 26, 2011

Installing OpenCV 2.2.0 in Ubuntu 10.10


Here are the detailed steps required to install OpenCV-2.2.0 in Ubuntu 10.10.
1. Download OpenCV from http://sourceforge.net/projects/opencvlibrary/file/opencvunix/2.2/
2. Extract the files in a folder preferably in home folder eg: 'home/jai/OpenCV'.
3. Install the pre-requisites by typing the following in the terminal
$ sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
$ sudo apt-get install cmake-gui
$ sudo apt-get install cmake
4. create a folder 'build' in 'home/OpenCV'
5. start cmake by typing the following in terminal
$ cmake-gui
give “where the source code is” path as 'home/jai/OpenCV'
give “where to build the binaries” path as 'home/jai/OpenCV/build'
configure it till no more red tab appears. Click on generate. This generates the binaries required to install OpenCV in 'home/jai/OpenCV/build'.
6. Go to the build directory in and install OpenCV by typing as follows in the terminal
$ cd ~/jai/OpenCV/build
$ make
$ sudo make install
7. Now to configure the library. First, open the opencv.conf file with the following code:
$ sudo gedit /etc/ld.so.conf.d/opncv.conf
Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:
/usr/local/lib
8. Run the following code to configure the library:
$ sudo ldconfig
9. Now, Open another file:
$ sudo gedit /etc/bash.bashrc
Add the following two lines and save it.
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
10. Restart the computer. OpenCV is installed now.


Compiling any OpenCV programs eg- test.cpp:
go to the working directory by using cd in terminal and type the following
$ gcc `pkg-config --libs --cflags opencv` -o test test.cpp
This creates a binary file with name test. To execute it, just type
$ ./test <arguments_if_any>

References:
1. http://opencv.willowgarage.com/wiki/InstallGuide
2. http://www.samontab.com/web/2010/04/installing-opencv-2-1-in-ubuntu/

Wednesday, June 22, 2011

Adding code blocks to a blog (detailed steps)

First you need to backup your blogger template. In your blogger dashboard, click on 'Design' > 'Edit HTML' and then click on 'download full template' and save your template.

  1. Go to Blogger Dashboard > Design > Edit HTML.
  2. Press CTRL+F to find the code </head>
  3. Copy the below code
  4. <!--SYNTAX HIGHLIGHTER BEGINS--> <link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/> <link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'></script> <script language='javascript'> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf'; SyntaxHighlighter.all(); </script> <!--SYNTAX HIGHLIGHTER ENDS-->
  5. Paste it on top of </head> this code.
  6. Preview your template and if everything works fine, then save it.
Make the script work

You have just added the script to your blog. If you want to highlight code in your post, then you need to use the following method in order to make your Syntax Highlighter work properly..

In <pre> method... when writing a new post, you need to use <pre> tag in the post. The code of your post needs to go in between <pre class="brush:html"> and </pre> tags, in order to highlight your code properly.

    Tuesday, June 21, 2011