title: opencv saving image captured from webcam
body: <p>I receive an error "SIGABRT ERROR" when the code is trying to save the image on the HD.</p>
  
  <p>I'm working with a MacBook Pro Mountain Lion on last XCODE and the libraries are well reconfigured.</p>
  
  <p>Someone has a solution or some ideas?</p>
  
  <pre><code>#include "cv.h"
  #include "highgui.h"
  #include &lt;stdio.h&gt;
  using namespace cv;
  // A Simple Camera Capture Framework
  int main() {
  
      CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
      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 );
          // Do not release the frame!
  
          if ( (cvWaitKey(10) &amp; 255) == 's' ) {
              CvSize size = cvGetSize(frame);
              IplImage* img= cvCreateImage(size, IPL_DEPTH_16S, 1);
              img = frame;
               cvSaveImage("matteo.jpg",&amp;img);
                                              }
       if ( (cvWaitKey(10) &amp; 255) == 27 ) break;
      }
      // Release the capture device housekeeping
      cvReleaseCapture( &amp;capture );
      cvDestroyWindow( "mywindow" );
      return 0;
  }
  </code></pre>