title: opencv capture image from webcam without post processing
body: <p>I want to capture images from webcam without any post processing, that is <strong>NO</strong> auto focus , exposure correction , white balance and stuff. Well basically I want to capture continuous frames from webcam and make each frame compare with the previous one and save them to disk only when there is an actual change. Because of the post processing almost every frame is being returned as different for me.</p>
  
  <p>code so far</p>
  
  <pre><code>using namespace cv;
  
  
  
  bool identical(cv::Mat m1, cv::Mat m2)
  {
  
  
  if ( m1.cols != m2.cols || m1.rows != m2.rows || m1.channels() != m2.channels() || m1.type() != m2.type() )
  {
    return false;
  }
  
  for ( int i = 0; i &lt; m1.rows; i++ )
  {
    for ( int j = 0; j &lt; m1.cols; j++ )
      {
        if (  m1.at&lt;Vec3b&gt;(i, j) != m2.at&lt;Vec3b&gt;(i, j) )
          {
            return false;
          }
      }
  }
  return true;
  }
  
  
   int main() {
   CvCapture* capture = cvCaptureFromCAM( 1);
   int i=0,firsttime=0;
   char filename[40];
   Mat img1,img2;
   if ( !capture ) {
   fprintf( stderr, "ERROR: capture is NULL \n" );
   getchar();
   return -1;
   }
  
   cvNamedWindow( "img1", CV_WINDOW_AUTOSIZE );
    cvNamedWindow( "img2", CV_WINDOW_AUTOSIZE );
  
    while ( 1 ) {
  
   IplImage* frame = cvQueryFrame( capture );
   img1=frame;
   if ( !frame ) {
  
     fprintf( stderr, "ERROR: frame is null...\n" );
     getchar();
     break;
   }
   if(firsttime==0){
   img2=frame;
   fprintf( stderr, "firtstime\n" );
   } 
  
   if ( (cvWaitKey(10) &amp; 255) == 27 ) break;
  
   i++;
  
   sprintf(filename, "D:\\testimg\\img%d.jpg", i);
  
  
   cv::cvtColor(img1, img1, CV_BGR2GRAY);
   imshow( "img1", img1);
   imshow( "img2", img2);
   imwrite(filename,img1);
  
   if(identical(img1,img2))
   {
      //write to diff path
   }
  
  
   img2=imread(filename,1);
   firsttime=1;
  }
   // Release the capture device housekeeping
   cvReleaseCapture( &amp;capture );
   return 0;
  }
  </code></pre>
  
  <p>While ur at it, I'll be great full if u can suggest a workaround for this using another frame compare solution aswell :)</p>