title: Areas of objects using cvMoments
body: <p>I am working on a motion recognition project of walking, involving openCV and C++. I have reached the stage in the algorithm where I am required to find the area of the human blob. I have loaded the video, converted it to grayscale and thresholded it to obtain a binary image with white regions showing the human walking in addition to other white regions. I need to find the area of each white region to determine the area of the human blob since this region will have an area greater than that of the other white regions. Please look through my code and explain the output to me because I am getting an area of 40872 and I do not know what this means. This is my code. I want to upload the video I used but I do not know how to:/ If someone can tell me how to upload the video I used, please do, because this is the only way I will be able to get help with this particular video. I really hope someone can help me.</p>
  
  <pre><code>#include "cv.h"
  #include "highgui.h"
  #include "iostream"
  
  using namespace std;
  int main( int argc, char* argv ) {
  
  CvCapture *capture = NULL;
  capture = cvCaptureFromAVI("C:\\walking\\lady walking.avi");
  if(!capture){
      return -1;
  }
  
  IplImage* color_frame = NULL;
  IplImage* gray_frame = NULL ;
  int thresh_frame = 70;
  CvMoments moments;
  
  int frameCount=0;//Counts every 5 frames
  cvNamedWindow( "walking", CV_WINDOW_AUTOSIZE );
  
  while(1) {
      color_frame = cvQueryFrame( capture );//Grabs the frame from a file
      if( !color_frame ) break;
      gray_frame = cvCreateImage(cvSize(color_frame-&gt;width, color_frame-&gt;height),      color_frame-&gt;depth, 1);
      if( !color_frame ) break;// If the frame does not exist, quit the loop
  
      frameCount++;
      if(frameCount==5)
      {
          cvCvtColor(color_frame, gray_frame, CV_BGR2GRAY);
          cvThreshold(gray_frame, gray_frame, thresh_frame, 255, CV_THRESH_BINARY);
          cvErode(gray_frame, gray_frame, NULL, 1);
          cvDilate(gray_frame, gray_frame, NULL, 1);
  
          cvMoments(gray_frame, &amp;moments, 1);
          double m00;
          m00 = cvGetSpatialMoment(&amp;moments, 0,0);
  
          cvShowImage("walking", gray_frame);
          frameCount=0;
      }
      char c = cvWaitKey(33);
      if( c == 27 ) break;
  }
  
  double m00 = (double)cvGetSpatialMoment(&amp;moments, 0,0);
  cout &lt;&lt; "Area - : " &lt;&lt; m00 &lt;&lt; endl;
  
  cvReleaseImage(&amp;color_frame);
  cvReleaseImage(&amp;gray_frame);
  cvReleaseCapture( &amp;capture );
  cvDestroyWindow( "walking" );
  
  return 0;
  }
  </code></pre>