My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
and update your bookmarks.

Sunday, March 13, 2011

Qt–OpenCV : Hello image display in the screen

After successfully configuring your Qt-Creator with OpenCV library, its now time to get your hands dirty with the openCV programming. Here I have created a simple sample program which loads the picture from your drive named hello.jpg. Its really simple Smile

Here is the code for main.cpp
  1: #include <opencv/cv.h>
  2: #include <opencv/highgui.h>
  3: #include <QtGui/QApplication>
  4: #include "mainwindow.h"
  6: int main(int argc, char *argv[]){   
  7:     QApplication a(argc, argv);    
  8:     MainWindow w;    
 10:     IplImage* img = cvLoadImage( "C:\\hello.jpg" ); 
 11:                     //load the image     
 12:     cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );  
 13:     cvShowImage( "Example1", img ); 
 14:     cvWaitKey(0);  
 15:     cvReleaseImage( &img );  
 16:     cvDestroyWindow( "Example1" ); 
 17:     return a.exec();
 18: }

You will get output like this…

You can download the above project for OpenCV2.2 here.


  1. Thank you

    I have tried running this code on Windows xp & opencv2 .2 & Qt 4.7.4 (32 bit)

    But the interface did not show

    No image is displayed: /

    And I do not know what reason,can you help me?

  2. @Anonymous Thanks for the comment. I have updated the post with OpenCV2.2 working one. You can try that one and if any problem occurs , you can consult again....

  3. This comment has been removed by the author.

  4. can you integrate openCV in android mobile phone?? or can send image from android phone via bluetooth, wifi to pc with openCV... which is easy..and can you help me.. this is my pg project and time is critical.