Question

Below is some simple OpenCV code to create a frame from a video file and run the SURF feature detector and extractor on the frame. When I run this code on Linux and OSX it runs fine, however on windows I am getting a heap corruption error on the two commented lines.

VideoCapture capture(vidFilename.c_str());
Mat frame;
capture >> frame; 

SurfFeatureDetector *detector = new SurfFeatureDetector(minHessian);
vector<KeyPoint> frameKeypoints;
detector->detect(frame, frameKeypoints);
delete(detector); // Heap Corruption Detected

SurfDescriptorExtractor *extractor = new SurfDescriptorExtractor();
Mat frameDescriptors;
extractor->compute(frame, frameKeypoints, frameDescriptors);
delete(extractor); // Heap Corruption Detected

I have no clue what could cause this in the code. I am using VS 2010 to compile the code, is there something in VS that could cause this to happen?

Was it helpful?

Solution

As mentioned above that you do not get any exception related to heap corruption does not mean that it did not happen.There would be problem in your code and not in VS or compiler.My previous post on the similar article would be useful here as well.

https://stackoverflow.com/a/22074401/2724703

Probably you should also try to run some dynamic tool(Valgrind) on your linux. There is high possibility that, you would find the same bug using Valgrind as well.

These dynamic tools would give you the root cause of these problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top