1 | initial version |
I have had a similar issue that might be related to yours. I was trying to run the sample Chmafer matching code from OpenCV (/trunk/opencv/samples/cpp/chamfer.cpp) and I would get the following error:
* glibc detected :double free or corruption (!prev): 0x0000000000745bb0 **
The reason is that in function chamerMatching(img, tpl, results, costs)
a template is created and then a reference to it is added inside matcher_
object:
ChamferMatcher::Template template_(templ, (float)templScale);
ChamferMatcher::Matches match_instances = matcher_.matching(template_, img);
As a result when the function returns template_
is destroyed first and then when matcher_
is destroyed it tries to destroy the same template again hence you gen an error.
A quick fix to it is to modify the destructor of Matching()
and to comment out the line that deletes templates.
~Matching()
{
for (size_t i = 0; i<templates.size(); i++) {
//delete templates[i];
}
}
Note, however, that this solution is just a hack that I used to get the demo working. There might be other ways templates can be added to Matching
object and those need to be deleted otherwise you will get memory leak.