title: OpenCV & Virsual C++: save Frame data from Camera and then  save  to Jpg
body: <p>I am an <strong>OpenCV</strong> and <strong>C++</strong> beginner. I've got a problem with my student project.My Tutor wants to grab frames from a Camera and save the grabbed frames into jpg. So first I used <code>"cvCreateCameraCapture，cvQueryFrame，cvSaveImage"</code> and it worded ok. But the frame is relative big,about 2500x2000,and it takes about 1 second to save one Frame. But my Tutor requires at least to save 10 Frames per second.</p>
  
  <p>Then I came out the ideas to save raw data first and after grabbing process  I can save them into Jpg. So I wrote following test code.But the problem is that all the saved Images are the same and it seems they are just from the data of the last grabbed frame.I guess the problem is about my poor knowledge of c++ especially pointers.So I really hope to get help here.</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>void COpenCVDuoArryTestDlg::OnBnClickedButton1()
  {
  IplImage* m_Frame=NULL;
  TRACE("m_Frame initialed");
  CvCapture * m_Video=NULL;
  m_Video=cvCreateCameraCapture(0);
  IplImage**Temp_Frame= (IplImage**)new IplImage*[100]; 
  for(int j=0;j&lt;100;j++){
  
  Temp_Frame[j]= new IplImage [112];
  
  }
  TRACE("Tempt_Frame initialed\n");
  
  cvNamedWindow("video",1);
  int t=0;
  
  while(m_Frame=cvQueryFrame(m_Video)){ 
  
      for(int k=0;k&lt;m_Frame-&gt;nSize;k++){
  Temp_Frame[t][k]= m_Frame[k];
  
      }
  
  cvWaitKey(30);
  t++;
  
  if(t==100){
  break;
  }
  
  }
  
  
  for(int i=0;i&lt;30;i++){
  CString ImagesName;
  
  ImagesName.Format(_T("Image%.3d.jpg"),i);
  
  if(cvWaitKey(20)==27) {
  break;
  }
  else{
  
  cvSaveImage(ImagesName, Temp_Frame[i]);
  
  }    
  }    
  
  cvReleaseCapture(&amp;m_Video);
  cvDestroyWindow("video");
  TRACE("cvDestroy works\n");
  
  delete []Temp_Frame;
  }
  </code></pre>