title: Body recognition in EmguCV/OpenCV (Tracking person in video)
body: <p>I am trying to recognize the person in video (not by his face but by his body). What I have done so far now is to find the HOG,HS and RGB histograms of a person and compare it with all other person to find him.</p>
  
  <p>I am using EmguCV but OpenCV's help will also be appreciated.</p>
  
  <p><strong>HOG is Calculated using</strong></p>
  
  <pre><code>        Size imageSize = new Size(64, 16);
          Size blockSize = new Size(16, 16);
          Size blockStride = new Size(16, 8);
          Size cellSize = new Size(8, 8);
  
          HOGDescriptor hog = new HOGDescriptor(imageSize, blockSize, blockStride, cellSize);
  
          float[] hogs = hog.Compute(image);
  </code></pre>
  
  <p><strong>Code to Calculate HS Histograms (Same method is used for RGB)</strong></p>
  
  <pre><code>        Image&lt;Gray, byte&gt;[] channels = hsvImage.Copy().Split();
          Image&lt;Gray, byte&gt; hue = channels[0];
          Image&lt;Gray, byte&gt; sat = channels[1];
  
          dh.Calculate&lt;byte&gt;(new Image&lt;Gray, byte&gt;[] { hue }, true, null);
          dh2.Calculate&lt;byte&gt;(new Image&lt;Gray, byte&gt;[] { sat }, true, null);
  
          float[] huehist = dh.GetBinValues();
          float[] sathist = dh2.GetBinValues();
  </code></pre>
  
  <p><strong>Calculating distance of 2 histograms using</strong></p>
  
  <pre><code>        double distance = 0;
          for (int i = 0; i &lt; hist1.Length; i++)
          {
              distance += Math.Abs(hist1[i] - hist2[i]);
          }
          return distance;
  </code></pre>
  
  <p><strong>What is happening</strong></p>
  
  <p>I am trying to track a selected person from video feed. and the person can move from camera to camera.
  The body of <strong>personA</strong> is extracted from the video frame, whose HOG,HS,RGB histograms are calculated and stored... then from next frame the histograms of all detected persons are calculated and matched with the histograms of <strong>personA</strong> the most matched histogram (with minimum distance) is considered as the same person (personA)... so it is continued to track that person...</p>
  
  <p><strong>Problem</strong></p>
  
  <ul>
  <li>Accuracy is not good (sometimes it tells 2 people, with very different colored cloths, same)</li>
  </ul>
  
  <p><strong>Suggestions</strong></p>
  
  <ul>
  <li>What should I change/remove</li>
  <li>Should I calculate histograms using <strong>CvInvoke.CalcHist(...);</strong> instead of dense histograms for HS and RGB</li>
  <li>Should I normalize histograms before calculating distances.</li>
  <li>Is this normalization method good? (every value <strong>minus</strong> mean of array) </li>
  <li>Or should I try something else.</li>
  </ul>
  
  <p><strong>Any kind of help/suggestion will be HIGHLY APPRECIATED</strong> if any more info is needed then please comment.
  Thanks,</p>