title: Tracking Blobs with Microsoft Kinect
body: <p>I am working on a people counter. For this I have the Microsoft Kinect installed over the door.
  I am working with C# and EmguCV. I have extracted the heads of the people, so that they appear as white blobs on a black image. Then I have created a bounding box around the heads. That works fine. So I now how many blobs I have per frame and I also now their position. This works fine. But now I want to track the blobs because I want to count how much people come in and go out, but I don't know how to do this. Can anyone help me? The problem is that every frame, new blobs can appear and old blobs can disappear. Can anyone give me an algorithm or maybe some code? or a paper. 
  Thanks a lot!</p>
  
  <hr>
  
  <p>Sure. This is the code for the blobs:</p>
  
  <pre><code>using (MemStorage stor = new MemStorage())
          {
  
  
  
              Contour&lt;System.Drawing.Point&gt; contours = head_image.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_EXTERNAL, stor);
  
  
  
              for (int i = 0; contours != null; contours = contours.HNext)
              {
  
                  i++;
  
  
  
                  //if ((contours.Area &gt; Math.Pow(sliderMinSize.Value, 2)) &amp;&amp; (contours.Area &lt; Math.Pow(sliderMaxSize.Value, 2)))
                  {
  
                      MCvBox2D box = contours.GetMinAreaRect();
  
                      blobCount++;
  
                      contour_image.Draw(box, new Bgr(System.Drawing.Color.Red), 1);
  
  
                      new_position = new System.Drawing.Point((int)(box.center.X), (int)(box.center.Y));
                      new_x = box.center.X;
                      new_y = box.center.Y;
                  }
  
              }
          }
  </code></pre>