SiftDescriptorExtractor 导致内存泄漏

发布于 2024-11-27 19:09:12 字数 801 浏览 1 评论 0原文

我目前正在实施 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无名指的心愿 2024-12-04 19:09:12

你是对的。我刚刚在 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 call iplImage at the end of this code.

段念尘 2024-12-04 19:09:12

使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文