OpenCV持久对象跟踪和滞后策略
我正在为我的团队构建一个对象跟踪 API。
我的代码将识别相机场景中的前景物体。随着时间的推移,它将在实例上调用 addObject(id, pos)
、updateObject(id, newPos)
和 removeObject(id)
方法实现我的监听器接口。这些是帧处理后事件——因此它们可能每秒发生 30 次。
如何确保对象不会闪烁出现或消失?我需要给对象一个最短的生命周期。如果某个对象在一帧中消失,并以新 ID 重新出现在下一帧中的同一位置,这也是不受欢迎的闪烁。
(到目前为止我的想法)我考虑过使用对象掩码累加器作为实例化的基础。我想象一个灰度图像,其中对象的候选区域将在每一帧的累加器中增强,然后一旦对象区域超过阈值,它就会被实例化,我们调用 addObject(id, pos) 方法。现在的问题是,对象可以悬停在累加器中的阈值附近,并且仍然可以表现出闪烁行为。那么,一旦实例化对象区域,我就会向它添加一些常量值,以便它在累加器中具有生命周期。当该区域低于累加器阈值时,将减去该常数。
I'm building an object tracking API for my team.
My code will recognize foreground objects in the camera scene. Over time, it will call methods for addObject(id, pos)
, updateObject(id, newPos)
, and removeObject(id)
on instances that implement my listener interface. These are post frame-processing events -- so they might occur 30 times a second.
How can I make sure that objects don't flicker in and out of existence? I need to give objects a minimum lifetime. If an object disappears for one frame and reappears in the same spot in the next frame with a new ID, that is also undesired flickering.
(My thoughts so far) I have thought about using an object mask accumulator as a basis for instantiation. I imagine a grayscale image, where candidate regions for objects would be intensified in the accumulator each frame, then as soon as an object region exceeds a threshold, it gets instantiated and we call the addObject(id, pos)
method. Now, the problem with this is, an object can hover around the threshold in the accumulator and can still exhibit flickery behavior. So then, I would add some constant value to the object region as soon as it is instantiated so that it would have a lifetime in the accumulator. This constant would be subtracted when the region crosses below the accumulator threshold.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终使用了我的问题中描述的解决方案,几乎没有任何进一步的调整。它对我正在做的事情效果很好。不过,有必要保留先前累加器状态的副本,以确定像素值是上升还是下降超过阈值。
I ended up using the solution described in my question, almost without any further tweaks. It worked well for what I was doing. It is necessary to keep a copy of the previous accumulator state, though, to determine whether the pixel values are rising or falling across the threshold value.