OpenCV 2.3.1 with CodeBlocks on Ubuntu 12.04

For Installing OpenCV 2.3.1 on ubuntu 12.04 please refer to previous post
http://opencvlover.blogspot.in/2012/05/install-opencv-231-on-ubuntu-1204.html

Once the installation is done, install codeblocks as mentioned in previous post http://opencvlover.blogspot.in/2011/07/installing-opencv-with-codeblocks-ide.html

Create a new console application as mentioned in above post and go to Build Options.
Make sure that GNU GCC compiler is selected in compiler drop down option.
Go to Linker Settings tab and Link libraries which are located at /usr/local/lib/ and looks like 'libopncv_*.so'
An example is shown in image below


Now go to Search directories and under Compiler tab add following location
/usr/local/include/opencv2
Here is a screenshot


Now we are ready to run OpenCV 2.3.1 on Code Blocks running on Ubuntu 12.04.
Here is a sample code to test the installtion






15 comments:

  1. Hi.. I am getting following errors...
    /home/cpp/img/main.o||In function `main':|
    main.cpp|| undefined reference to `cvNamedWindow'|
    main.cpp|| undefined reference to `cvWaitKey'|
    main.cpp|| undefined reference to `cvDestroyWindow'|
    ||=== Build finished: 3 errors, 0 warnings ===|

    Please tell me what should i do?????

    ReplyDelete
    Replies
    1. Please check your linker setting as mentioned in the post. Which opencv version are you using?

      Delete
    2. I have checked linker settings.. Still its not working..
      I am using OpenCV Version 2.1.0-7...

      Delete
    3. Method mentioned in above blogpost works for opencv 2.3 and higher versions. I would suggest you using opencv 2.3.1 or higher versions as they are latest.
      For opencv 2.1 I guess you will have to soecify few more setting such as include directory etc.

      Delete
    4. I have read your blog its very attractive and impressive. I like it your blog.

      Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

      Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai

      Delete
  2. Hi... i am new to ubuntu and opencv...
    I followed the above mentioned steps..
    but i am getting following error....

    -------------- Build: Debug in p2 ---------------

    Linking console executable: bin/Debug/p2
    /usr/bin/ld: cannot find -lcv
    /usr/bin/ld: cannot find -lhigui
    /usr/bin/ld: cannot find -lcvaux
    /usr/bin/ld: cannot find -lcv
    /usr/bin/ld: cannot find -lcvaux
    /usr/bin/ld: cannot find -lhigui
    collect2: ld returned 1 exit status
    Process terminated with status 1 (0 minutes, 0 seconds)
    6 errors, 0 warnings

    can anybody tell what is the problem????

    ReplyDelete
    Replies
    1. which opencv version are you using?

      Delete
    2. Hi I am also getting the same error...

      /usr/bin/ld: cannot find -lcv
      /usr/bin/ld: cannot find -lcvaux
      /usr/bin/ld: cannot find -lhigui
      collect2: ld returned 1 exit status

      I am using openCV 2.4.9

      Delete
  3. Hi..
    I am trying to capture image using webcam. When i executed the code its giving me capture as null.
    What could be the problem??
    Please help me.
    Following is the code.

    #include
    #include

    int main( int argc, char** argv )
    {
    cvNamedWindow( "Example", CV_WINDOW_AUTOSIZE );

    CvCapture* capture = cvCaptureFromCAM(0) ;
    IplImage* frame;

    while(1)
    {
    frame = cvQueryFrame( capture );

    if( 1 ) // !frame
    break;
    cvShowImage( "Example", frame );

    char c = cvWaitKey(33);
    if( c == 27 )
    break;

    cvSaveImage("webcam_frame.png",frame);
    }
    cvReleaseCapture( &capture );
    cvWaitKey(0);
    cvDestroyWindow( "Example" );
    }

    ReplyDelete
  4. Herpes, a very common viral infection, spreads by person-to-person contact.
    The infection is caused by the herpes simplex virus (HSV), which comes in two forms: HSV-1, which usually results in oral herpes infections affecting the mouth and lips; and HSV-2, which usually causes genital herpes affecting the genitals and anus.
    Both types of HSV spread primarily by physical contact with an infected person. Most people get HSV-2 during sexual intercourse (vaginal or anal). HSV-1 tends to spread to individuals in childhood, when an adult who carries the virus touches the child — for example, by pinching a baby's cheeks. Among adults, HSV-1 usually spreads by kissing.
    what is herpes

    ReplyDelete
  5. Herpes is a type of viral infection that considered as a highly contagious illness. we can call this as one of the most devastating illness nowadays. The disease categorized as chronic illness. But now you can eliminate herpes virus from your body by using Herpes Natural Cure ..

    ReplyDelete
  6. Herpes, a highly contagious disease which usually known as sexually transmitted disease. Nowadays herpes simplex virus has many
    herpes treatment but those treatment can only contro the symptoms of herpes but can't cure permanently. you can only cure the herpes by using Natural Herpes Cure because natural stuffs helps to boost up your immune system. the powerful immune system means you have the enough ability to fight with Herpes Simplex Virus ..

    ReplyDelete
  7. Hiv disease for the last 3 years and had pain hard to eat and cough are nightmares,especially the first year At this stage, the immune system is severely weakened, and the risk of contracting opportunistic infections is much greater. However, not everyone with HIV will go on to develop AIDS. The earlier you receive treatment, the better your outcome will be.I started taking ARV to avoid early death but I had faith in God that i would be healed someday.As a Hiv patent we are advise to be taking antiretroviral treatments to reduce our chance of transmitting the virus to others , few weeks ago i came on search on the internet if i could get any information on Hiv treatment with herbal medicine, on my search i saw a testimony of someone who has been healed from Hiv her name was Achima Abelard and other Herpes Virus patent Tasha Moore also giving testimony about this same man,Called Dr Itua Herbal Center.I was moved by the testimony and i contacted him by his Email.drituaherbalcenter@gmail.com We chatted and he send me a bottle of herbal medicine I drank it as he instructed me to.After drinking it he ask me to go for a test that how i ended my suffering life of Hiv patent,I'm cured and free of Arv Pills.I'm forever grateful to him Drituaherbalcenter.Here his contact Number +2348149277967...He assure me he can cure the following disease..Hiv,Cancer,Herpes Virus,Epilepsy, fibromyalgia ,ALS,Hepatitis,Copd,Parkinson disease.Genetic disease,Fibrodysplasia Ossificans Progressiva,Factor V Leiden Mutation ,Fatal Familial Insomnia ,Dupuytren's disease,Fibrodysplasia Ossificans Progressiva,Fluoroquinolone Toxicity Syndrome,Inflammatory bowel disease ,Huntington's disease ,Diabetes,Fibroid...

    ReplyDelete