SiftDescriptorExtractor 导致内存泄漏
我目前正在实施 SIFT 从图像中提取特征点,并注意到在获取描述符时出现内存泄漏。无论如何,我可以释放课堂上可能附加的内存吗?
编辑 向代码块添加了更多详细信息
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;
非常感谢任何建议。谢谢。
I am currently implementing SIFT to extract feature points from an image and noticed that I have a memory 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你是对的。我刚刚在 Linux 上使用 OpenCV 2.3 进行了测试,
compute()
确实存在内存泄漏。这会影响 SiftDescriptorExtractor,也可能影响其他类型,例如 SurfDescriptorExtractor、OrbDescriptorExtractor 和 BriefDescriptorExtractor。顺便说一句,不要忘记
cvReleaseImage()
在此代码末尾调用iplImage
的图像。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 calliplImage
at the end of this code.使用 2.3 时也遇到了 SiftDescriptorExtractor 的内存泄漏问题。
然而其他描述符提取器不存在这个问题。
我建议在错误跟踪器中创建一个票证以通知开发人员。
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.