xcodelovers

Just Sharing Knowledge

Tag Archives: computer vision

Tutorial integrating Code::Blocks and OpenCV 2.2.0

In this tutorial, we will learn about “how to integrate Code::Blocks and OpenCV 2.2.0”. The installation step of OpenCV 2.2.0 similar like OpenCV 2.1.0 but different in setting of OpenCV include directory or files and OpenCV library files. Please see my previous tutorial about “Tutorial integrating Code::Blocks and OpenCV 2.1.0”.

Ok, lets jump to the tutorial step.

  1. We assume that you have installed opencv and codeblocks on your computer. If you don’t have it, please see my other tutorial how to installing them in this blog. Go to the next step.
  2. Run Code::Blocks and select on the menu “Setting->Compiler and debugger” like image below.
  3. Next, you will see a dialog for Compiler and debugger settings like image below, on the “search directories” tab select “compiler” tab and add opencv include directory by click “Add” button on the bottom.
  4. Next, On the “search directories” tab select “linker” tab and add opencv library directory by click “Add” button on the bottom like image below.
  5. Next, still on a dialog for Compiler and debugger settings, select “Linker setting” tab and add opencv include file by click “Add” button on the bottom like image below.
  6. Create New project from menu “File->New->Project”, select “Console Application”, choose C++ project and give project name. Select “GNU GCC Compiler” and click “Finish” button.
  7. On the left panel expand folder “src” and then open main.cpp. On the code editor put this code bellow.
    #include
    
    #include "cv.h"
    
    #include "highgui.h"
    
    int main(int argc, char** argv)
    
    {
    
      IplImage *img = cvLoadImage("lena.jpg", CV_LOAD_IMAGE_COLOR);
    
     /* initialize font and add text */
    
     CvFont font;
    
     cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0, 1, CV_AA);
    
     cvPutText(img, "Hello World!", cvPoint(10, 50), &font, cvScalar(255, 255, 255, 0));
    
     /* display the image */
    
     cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
    
     cvShowImage("image", img);
    
     cvWaitKey(0);
    
     cvDestroyWindow("image");
    
     cvReleaseImage( &img );
    
     return 0;
    
    }
    
    
  8. Build and run project by press “F9”. (Note: you must put image file on the project folder first and then run project.)
  9. Then you will see result like image below. Congratulation you are successful integrate Code::Blocks and OpenCV. Have fun…

Tutorial integrating Code::Blocks and OpenCV 2.1.0

In this tutorial, we will learn about “how to integrate Code::Blocks and OpenCV 2.1.0”. For OpenCV 2.2.0, please see my other tutorial about “Tutorial integrating Code::Blocks and OpenCV 2.2.0”.

You must have OpenCV 2.1.0 and Code::Blocks installed on your system. If you don’t have it, please see my other tutorial how to installing them in this blog.

Ok, lets jump to the tutorial step.

  1. We assume that you have installed opencv and codeblocks on your computer. So ,we jump to the next step.
  2. Run Code::Blocks and select on the menu “Setting->Compiler and debugger” like image below.
  3. Next, you will see a dialog for Compiler and debugger settings like image below, on the “search directories” tab select “compiler” tab and add opencv include directory by click “Add” button on the bottom.
  4. Next, On the “search directories” tab select “linker” tab and add opencv library directory by click “Add” button on the bottom like image below.
  5. Next, still on a dialog for Compiler and debugger settings, select “Linker setting” tab and add opencv include file by click “Add” button on the bottom like image below.
  6. Create New project from menu “File->New->Project”, select “Console Application”, choose C++ project and give project name. Select “GNU GCC Compiler” and click “Finish” button.
  7. On the left panel expand folder “src” and then open main.cpp. On the code editor put this code bellow.
    #include "stdio.h"
    #include "cv.h"
    #include "highgui.h"
    
    int main(int argc, char** argv)
    {
     IplImage *img = cvLoadImage("lena.jpg", CV_LOAD_IMAGE_COLOR);
    
     /* initialize font and add text */
     CvFont font;
     cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0, 1, CV_AA);
     cvPutText(img, "Hello World!", cvPoint(10, 50), &font, cvScalar(255, 255, 255, 0));
    
     /* display the image */
     cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
     cvShowImage("image", img);
     cvWaitKey(0);
     cvDestroyWindow("image");
     cvReleaseImage( &img );
    
     return 0;
    
    }
    
    
  8. Build and run project by press “F9”. (Note: you must put image file on the project folder first and then run project.)
  9. Then you will see result like image below. Congratulation you are successful integrate Code::Blocks and OpenCV. Have fun…

Tutorial Installing OpenCV based on Visual Studio binaries

In this tutorial, we will learn step by step installation for OpenCV package based on Visual Studio compiler binaries. For OpenCV installation based on other compiler binaries such as MinGW, please see my other tutorial in “Tutorial Installing OpenCV from source based on MinGW compiler binaries”.

The latest version of OpenCV is 2.2.0 that support more library function for C++ language, but the principle of installation between old version and new one is same.

Ok, lets jump to installation step.

  1. Download OpenCV 2.1.0 binary package for visual studio 2008 in here or OpenCV2.2.0 for visual studio 2010 in here.
  2. Install it by double clicking on the file. Next, you will see a welcome setup dialog like image below, just click on “Next” button.
  3. On the next screen, you will see a license agreement dialog like image below. Click on “I Agree” button.
  4. On the next screen, you will see a system path dialog like image below. Choose “Add OpenCV to system path for all user” and then click “Next” button.
  5. On the next screen, you will see a dialog for choose location of installation like image below. In this tutorial we will use default location, you may change the installation location as you wish. After you choose installation location, then just click “Next” button.
  6. Next, you will see a dialog for start menu folder like image below. In this tutorial we will use default folder, you may change it as you wish. Then click “Next” button.
  7. Next, you will see a dialog for choose type component installation like image below. In this tutorial we will use “FULL” installation, you may change it as you wish. Then click “Install” button.
  8. Finally, you will see a information dialog for complete installation like image below. Then click “Finish” button.

What is OpenCV?

OpenCV (Open Source Computer Vision) is a cross-platform (Windows, Linux, MacOS, freeBSD) library of programming functions that are widely used to support the project development of applications based on computer vision. OpenCV developed by Intel, which is free under BSD license for both academic and commercial use. OpenCV libraries contain more than 500 algorithms which are widely used in image and video processing.
Now, in its development is supported by researchers from robotics lab Willow Garage. OpenCV based on C / C + + which can be integrated with a variety of programming IDE editor like code:: blocks, Eclipse, Qt, DevCpp, and others also support the python programming language.
For more detailed information please visit the “OpenCV website” or “OpenCV Wiki” and for a tutorial how to integrate OpenCV with “visual editor IDE” as codeblocks, eclipse and qt please read my tutorials on this blog.