title: Comparing current and previous faces from a continous faces detection
body: <p>I am working with face detection.I need to compare current and previous(successive) faces.Can any one help me how to take current and previous faces from a continuous face detection.I am not getting any idea about this. </p>
  
  <p><strong>This is my face detection code</strong> </p>
  
  <pre><code>void facedetect(IplImage* image)
  {
  ct1++;
  cvNamedWindow("output");
  int j=0,i,count=0,strsize;
  char numstr[50];
  CvPoint ul,lr,w,h,ul1,lr1;
  CvRect *r;
  string path;
  IplImage* image1;IplImage* tmpsize;IplImage* reimg;
  CvHaarClassifierCascade* cascade=(CvHaarClassifierCascade*) cvLoad(cascade_name);                                                              
  CvMemStorage* storage=cvCreateMemStorage(0);
  const char *extract;
  if(!cascade)
  {
      cout&lt;&lt;"Coulid not load classifier cascade"&lt;&lt;endl;
  
  }
  if(cascade)
  {         faces=cvHaarDetectObjects(image,cascade,storage,1.1,1,CV_HAAR_DO_CANNY_PRUNING,cvSize(10,10));
      for(int i=0;i&lt;(faces ? faces-&gt;total : 0);i++)
      {
          string s1="im",re,rename,ex=".pgm";
          sprintf(numstr, "%d", k);
          re = s1 + numstr;
          rename=re+ex;
          char *extract1=new char[rename.size()+1];
          extract1[rename.size()]=0;  memcpy(extract1,rename.c_str(),rename.size());                              
          strsize=rename.size();
          r=(CvRect*) cvGetSeqElem(faces,i);
          ul.x=r-&gt;x;
          ul.y=r-&gt;y;
          w.x=r-&gt;width;
          h.y=r-&gt;height;
          lr.x=(r-&gt;x + r-&gt;width);
          lr.y=(r-&gt;y + r-&gt;height);
          cvSetImageROI(image,cvRect(ul.x,ul.y,w.x,h.y));
          image1=cvCreateImage(cvGetSize(image),image-&gt;depth,image-&gt;nChannels);
          cvCopy(image, image1, NULL);
          reimg=resizeImage(image1, 40, 40, true);
          saveImage(reimg,extract1);
          Mat img=cvarrToMat(reimg);
          //Mat img1=cvarrToMat();
          imshow("result",img); //this is the current image, but i need to get the previous image also.
          //readImag(img,"/home/athira/Image/folderr", path);
          cvResetImageROI(image);
          cvRectangle(image,ul,lr,CV_RGB(1,255,0),3,8,0);
          j++,count++;
          k++;
          arr[l]=ul.x;
          arr1[l]=ul.y;
          cout&lt;&lt;"frame"&lt;&lt;ct1&lt;&lt;" "&lt;&lt;"face"&lt;&lt;ct&lt;&lt;":"&lt;&lt;"x: "&lt;&lt;ul.x&lt;&lt;endl;
          cout&lt;&lt;"frame"&lt;&lt;ct1&lt;&lt;" "&lt;&lt;"face"&lt;&lt;ct&lt;&lt;":"&lt;&lt;"y: "&lt;&lt;ul.y&lt;&lt;endl;
          cout&lt;&lt;""&lt;&lt;endl;
          ct++;
          //compareImages(l,faces-&gt;total);
          //feature_extract(img,img1);
          l++;
  
      }
       width=image-&gt;width;
       height=image-&gt;height;
       resoltion=width*height;
       s=(float) 0.0301/100;
       diff=s*resoltion;
      cvShowImage("output",image);
      cvWaitKey(0);       
  }       
  }
  </code></pre>