【问题标题】:Taking the HOG descriptor of an image using HOGDescriptor from EMGU CV C#使用来自 EMGU CV C# 的 HOGDescriptor 获取图像的 HOG 描述符
【发布时间】:2013-12-28 03:59:38
【问题描述】:

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

如果我做这样的事情:

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

f = hog.Compute(img1, Size.Empty, Size.Empty,null );

它不起作用,它给出了一个

对象引用未设置为对象的实例。

异常。我想用默认参数计算 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);
    }

【问题讨论】:

  • 究竟在哪一行?调试你的代码,看看null是什么。
  • f = hog.Compute(img1, Size.Empty, Size.Empty,null );在这个上;他们在函数文档中说,如果你不需要计算位置,你可以让它为空。我不需要位置我想为所有图像计算 hog 描述符,而不仅仅是部分(某些位置)
  • 仅作记录-我在堆栈溢出时看到了与此类似的问题,但没有人能够解决它。 EMGU CV 的文档记录很差
  • 我已经修改了代码,现在我收到以下错误:“外部组件已引发异常”代码如下所示

标签: c# image-processing emgucv pattern-recognition


【解决方案1】:

为了记录,他的回答是:

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);
        }

如果其他人需要它:)

【讨论】:

  • 为什么调整大小应该总是宽度小于高度?
猜你喜欢
  • 2015-02-17
  • 1970-01-01
  • 1970-01-01
  • 2017-12-24
  • 2016-02-26
  • 2017-01-14
  • 2020-04-09
  • 2014-04-12
  • 1970-01-01
相关资源
最近更新 更多