xcodelovers

Just Sharing Knowledge

Tag Archives: IDE

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 installing Code::Blocks and MinGW individual package (Windows)

In this tutorial we wil learn how to install and integrate Code::Blocks individual package (Exclude MinGW) with MinGW compiler.
Lets go to the tutorial step:

  1. Install MinGW compiler. There are two kinds of MinGW installer you can use.
  2. Download Code::Blocks individual package (Exclude MinGW) from official website codeblocks. Choose file installer for windows ” codeblocks-10.05-setup.exe “ (Latest version : Code::Blocks 10.05). You can downlond it directly from BerliOS or Sourceforge.net.
  3. Install Code::Blocks by double-clicking on the file and the next steps the same as my tutorial about “Tutorial Installing Code::Blocks and MinGW integrated package (Windows)”.
  4. Note, before you create new project you must change compiler setting by select toolbar menu “Setting->Compiler and debugger” and you will see a dialog like image below.Select on tab “Toolchain executables” and click on “Auto-detect” button. Wait until auto-detect message appear like image below..Click “Ok” button on that message and click “Ok” button on a dialog “compiler and debugger setting”.
  5. Create new project from menu “File->New->Project” and select “console application”. See my tutorial about “Tutorial Installing Code::Blocks and MinGW integrated package (Windows)”.
  6. Put this code on the “main.cpp”
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        cout << "Hello world! This is my first program.." << endl;
        return 0;
    }
    
  7. Compile the program by press “F9” and you will see the result like image below.Congratulations you have successfully integrate Code::Blocks with MinGW….

Tutorial Installing Code::Blocks and MinGW integrated package (Windows)

There are two kinds of  Code::Blocks installer from binary package :

  1. Code::Blocks individual package installer without MinGW/GCC include. (Where you must install MinGW/GCC and Code::Blocks separately). See my tutorial how to install its manualy.
  2. Code::Blocks integrated package installer with MinGW/GCC.

In this tutorial we will use the second installer package for windows platform because it is the easy way to use Code::Blocks with MinGW/GCC. Now just do the following steps:

  1. Download Code::Blocks and MinGW integrated binary package in here. Choose file installer for windows ” codeblocks-10.05mingw-setup.exe “ (Latest version : Code::Blocks 10.05). You can downlond it directly from BerliOS or Sourceforge.net.
  2. After you download it then you just double click on that file and you will see dialog welcome setup like the image below. Click on “Next” button.  
  3. Then a dialog license agreement will appear like screen shoot image below. Click on “I Agree” button.
  4. A selection type installation dialog will appear like screen shoot image below. In this tutorial we do not make any changes just click the “Next” button.
  5. A choose location of installation dialog will appear like image below. In this tutorial we will use default location. You may choose a different installation location of installation as you wish. Then just click on “Install” button.
  6. Wait until the installation is complete.
  7. After the installation is complete then you will see a dialog option to run Code:: Blocks now or later like image below. Select the “Yes” button to run Code::Blocks now.
  8. Then you will see visual IDE of Code::Blocks like image below.
  9. Installation of Code::Blocks and MinGW is finished. Then to check it we will make a sample program “HelloWord”.
  10. Select on menu File->New->Project..Now you will see a project choose dialog like image below and for this tutorial select “Console Application” on the top right corner. Then click on “Go” button or just double click on “Console Application” .
  11. Now you will see a dialog cosole application like image below. In this tutorial we do not make any changes just click the “Next” button.
  12. On the next screen you will see a dialog of language selection like image below. In this tutorial we choose “C++” and then click the “Next” button.
  13. On the next screen you will see a dialog of select project name and folder for workspace like image below. After finished click the “Next” button.
  14. Then you will see a dialog for select type of compiler like image below. n this tutorial we do not make any changes just click the “Finish” button.
  15. On the next screen you will see Code::Blocks IDE like image below. Choose left screen on “Management” panel and click “Project” tab. Expand on “src” folder and double click on file “main.cpp” and you will see listing code on the middle of editor.
  16. Try to change listing code on the editor with this..
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        cout << "Hello world! This is my first program.." << endl;
        return 0;
    }
    
  17. Then build and run program by select menu “Build->Build and Run” or just press “F9” button. You will see the result like image below. Congratulations you are ready to program with Code::Blocks. Have fun with it….

What is Code::Blocks ?

Code::Blocks is a free open source IDE (Integrated Development Environment) for C/C++ programming code that can be run on cross platform (Windows, Linux, and Mac OS X). It is support multiple compilers, including MinGW / GCC, Digital Mars, Microsoft Visual C++, Borland C++, Watcom, LCC and the Intel C++ compiler.

The IDE was designed for the C++ language but also support for other compilers languages, including GNU Fortran, Digital Mars D and GNU GDC. If you ever seen Microsoft Visual C++ IDE before, this Code::Blocks IDE is similar like that. Interest and want to learn about Code::Blocks ? Absolutely yes…look at screen shoot below you can built many project with this IDE.

You can find more detail information about Code::Blocks in the Code::Blocks Website or Official Wiki Code::Blocks.
If you interested and want to try Code::Blocks IDE see my tutorial Code::Blocks in this blog.