使用EMGU CV C#中的HOGDescriptor获取图像的HOG描述符 [英] Taking the HOG descriptor of an image using HOGDescriptor from EMGU CV C#
本文介绍了使用EMGU CV C#中的HOGDescriptor获取图像的HOG描述符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用EMGU CV和C#计算图像的猪描述符向量。
How can I compute the hog descriptor vector of an image using EMGU CV and C#.
如果我做这样的事情:
float[] f;
Image<Bgr, Byte> img1 = new Image<Bgr, Byte>(fullPath);
f = hog.Compute(img1, Size.Empty, Size.Empty,null );
它不起作用,它给出了
对象引用未设置为对象的实例。
Object reference not set to an instance of an object.
异常。我想用默认参数计算猪的描述符。
exception. I want to compute the hog descriptor with default parameters.
有人知道怎么做吗?
Emgu cv记录很差。
Emgu cv is very poorly documented.
我修改了代码,现在我收到以下错误:外部组件抛出异常代码列在下面
I have modified the code and now I am getting the following error: "External component has thrown an exception" The code is listed below
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);
}
推荐答案
这里的记录是答案:
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);
}
如果其他人需要它:)
这篇关于使用EMGU CV C#中的HOGDescriptor获取图像的HOG描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文