简体   繁体   English

视频中的OpenCV边界和相交检测

[英]OpenCV boundary and intersection detection in a video

I am obtaining a feed from my camera and an example frame from it looks as follows 我正在从相机获取一个提要,并且它的示例帧如下所示

http://imgur.com/Tv7fb

The frame consists of a boundary and a moving object. 框架由边界和运动对象组成。 I have the following questions. 我有以下问题。

1) How do I dynamically detect the boundary efficiently? 1)如何有效地动态检测边界? The boundary is guaranteed to be of a different color to the rest of the surroundings. 保证边界的颜色与周围的其他颜色不同。

2) How do I detect the boundary of the moving object efficiently? 2)如何有效检测运动物体的边界? It is guaranteed to be the only moving object in the frame. 保证它是框架中唯一的移动对象。

3) How do I determine an intersection between the boundary and the moving object? 3)如何确定边界与运动对象之间的交点? The boundary and object could be in any shape. 边界和对象可以是任何形状。

  1. Use segmentation techniques to find large areas of solid color. 使用分割技术查找大面积的纯色。 Choose, say, the largest solid color region as your boundary. 选择最大的纯色区域作为边界。 Or, use the Hough transform to find strong lines in the image, and identify the boundary. 或者,使用霍夫变换在图像中找到粗线,并确定边界。 Create a mask containing white pixels where your boundary region lies, black everywhere else. 创建一个包含白色像素的遮罩,该白色像素位于您的边界区域所在的位置,其他地方则为黑色。

  2. Use background subtraction . 使用背景减法 This can be done in a simple way by capturing a reference frame with no objects in the scene, and then just subtracting it from subsequent frames. 可以通过捕获场景中没有任何对象的参考帧,然后从后续帧中减去该参考帧,以一种简单的方式完成此操作。 Create a mask containing white pixels where your object is, black everywhere else. 在对象所在的位置创建一个包含白色像素的遮罩,在其他所有位置创建一个遮罩。

  3. Intersect the masks created in 1 and 2 with a per-element AND operation (or a per-element multiply). 每个元素的AND运算 (或每个元素的乘法)与在1和2中创建的蒙版相交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM