Wednesday 9 January 2013

Cuckoo Search :

Cuckoo search (CS) is an optimization algorithm (finding a value x such that f(x) is as small (or as large) as possible) based on cuckoo species which laying their eggs in the nests of other host birds (of other species). The optimal solutions obtained by CS are far better than the best solutions obtained by an efficient particle swarm optimiser and in some ways better than the powerful genetic algorithem too.
May be this is one of the main reason for this to be famous.
CS is based on three idealized rules:
1) Each cuckoo lays one egg at a time, and dumps its egg in a randomly chosen nest;
2) The best nests with high quality of eggs will carry over to the next generation;
3) The number of available hosts nests is fixed, and the egg laid by a cuckoo is discovered by the host bird with a probability . Discovering operate on some set of worst nests, and discovered solutions dumped from farther calculations.
                 Yang and Deb discovered that the random-walk style search is better performed by Lévy flights rather than simple random walk.
Uses: 
The applications of Cuckoo Search into engineering optimization problems have shown its promising efficiency. For example, for both spring design and welded beam design problems, CS obtained better solutions than existing solutions in literature. A promising discrete cuckoo search algorithm is recently proposed to solve nurse scheduling problem.

You can read Xin-She Yang and Suash Deb's paper (Engineering Optimisation by Cuckoo Search) .
This can be implemented in Matlab. check this: http://www.mathworks.in/matlabcentral/fileexchange/29809-cuckoo-search-cs-algorithm. 
ieeexplore papers can be referred for more reference.
Program To load a image From Your Computer using OpenCV:

//Image_load
#include<opencv\highgui.h>
////////////////////////////////////  C LIBRARIES /////////////////
#include<stdio.h>
///////////////////////////////////////////////////////////////

int main(int argc,char* argv){          
 IplImage* img;                                                 
// declaring img in OpenCV
 img = cvLoadImage("E:\\Image.JPG",1);       /// loads the image from the location E: //
 if(img == NULL){                                         //// If Image is not present then the program terminates
  printf("Error: Frame is Null \n");
  getchar();
  return(-1);
 }
 cvNamedWindow("Original",CV_WINDOW_AUTOSIZE);  // loads window with auto size
 cvShowImage("original",img);                    //// shows the output image
 cvWaitKey(0);                                               // waits for the key stroke to destroy window.
 cvDestroyWindow("Original");
  return(0);
 }


Output:

Applications of Open Computer Vision:
              Application of this is growing day by day. The main advantage is the inbuilt libraries which makes many techniques easy.
             Simple techniques which are given as examples in OpenCV software are :
             In Video prossesing:
             1. Colour Tracking.
             2. Point Tracking.
             3. Motion Segmentation.
             4. Edge detection.
             Image Prossessing:
             1. Edge detection.
             2. Segmentation.
             3. Morphology.
             4. Histogrom.
             5. Distance Transform.
             6. Ellipse Fitting.
To do better you should be knowing atleast these techniques thorough.
             Major applications of OpenCV is based on identification,recognition and tracking. Now-a-days Major Robotic projects are done using this. For list of applications go to http://en.wikipedia.org/wiki/OpenCV. I will try to discuss the code for above techniques starting from basic code implientation.

Wednesday 2 January 2013


Installation of OpenCV in windows:

Let us first install and see the applications later.
I am using windows platform so I am going to discuss here installation in windows using Microsoft visual studio.

Required to download:
1. OpenCV (click)
2. Microsoft visual studio.

I use Microsoft visual studio ultimate in my programs.
I will discuss step by step procedure to install. I will try to make it as simple as possible.

Step 1:  (Download required components.)                                                                           
                                                                                                                                                       
  • Download OpenCV. It is an open source. You can download it by clicking on it. 
  • I prefer using Microsoft visual studio ultimate.                                                         




Step 2: (Extracting OpenCV to a location)
  • After downloading, go to the folder, right click on it and click on run as administrator.
  • Now select the location where you need to extract (Here I extracted to C:\ ) then click extract. 


It will take some minutes for extraction into the selected folder.
After extraction, name of the folder will be OpenCV. To avoid confusion while setting path change the name of folder to something else.(Let “OpenCV243”).

Now install Microsoft visual studio (Ignore if you have).
Step 3: (Set the path.)                                                                        
Follow the link of steps to set path.                                                 

Start à Control panel à System  à Advanced system settings



Advanced system settings à Environment Variables àPATH (Search for variable PATH in System variable inside Environmental Variables window)



Double click on the system variable PATH to edit it.



When edit system variable window pops up add C:\OpenCv243\build\x86\vc10\bin;

System variable value, i.e. the path added should be ended with semicolon (;).
To know why this is done, go to the location that is added to the variable. It contains all the .dll files which are to be added for the program to run.

Step 4: (Creating property sheet in Microsoft Visual Studio)                                                           
Here we create a property sheet which should be created in any program we write further in OpenCV. But a property sheet which was created can be added to any program. So creating    property sheet is crucial in the way we write the program.                                                             

Open Microsoft Visual Studio



Click on new project

Create a Win32 console application. Write a unique name for your New Project. Click OK.

Click Next..



Check for
Application type: Console application
Additional options: Empty project

Click Finish.
Now open the Property manager à Right click on Debug àAdd new property sheet.

Name the Property sheet and click Add.


There are three places where you should link locations or add. 

1.C/C++   à  Additional include directories à Edit à Add(C:\OpenCv243\build\include)


2. Linker à Additional Library Directories à Edit à Add (C:\OpenCv243\build\x86\vc10\lib)

     

 3. Linker à input à Additional Dependencies à Edit, Add

opencv_calib3d243d.lib;
opencv_contrib243d.lib;
opencv_core243d.lib;
opencv_features2d243d.lib;
opencv_flann243d.lib;
opencv_gpu243d.lib;
opencv_haartraining_engined.lib;
opencv_highgui243d.lib;
opencv_imgproc243d.lib;
opencv_legacy243d.lib;
opencv_ml243d.lib;
opencv_nonfree243d.lib;
opencv_objdetect243d.lib;
opencv_photo243d.lib;
opencv_stitching243d.lib;
opencv_ts243d.lib;
opencv_video243d.lib;
opencv_videostab243d.lib;

Note: This changes when your version changes. These are for OpenCV 2.4.3 as you can see 243d everywhere.

Now click OK. Your New Property Sheet is created now.

To write program go to    Solution Explorer à Right click on Source Files à Add new Item 


We write the program in C/C++ so select C++ file. Name it and click Add. Now you are ready to write Program in OpenCV.