title: cvReleaseCapture() error
body: <p>To make my question clearer, please view the following codes below:</p>
  
  <p>For snapping image:</p>
  
  <pre><code>void CameraTest ::on_snapButton_clicked()
  {
      CvCapture* capture = cvCaptureFromCAM(0); // capture from video device #0
  
  
      cvSetCaptureProperty(capture ,CV_CAP_PROP_FRAME_WIDTH , 800); 
      cvSetCaptureProperty(capture ,CV_CAP_PROP_FRAME_HEIGHT , 600); 
  
  
      if(!cvGrabFrame(capture))  //if no webcam detected or failed to capture anything
      {              // capture a frame 
          cout &lt;&lt; "Could not grab a frame\n\7";
          exit(0);
      }
  
      IplImage* img=cvRetrieveFrame(capture);           // retrieve the captured frame
  
      cv::Mat imageContainer(img);
      image=imageContainer;
      cv::imshow("Mat",image);  
  
      //cvReleaseCapture(&amp;capture);  When I enable this, and run the programming calling this, there will be an error. 
  }
  </code></pre>
  
  <p>Now, the program to display the image:</p>
  
  <pre><code>      void CameraTest ::on_processButton_clicked() 
        {
            cv::imshow("image snapped", image);
  
            //my image processing steps...
        }
  </code></pre>
  
  <p>When I enable the <code>cvReleaseCapture(&amp;capture)</code> line, I recieve the following error:</p>
  
  <pre><code>Unhandled exception at 0x00fc3ff5 in CameraTest.exe: 0xC0000005: Access violation reading location 0x042e1030.
  </code></pre>
  
  <p>When I comment/remove the line, I am able to display image properly upon clicking the other button, but when I want to snap new images, I have to click the button a few times, which is a major flaw in the program. Is there anyway to go around it? </p>