title: Taking the HOG descriptor of an image using HOGDescriptor from EMGU CV C#
body: <p>How can I compute the hog descriptor vector of an image using EMGU CV and C#.</p>
  
  <p>If i make something like this:</p>
  
  <pre><code>float[] f;
  Image&lt;Bgr, Byte&gt; img1 = new Image&lt;Bgr, Byte&gt;(fullPath);
  
  f = hog.Compute(img1, Size.Empty, Size.Empty,null );
  </code></pre>
  
  <p>it doesn't work, it gives a </p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object.</p>
  </blockquote>
  
  <p>exception. I want to compute the hog descriptor with default parameters.</p>
  
  <p>Does someone know how to do this ?</p>
  
  <p>Emgu cv is very poorly documented.</p>
  
  <p>I have modified the code and now I am getting the following error: "External component has thrown an exception" The code is listed below   </p>
  
  <pre><code>public float[] GetVector(Image&lt;Bgr, Byte&gt; im)
      {
          HOGDescriptor hog = new HOGDescriptor();    // with defaults values
         // Image&lt;Bgr, Byte&gt; pImage = new Image&lt;Bgr, Byte&gt;(;
         //pImage.ROI = new Rectangle(new Point(0, 0), new Size(64, 128));
          Point[] p = new Point[im.Width * im.Height];
          int k = 0;
          for (int i = 0; i &lt; im.Width; i++)
          {
              for (int j = 0; j &lt; im.Height; j++)
              {
                  Point p1 = new Point(i, j);
                  p[k++] = p1;
              }
          }
          return hog.Compute(im, new Size(8, 8), new Size(0, 0), p);
      }
  </code></pre>