C++ HOG描述符中的错误

C++ HOG描述符中的错误,c++,opencv,image-processing,C++,Opencv,Image Processing,我正在使用HOG描述符进行特征提取。我使用的是visual studio 2012和opencv 2.4.9版本。我在hog.compute函数中遇到运行时错误 int main() { Mat img_raw = imread("p1.jpg", 1); // load as color image. Mat img; cvtColor(img_raw, img, CV_RGB2GRAY); HOGDescriptor hog; ve

我正在使用HOG描述符进行特征提取。我使用的是visual studio 2012和opencv 2.4.9版本。我在hog.compute函数中遇到运行时错误

int main()
{
     Mat img_raw = imread("p1.jpg", 1); // load as color image.    
     Mat img;
     cvtColor(img_raw, img, CV_RGB2GRAY);

     HOGDescriptor hog;
     vector<float> descriptor;
     vector<Point>locations;

     hog.compute(img, descriptor,Size(32,32),Size(0,0),locations);   

     cout << "HOG descriptor size is " << hog.getDescriptorSize() << endl;
     cout << "img dimensions: " << img.cols << " width x " << img.rows <<     "height" << endl;
     cout << "Found " << descriptor.size() << " descriptor values" << endl;
     cout << "Nr of locations specified : " << locations.size() << endl;
     return 0;

}

Plz还包括运行时错误,所以我们可以更好地解决这个问题。另外,请注意OpenCv会将彩色图像加载为BGR,所以您应该使用CV_BGR2GRAY,尽管它可能不会有太大的区别。。。我做了关于BGR的更改,但我有相同的错误,错误是未处理的异常,位于HOG.exe中的0x00007FFDA4224E7B msvcr110d.dll处:0xC000005:访问冲突读取位置0xFFFFFFFFFFFFFFFFFFFFFFFFF通过添加此文件opencv_features2d249d.lib,我得到了正确的输出。谢谢大家。