2015-04-06 24 views
0

我想用OpenCv3.0的HOGDescriptor下VS2012.And我的代码是流向:一些问题在OpenCv3.0 2012

cv::Mat img=cv::imread("D:\\pictures\\1.bmp"; 

    if(img.data==NULL) 

    { 

     cout<<"load pictures error"<<endl; 

    } 

    if(img.cols!=hog.winSize.width||img.rows!=hog.winSize.height) 

    { 

     count<<"the size of pictures is wrong"<<endl; 

    } 

    cv::HOGDescriptor; 

    hog(cv::Size(64,64),cv::Size(16,16),cv::Size(8,8),cv::Size(8,8),9); 

    vector<float> featureVec; 

    hog.compute(img,featureVec); 

//fails,"Access error occurred while writing position 0 x00477218” 

我检查代码很多次,和唐为什么。

请帮帮我。谢谢。

回答

0

您在代码中使用了不正确的类型。

根据文档(Openc 3.0 docs),您的featureVec必须是点的向量。不是花车矢量。文档的

相关部分:

virtual void cv::HOGDescriptor::detect ( const Mat &  img, 
     std::vector<Point> &  foundLocations, 
     double  hitThreshold = 0, 
     Size winStride = Size(), 
     Size padding = Size(), 
     const std::vector<Point> & searchLocations = std::vector<Point>() 
    )  const 
在你的代码尝试

所以以下:

vector<cv::Point> featureVec; 
hog.compute(img,featureVec); 

有趣的是,该代码编译时,如果类型不匹配。

0

尝试使用默认参数运行HoG.compute(img,featureVec),即在声明HOG变量时不提供窗口大小。这听起来像一个参数是错误的...

检测是一种不同的方法,所以电话是正确的