使用openCV查找图像轮廓

使用openCV查找图像轮廓

本文介绍了使用openCV查找图像轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我想跟踪物体的运动,我需要图像序列的轮廓。
有人知道,怎么办?
剪影遮罩是运动发生时具有非零像素的二进制图像

as i want to track motion of an object, i require silhouette of sequence of images.does anybody know , how to do this?Silhouette mask is a binary image that has non-zero pixels where the motion occurs

推荐答案

背景扣除。这里有两种方法。


  1. 从当前帧中减去上一帧。只有两个帧中未更改的像素都将为零。请参见,。

  2. 保持视频的连续平均帧。请参阅中部分的OpenCV文档。对于每个新帧,从当前帧中减去运行平均值。完成后,请使用当前框架更新移动平均值。

  1. Subtract the previous frame from the current frame. Only pixels in both frames that haven't changed will result in zero. See cvSub, cvAbsDiff.
  2. Maintain a running average of the video frames. See the function cvRunningAvg in the Motion Analysis and Object Tracking section of the OpenCV docs. For each new frame, subtract the running average from the current frame. When you're done, update the running average with the current frame.

使用上述方法之一后,使用或。这将产生一个二进制图像,理想情况下,图像是静态的0,以及存在运动的1或255.

After using one of the methods above, you could segment the resulting difference image using cvThreshold or cvAdaptiveThreshold. This will result in a binary image, ideally with zero where the image was static, and 1 or 255 where motion was present.

虽然你没有在问题,然后可以继续计算二值图像的轮廓。有。

Though you didn't mention this in your question, you can then proceed to calculate the contour of the binary image. There's cvFindContours for that.

这篇关于使用openCV查找图像轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 14:55