That's the code:
Qt Code:
  1. #include "opencv/highgui.h"
  2. int main( int argc, char** argv ) {
  3. /* // Capture the Image from the webcam
  4.   CvCapture *pCapturedImage = cvCreateCameraCapture(0);
  5.  
  6.   // Get the frame
  7.   IplImage *pSaveImg = cvQueryFrame(pCapturedImage);
  8.  
  9.   // Save the frame into a file
  10.   cvSaveImage("test.jpg" ,pSaveImg);
  11.  
  12. */
  13.  
  14.  
  15. cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE );
  16.  
  17. CvCapture* capture = cvCreateCameraCapture(0) ;
  18. IplImage* frame;
  19.  
  20. while(1) {
  21. frame = cvQueryFrame( capture );
  22. if( !frame ) break;
  23. cvShowImage( "Example2", frame );
  24. char c = cvWaitKey(33);
  25. if( c == 27 ) break;
  26.  
  27. }
  28. cvReleaseCapture( &capture );
  29. cvDestroyWindow( "Example2" );
  30.  
  31. }
To copy to clipboard, switch view to plain text mode 
It actually shows the webcam video till it gets [Esc]
This is OK but when I manually close the window from the X button then it reopens...How can i avoid this from being done?