HOGDescriptor problem (debug assertion failed) [closed]

asked 2014-07-23 04:42:52 -0600

ahmad gravatar image

updated 2014-07-23 07:38:30 -0600

Hi, I have an issue with the HOGDescriptor. I use the hog.setSVMDetector(detectorVector); command to assign a trained vector to HOG.

afterwards I use the hog.detectMultiScale(...); function to detect people in an image.

but after applying the detectMultiScale() function to a sequence and trying to start over again for a new sequence the program gives an assertion failure. It looks like that when the HOGDescriptor deconstructor is called the error is produced.

I get the following error in file dbgheap.c. Expression: _CtrIsValidHeapPointer(pUserData)

By the way, when I do not apply the detectMultiScale() function the error is gone.

What may be causing the problem and how can it be fixed?

I have a class named "Detectors" with a field: HOGDescriptor hog;

my code for initializing hog is:

void Detectors::readHOG(string trainedData, string filename)
{
    hog.winSize = Size(48,96);

    if (filename=="")
        filename = trainedData + "\\ConfigFiles\\HOG_Data.dat";
    else 
        filename = trainedData + filename;
    ifstream HOG_inputFile(filename, ios::in);
    int i=0;

    while (!HOG_inputFile.eof())
    {
        float input;
        HOG_inputFile >> input;
        hog.svmDetector.push_back(input);
        i++;
    }
    hog.svmDetector.pop_back();
    HOG_inputFile.close();

}

my code for detection is:

void Detectors::detectionFunction(Mat current, int detType, bool calcWeights, bool showImg, vector<double> &hogParams)
{   
Mat img;
img = current.clone();
currentFrame = img.clone();
clearPrevious(false, img);

if (detType == 0) // HOG type
{
if (showImg)
namedWindow("people detector", 1);

{
double t = (double)getTickCount();

hog.detectMultiScale(img, found, found_weights, hogParams[10], Size(4,4), Size(32,32), hogParams[8], hogParams[11]);    

...
}
}
}

the detectionFunction() is called in a loop for each frame read from the disk. after all the frames have been processed and when the program wants to finish this error is fired.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-06 23:23:47.462543

Comments

Add your code. Probably some pointer or iterator mismatch issue but this cannot be solved without the code...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-23 06:07:34 -0600 )edit
1

can you try to use the builtin load/save functions of the HOGDescriptor instead ? you might have gotten the protocol wrong.

berak gravatar imageberak ( 2014-07-23 08:00:31 -0600 )edit

I have use setSVMDetector for setting the feature vector but I had the same problem. I have found out also that when I clear the feature vector before applying any detection the program does not fire an error. hog.svmDetector.clear(); but when I apply this after only one detection an error occurs,

ahmad gravatar imageahmad ( 2014-07-23 23:13:29 -0600 )edit