JoseleMG
JoseleMG

Reputation: 302

Exception KernelBase.dll

I am using Visual Studio 2010, with OpenCV 3.0.

The following code tries to extract the HOG features in order to train a SVM classificator. However, when I try to use the HOG's function "compute" in the line

hog.compute(grayImg,descriptor,Size(),Size(),positions);

The following error appears:

Unhandled exception in 0x000007fefd9bb16d (KernelBase.dll) in TrainSVM.exe: Exception de Microsoft C++: cv::Exception at memory location 0x0026e1b0.

            String imagesPath = "Positivas/*.jpg"; 
            vector<String> fn;
            glob(imagesPath, fn, true); // recursive, if you want
            for (size_t i=0; i<fn.size(); i++)
            {
                Mat img = imread(fn[i]);     
                std::vector<cv::Point> positions;
                positions.push_back(cv::Point(0,0));
                std::vector<float> descriptor;
                cv::Mat grayImg;//(patchHeight,patchWidth,CV_8UC1,0);
                cvtColor( img, grayImg, COLOR_BGR2GRAY );
                hog.compute(grayImg,descriptor,Size(),Size(),positions);

                Mat auxDescriptor = cv::Mat(descriptor);
                Mat descriptorMat(1,auxDescriptor.rows,CV_32FC1);
                transpose(auxDescriptor, descriptorMat);
                trainingData.push_back(descriptorMat);
                trainingLabels.push_back(labelPositive);

            }

Any thoughts on this? Thanks in advance!

Upvotes: 1

Views: 3288

Answers (1)

SSteve
SSteve

Reputation: 10728

After getting the exception message we found there was an assertion failing in the call to alignSize. The documentation for alignSize requires a parameter to be a power of two. From there, we looked at the documentation for hog.compute and found that it requires a window size that is a power of two.

Upvotes: 2

Related Questions