HOGDescriptor problem (debug assertion failed) [closed]
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.
Add your code. Probably some pointer or iterator mismatch issue but this cannot be solved without the code...
can you try to use the builtin load/save functions of the HOGDescriptor instead ? you might have gotten the protocol wrong.
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,