我正在尝试从图像中提取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);
}
答案 0 :(得分:0)
如果您将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);
}