【发布时间】:2015-08-25 00:03:31
【问题描述】:
我想在 C# 中进行运动检测(使用 EmguCV 3.0)来移除运动中或前景中的对象以绘制叠加层。
这是我使用 Kinect 完成的示例测试(因为它是深度相机)
如何开始使用 EmguCV 3.0?
- 我尝试了许多不起作用的后台删除代码
- OpticalFlow 似乎是一个好的开始,但在 EmguCV 3.0 中没有示例
- 如果我找到最大的斑点,如何找到它的轮廓?
有人可以帮我开始吗?
编辑:2015 年 6 月 17 日
在 EmguCV3.0.0 RC 中,我在包和文档中看不到 OpticalFlow: http://www.emgu.com/wiki/files/3.0.0-rc1/document/html/b72c032d-59ae-c36f-5e00-12f8d621dfb8.htm
只有:DenseOpticalFlow、OpticalFlowDualTVL1 ???
这是一个 AbsDiff 代码:
var grayFrame = frame.Convert<Gray, Byte>();
var motionFrame = grayFrame.AbsDiff(backFrame)
.ThresholdBinary(new Gray(20), new Gray(255))
.Erode(2)
.Dilate(2);
结果:
我不知道如何让运动变成白色?
这是 Blob 代码:
Image<Bgr, Byte> smoothedFrame = new Image<Bgr, byte>(frame.Size);
CvInvoke.GaussianBlur(frame, smoothedFrame, new Size(3, 3), 1); //filter out noises
Mat forgroundMask = new Mat();
fgDetector.Apply(smoothedFrame, forgroundMask);
CvBlobs blobs = new CvBlobs();
blobDetector.Detect(forgroundMask.ToImage<Gray, byte>(), blobs);
blobs.FilterByArea(400, int.MaxValue);
blobTracker.Update(blobs, 1.0, 0, 1);
foreach (var pair in blobs) {
CvBlob b = pair.Value;
CvInvoke.Rectangle(frame, b.BoundingBox, new MCvScalar(255.0, 255.0, 255.0), 2);
}
结果:
为什么会有这么多误报?
这是 MOG2 代码:
forgroundDetector.Apply(frame, forgroundMask);
motionHistory.Update(forgroundMask);
var motionMask = GetMotionMask();
Image<Bgr, Byte> motionImage = new Image<Bgr, byte>(motionMask.Size);
CvInvoke.InsertChannel(motionMask, motionImage, 0);
Rectangle[] rects;
using (VectorOfRect boundingRect = new VectorOfRect()) {
motionHistory.GetMotionComponents(segMask, boundingRect);
rects = boundingRect.ToArray();
}
foreach (Rectangle comp in rects) { ...
结果:
如果我选择最大的区域,我怎样才能得到对象的轮廓?
【问题讨论】:
标签: c# computer-vision emgucv