EmguCV HOG 描述符始终为零

EmguCV HOG descriptors are always zeros

我正在尝试从图像中提取 HOG 描述符,但结果总是得到零。怎么解决。这是我用来提取 HOG 描述符的 C# 代码。

private void btnGetHOGDescriptor_Click(object sender, EventArgs e)
{
    if(InputImage.Original != null)
    {
        Image<Bgr, Byte> inputImage = new Image<Bgr, Byte>(new Bitmap(pbInputImage.Image));
        float[] descriptor = GetVector(inputImage);

        rtbDescriptor.Text = string.Join(" ", descriptor);
    }
}

public float[] GetVector(Image<Bgr, Byte> img)
{
    HOGDescriptor hog = new HOGDescriptor();    // with defaults values
    Point[] p = new Point[img.Width * img.Height];
    int k = 0;
    for (int i = 0; i < img.Width; i++)
    {
        for (int j = 0; j < img.Height; j++)
        {
            Point p1 = new Point(i, j);
            p[k++] = p1;
        }
    }

    return hog.Compute(img, new Size(8, 8), new Size(0, 0), p);
}

如果将 GetVector 更改为:

public float[] GetVector(Image<Bgr, Byte> img)
        {
            HOGDescriptor hog = new HOGDescriptor();    // with defaults values

            return hog.Compute(img, new Size(8, 8), new Size(0, 0), null);
        }