开发者

SiftDescriptorExtractor causes a memory leak

开发者 https://www.devze.com 2023-03-24 11:16 出处:网络
I am currently implementing SIFT to extract feature points from an image and noticed that I have a me开发者_StackOverflowmory leak when I get the descriptors. Is there anyway I can free the memory tha

I am currently implementing SIFT to extract feature points from an image and noticed that I have a me开发者_StackOverflowmory leak when I get the descriptors. Is there anyway I can free the memory that may be attached in the class?

EDIT Added more details to the code block

cv::SiftFeatureDetector* features = new cv::SiftFeatureDetector();
cv::SiftDescriptorExtractor* extractor = new cv::SiftDescriptorExtractor();

std::vector<cv::KeyPoint> KeyPoints;
cv::Mat Descriptors;

// Turn the image into a Mat
cv::Mat mImage = cv::Mat(iplImage);

printf("Searching for keypoints in: %s.\n", szName.c_str());

// Detect keypoints
features->detect(mImage, KeyPoints);

printf("Found %d keypoints.\n", KeyPoints.size());

// Extract descriptors
extractor->compute(mImage, KeyPoints, Descriptors);

printf("Found %d descriptors.\n\n", Descriptors.rows);

// Let my memory go!
delete extractor;
delete features;

Any advice is greatly appreciated. Thanks.


You are right. I just tested on Linux with OpenCV 2.3 and there's a memory leak on compute() indeed. This affects SiftDescriptorExtractor, and probably other types too, like SurfDescriptorExtractor, OrbDescriptorExtractor and BriefDescriptorExtractor.

By the way, don't forget to cvReleaseImage() the image you call iplImage at the end of this code.


Working with 2.3 too and also experience memory leaks with SiftDescriptorExtractor. However the other descriptor extractors does not have this issue. I suggest to create a ticket in the bugtracker to inform the developers.

0

精彩评论

暂无评论...
验证码 换一张
取 消