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. It’s really simple .

Here is the code for main.cpp

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[]){   
  	QApplication a(argc, argv);    
	MainWindow w;    
	w.show();  
	IplImage* img = cvLoadImage( "C:\hello.jpg" ); 

 	//load the image     
	cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );  
	cvShowImage( "Example1", img ); 
	cvWaitKey(0);  
	cvReleaseImage( &img );  
	cvDestroyWindow( "Example1" ); 
	return a.exec();
}

 

You will get output like this…

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

 

SHARE Qt–OpenCV : Hello image display in the screen

You may also like...

4 Responses

  1. Anonymous says:

    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. Ashok says:

    @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. Ashok says:

    This comment has been removed by the author.

  4. Rajiv says:

    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.

Leave a Reply

Your email address will not be published.

Share