保存opencv BackgroundSubtractorMOG到文件? [英] Save opencv BackgroundSubtractorMOG to file?

查看:84
本文介绍了保存opencv BackgroundSubtractorMOG到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将opencv用于车辆计数过程. 如何将我的BackgroundSubtractorMOG对象(例如BackgroundSubtractorMOG2等)保存到文件中,以便我可以从文件中读取它,再次使用经过训练的背景模型而无需长时间训练呢?

I use opencv for a vehicle counting process. How could I save my BackgroundSubtractorMOG object such as BackgroundSubtractorMOG2 etc to a file, so that I can read it from the file, use the trained background model again without training it for a long time?

推荐答案

我碰巧正在寻找这个确切的东西,所以如果有人还在寻找,我将只分享我学到的东西.似乎简短的答案是否定的.至少OpenCV似乎不支持它.

I happened to be searching for this exact thing, so I'll just share what I've learned, if someone else is still looking for it. It seems like the short answer is no. At least it does not seem to be supported by OpenCV.

BackgroundSubtractorMOG2继承自BackgroundSubtractor,BackgroundSubtractor继承自Algorithm,该算法具有用于存储算法参数的内置读写功能.根据 Algorithm :: write 上的OpenCV文档仅存储背景模型算法的参数,而不存储背景模型本身.从链接中引用:

BackgroundSubtractorMOG2 inherits from BackgroundSubtractor which inherits from Algorithm which has built in read/write functionality for storing parameters of the algorithms. According to the OpenCV doc on Algorithm::write it stores only the parameters for background model algorithms and not the background model itself. Quote from the link:

但是,没有存储背景模型.首先,它非常大.然后,如果您存储了背景模型,则在下一次运行中它可能变得无关紧要(因为相机移位,背景改变,照明不同等) .).因此,BackgroundSubtractorMOG和BackgroundSubtractorMOG2还依赖于标准Algorithm :: write()来仅存储算法参数."

"However, the background model is not stored. First, it’s rather big. Then, if you have stored the background model, it would likely become irrelevant on the next run (because of shifted camera, changed background, different lighting etc.). Therefore, BackgroundSubtractorMOG and BackgroundSubtractorMOG2 also rely on the standard Algorithm::write() to store just the algorithm parameters."

作为一个旁注,我完全不同意OpenCV,而且我不明白为什么他们会觉得有必要为我做出这个决定,并且如果看到目的的话,不只是让我保存背景模型.无论如何,如果别人知道如何存储背景模型或解决方法,这就是我所发现的:请分享.

As a side note I completely disagree with OpenCV, and I don't see why they feel the need to make this decision for me and not just allow me to save the background model if I see a purpose for it. Anyway, that's what I've found, if someone else knows how to store the background model or a workaround: please share.

这篇关于保存opencv BackgroundSubtractorMOG到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆