OpenCV:检测视频源中的闪烁灯光
我有一个视频源。该视频源包含多个以不同速率闪烁的灯。所有灯的颜色相同(均为红外 LED)。如何检测这些闪烁灯的位置和频率?
免责声明:我对 OpenCV 非常陌生。我确实有一本学习 OpenCV,但我发现它有点让人不知所措。如果有人能用 OpenCV 术语解释解决方案,我们将不胜感激。我不希望有人为我编写代码。
I have a video feed. This video feed contains several lights blinking at different rates. All lights are the same color (they are all infrared LEDs). How can I detect the position and frequency of these blinking lights?
Disclaimer: I am extremely new to OpenCV. I do have a copy of Learning OpenCV, but I am finding it a bit overwhelming. If anyone could explain a solution in OpenCV terminology, it would be greatly appreciated. I am not expecting code to be written for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用使 LED 可见的阈值对序列中的每个图像进行阈值设置。如果您可以使用仅保留 LED 并删除背景的阈值,那么您或多或少已经完成,因为您现在需要做的就是跟踪看到 LED 的每个位置,并且计算它发生的频率。
作为中间步骤,如果阈值图像中存在“背景噪声”,则可以使用腐蚀来消除小错误,然后可能会扩张以“闭合您真正感兴趣的斑点中的孔”。
如果场景是静态的,您还可以通过取几帧的中值并从任何帧和阈值中删除所得的中值图像来制作一个简单的背景模型。发生变化的东西(你的 LED)会显得更强。
如果场景在移动,除了确保 LED 足够亮以能够使用上面给出的阈值方法之外,我看不到其他(简单)解决方案。
至于 OpenCV:如果你知道你想做什么,那么找到一个能做到这一点的函数并不难。困难的部分是提出解决问题的方法,而不是实际的编码。
Threshold each image in the sequence with a threshold that makes the LED:s visible. If you can threshold it with a threshold that only keeps the LED and removes background then you are more or less finished since all you need to do now is to keep track of each position that has seen a LED and count how often it occurs.
As a middle step, if there is "background noise" in the thresholded image would be to use erosion to remove small mistakes, and then maybe dilate to "close holes" in the blobs you are actually interested in.
If the scene is static you could also make a simple background model by taking the median of a few frames and removing the resulting median image from any frame and threshold that. Stuff that has changed (your LEDs) will appear stronger.
If the scene is moving I see no other (easy) solution than making sure the LED are bright enough to be able to use the threshold approach given above.
As for OpenCV: if you know what you want to do, it is not very hard to find a function that does it. The hard part is coming up with a method to solve the problem, not the actual coding.
如果 LED 是静止的,则问题比它们移动时要简单得多。假设它们是静止的,找到频率的解决方案可以简单地为每个像素位置保留一个向量或数组,在其中存储该像素的值,最好是在 kigurai 描述的预处理之后,在某个时间范围内。然后,您可以计算这些值向量的一维傅里叶变换,并找到地面频率作为直流峰值后的第一个重要分量。如果直流峰值太低,则说明那里没有 LED。
希望这个问题仍然有点实际,并且我的解决方案有意义。
If the leds are stationary, the problem is far simpler than when they are moving. Assuming they are stationary, a solution to find the frequency could simply be to keep a vector or an array for each pixel location in which you store the values of that pixel, preferably after the preprocessing described by kigurai, over some timeframe. You can then compute the 1D fourier transform of those value vectors and find the ground frequency as the first significant component after the DC peak. If the DC peak is too low, it means there is no led there.
Hope this problem is still somewhat actual, and that my solution makes sense.