Some questions when using HogDescriptor in OpenCv3.0 under Visual studio 2012

I want to use HOGDescriptor of OpenCv3.0 under VS2012.And my codes is flows:

    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”

I examine the codes many times, and don't why.

Please help me. Thank you.

Answers


You are using incorrect types in your code.

As per documentation (Openc 3.0 docs) your featureVec has to be vector of Points. Not vector of floats.

Relevant part of docs:

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

So in your code try following:

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

It interesting that the code event compile, if the types don't match.


Try to run HoG.compute(img,featureVec) with default parameters, i.e. don't give window sizes when declaring your HOG variable. It sounds like a parameter is wrong ...

Detect is a different method, so the call is correct


Need Your Help

How to send out a http reponse

php apache httpresponse

I am a php newbie and I came across some problems when use php with apache.