正确处理 EMGU 中的图像
我使用 EMGU(opencv 包装器)进行图像处理。我想从文件夹中一张一张地加载图像来对它们执行一些操作。我使用以下代码,并在 using 块中执行一些操作。
string[] filenames = Directory.GetFiles(directory);
foreach(string filename in filenames)
{
using (Image<Bgr, Byte> image = new Image<Bgr, byte>(filename))
{
}
}
然而,当我运行代码时,应用程序使用越来越多的内存块,直到我收到一些有关寻址或内存不足的异常。
有什么建议吗?
Im using EMGU (opencv wrapper) for image processing. I want to load images one by one from a folder to perform some operations on them. I use the following code and would do some operations in the using block.
string[] filenames = Directory.GetFiles(directory);
foreach(string filename in filenames)
{
using (Image<Bgr, Byte> image = new Image<Bgr, byte>(filename))
{
}
}
However, when I run the code the application uses a growing chunk of memory till I get some exception regarding addressing or being out of memory.
Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码看起来不错。我的猜测是您对每个图像执行的一个或多个操作正在分配未清理的图像副本。
This code looks fine. My guess would be one or more of the operations you are performing for each image is allocating a copy of the image that's not being cleaned up.