title: How to display one image and one video in one window using OpenCV
body: <p>I came upon a piece of code on <a href="http://opencv.willowgarage.com/wiki/DisplayManyImages" rel="nofollow">this</a> page. It's a neat function that takes as input, a <code>char*</code> and multiple <code>IplImage*</code> arguments and then displays all the images in one window.</p>
  
  <p>I want to do the same with one image and one video. So, apart from changing the main function to initialise a web cam input, and modifying the call to the above function, what else do I need to change?</p>
  
  <p>My main function is :</p>
  
  <pre><code>int main() {
  
      IplImage *img1 = cvLoadImage("image1.png");
  
     CvCapture* capture = cvCaptureFromCAM(0);
     if ( !capture ) {
       fprintf( stderr, "ERROR: capture is NULL \n" );
       getchar();
       return -1;
     }
     // Create a window in which the captured images will be presented
     cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
     // Show the image captured from the camera in the window and repeat
     while ( 1 ) {
       // Get one frame
       IplImage* frame = cvQueryFrame( capture );
       if ( !frame ) {
         fprintf( stderr, "ERROR: frame is null...\n" );
         getchar();
         break;
       }
       //cvShowImage( "mywindow", frame );
       cvShowManyImages("Image", 2, img1, frame);
       // Do not release the frame!
       //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
       //remove higher bits using AND operator
       if ( (cvWaitKey(10) &amp; 255) == 27 ) break;
     }
     // Release the capture device housekeeping
     cvReleaseCapture( &amp;capture );
     cvDestroyWindow( "mywindow" );
  
      return 0;
  }
  </code></pre>
  
  <p>The problem with this is, it only shows the first frame of the video. And I need to keep pressing <code>esc</code> to get the next frame.</p>