使用 EMGU CV C# 中的 HOGDescriptor 获取图像的 HOG 描述符

Mir*_*san 2 c# pattern-recognition image-processing emgucv

如何使用 EMGU CV 和 C# 计算图像的 hog 描述符向量。

如果我做这样的事情:

float[] f;
Image<Bgr, Byte> img1 = new Image<Bgr, Byte>(fullPath);

f = hog.Compute(img1, Size.Empty, Size.Empty,null );
Run Code Online (Sandbox Code Playgroud)

它不起作用,它给出了

你调用的对象是空的。

例外。我想用默认参数计算 hog 描述符。

有人知道该怎么做吗?

Emgu 简历的记录非常少。

我已经修改了代码,现在收到以下错误:“外部组件引发了异常”下面列出了代码

public float[] GetVector(Image<Bgr, Byte> im)
    {
        HOGDescriptor hog = new HOGDescriptor();    // with defaults values
       // Image<Bgr, Byte> pImage = new Image<Bgr, Byte>(;
       //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 < im.Width; i++)
        {
            for (int j = 0; j < 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);
    }
Run Code Online (Sandbox Code Playgroud)

Mir*_*san 5

他的回答仅供记录:

public Image<Bgr, Byte> Resize(Image<Bgr, Byte> im)
        {
            return im.Resize(64, 128, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR);
        }
        public float[] GetVector(Image<Bgr, Byte> im)
        {
            HOGDescriptor hog = new HOGDescriptor();    // with defaults values
            Image<Bgr, Byte> imageOfInterest = Resize(im);
            Point[] p = new Point[imageOfInterest.Width * imageOfInterest.Height];
            int k = 0;
            for (int i = 0; i < imageOfInterest.Width; i++)
            {
                for (int j = 0; j < imageOfInterest.Height; j++)
                {
                    Point p1 = new Point(i, j);
                    p[k++] = p1;
                }
            }

            return hog.Compute(imageOfInterest, new Size(8, 8), new Size(0, 0), p);
        }
Run Code Online (Sandbox Code Playgroud)

如果其他人需要它:)