Try to find the truth

Friday, May 14, 2010

Getstarted with openCV

I told about the topic almost 1 year ago,but unfortunately can not manage time for that , now after studying computer graphics and computer vision for few months I thought that could be a right time to start.

The main reason I am writing here is that I see lack of systematic short sequential tutorials on that topic in the net. There are many tutorials out there but they are not arranged properly, and some are extraordinarily include a great deal of back ground like deep mathematics and also some knowledge in machine learning also. Before we start let me clear one thing I am no way a guru or something like that, I am a simple student , what I am going to write here are all collected , read and studied by me from net and books , it's includes my understanding and unfortunately there for my misconceptions if I have any :-) .So if this blog is ever seen by any expert or any student who find something wrong don't hesitate to contact me at hiraksarkar.csATgmailDOTcom.

Let me start

1.Introduction

Opencv
is a free and open source library mainly written in C. A few google clicks will tell you every detail of it's history (interesting). So I am not going in to that .
To get start with opencv what you need is a C++ ide , any ide should work fine like code blocks or something will be work well. Secondly you need a camera, that does not mean that you have to have camera right now but try to collect one, you can do experiments with video files and stored images , but that will bore you but with a camera of your own you will able to do extraordinary projects that wil amaze you , any cheap webcam ( mine was 300/- only :-) ) should work fine. I do all my programs with VC++ (version 6.0) , better to chose a IDE with which you are familiar and if you have nothing familiar (like me :-) ) can start with VC++ .
two things you have to configure in the IDE
i. include files
ii.library files
but requirements can change with one IDE to another . better do a google search with
"install opencv with " , you will find many tutorials and pdfs where detail installation steps are given with pictures which are easy to understand . You can get official guide here .
In case you are using VC++ 6.0 .An excellent quick start guide in this pdf
download it and get started, there is only one problem here that is in the Tools->Options->Directories section not only include files you also have to add one entry in Libraries tag normally the path is C:\Program Files\Opencv\lib but check it at your installation folder.

After you are done with that important but useless job
create a project with an empty C++ source file

and there the code below

#include"cv.h"
#include"highgui.h"

int main(){

IplImage *img = cvLoadImage("ImageFileName"); //declaring and loading a
//specified by the image name
cvNamedWindow("window_name",CV_WINDOW_AUTOSIZE);//create
//window to hold it
cvShowImage("window_name",img); //show the image through the window

cvWaitKey(0) ; //wait for a key to be pressed
cvReleaseImage(&img); // release the image space (not necessary)
return 0;

}


as per code is concerned there is no doubt that is very bad piece of code which do not take any user input at run time , and the most important thing is that there is no error checking in the whole code , but I intentionally do that to keep it as simple as possible, this is nothing but a image viewer program which can show almost any type of image , yes you have just made your own image viewer congrats !!!! actually not that, all the magic is done here by the functions we just write them in proper order.
In the next part we will analyze individual code section and scan it line by line and I can assure you that each line will take one post to understand properly (actually far more time).
More on next post.....
Good Bye


N.B.Right to use this code in any way you want without warrenty, support or any guarentee of it working.

Thursday, February 11, 2010

How you can compile APUE book library in Fedora 11

Step 1: You can see a a folder named Make.defines.linux modify it's WKDIR =your directory where you store the apue.2e folder