- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想在 C# 中进行运动检测(使用 EmguCV 3.0)以移除运动中或前景中的对象以绘制叠加层。
这是我用 Kinect 完成的示例测试(因为它是深度相机)
如何开始使用 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);
结果:
我不知道如何获得白色的 Action ?
这是 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) { ...
结果:
如果我选择最大的区域,我怎样才能得到物体的轮廓?
最佳答案
首先,我可以给你一些示例光流代码。
让oldImage
和 newImage
是保存前一帧和当前帧的变量。在我的代码中,它的类型是 Image<Gray, Byte>
.
// prep containers for x and y vectors
Image<Gray, float> velx = new Image<Gray, float>(newImage.Size);
Image<Gray, float> vely = new Image<Gray, float>(newImage.Size);
// use the Horn and Schunck dense optical flow algorithm.
OpticalFlow.HS(oldImage, newImage, true, velx, vely, 0.1d, new MCvTermCriteria(100));
// color each pixel
Image<Hsv, Byte> coloredMotion = new Image<Hsv, Byte>(newImage.Size);
for (int i = 0; i < coloredMotion.Width; i++)
{
for (int j = 0; j < coloredMotion.Height; j++)
{
// Pull the relevant intensities from the velx and vely matrices
double velxHere = velx[j, i].Intensity;
double velyHere = vely[j, i].Intensity;
// Determine the color (i.e, the angle)
double degrees = Math.Atan(velyHere / velxHere) / Math.PI * 90 + 45;
if (velxHere < 0)
{
degrees += 90;
}
coloredMotion.Data[j, i, 0] = (Byte) degrees;
coloredMotion.Data[j, i, 1] = 255;
// Determine the intensity (i.e, the distance)
double intensity = Math.Sqrt(velxHere * velxHere + velyHere * velyHere) * 10;
coloredMotion.Data[j, i, 2] = (intensity > 255) ? 255 : intensity;
}
}
// coloredMotion is now an image that shows intensity of motion by lightness
// and direction by color.
关于如何移除前景这个更大的问题:
如果我有办法获得静态背景图像,那是最好的开始方式。然后,AbsDiff method 会检测到前景。并使用 Erode和 Dilate或 Gaussian平滑图像,然后使用 Blob 检测。
对于简单的前景检测,我发现 Optical Flow 处理太多(最大 8fps),而 AbsDiff 方法同样准确但对帧率没有影响。
关于轮廓,如果你只是想找到大小、位置和其他时刻,那么上面 AbsDiff 教程中的 Blob 检测似乎就足够了,它使用 Image.FindContours(...)
.
如果没有,我会开始查看 CvBlobDetector this tutorial 中使用的类.有一个内置的 DrawBlob 函数可能会派上用场。
关于c# - EmguCV:使用光流在运动中的物体上绘制轮廓?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30744432/
大家好,本文实现了相机碰撞检测,使相机不穿墙壁、物体,并给出了思路和代码,感谢大家~ 关键词:数字孪生、three.js、Web3D、WebGL、相机碰撞、游戏相机 我正在承接Web3D数字孪生项
我有一个大小为 12*30 的字符串的图像。我想创建一个动画,让它给人一种拉伸(stretch)字符串的感觉。我通过缩放图像来做到这一点,但我面临的问题是缩放图像没有发生碰撞。它仅出现在原始图像大小的
我的对象列表是如此初始化: $( function() { var $container = $('div.hikashop_products'); $container.isotop
我听说 swing 默认情况下是双缓冲的。我不想让 Swing 双缓冲。我正在使用双缓冲,我想添加一些 Swing 对象(现在只是添加到 JPanel 中的 JButton,然后再添加到 JFrame
几天来我一直在思考最好的解决方案,但似乎无法找到正确的想法。 我有一 block (物体),我想将它们放入尽可能小的空间中。我最终寻找的是这样的东西 http://i.stack.imgur.com/
我的纹理不仅仅是一个盒子或圆形,我的 body 需要与这个形状相同,所以我想结合多个 body 来达到我想要的形状,这甚至可能吗?或者有更好的方法吗?我正在使用带有 libgdx 框架的 java。
我遇到的情况是,我有很多计算机并且需要有唯一的 ID。 他们会通过 API 请求发送其 uniqueId。该对象看起来像 class ID { long timestamp; int id; }
我正在尝试检测一张卡片,但问题是有时图像不好并且有多个背景,如下所示: 没有很好地定义边缘 ![没有很好地定义边缘][1] 示例背景 ![示例背景][2] 我这样做了: gray = cv2.cvtC
我正在尝试从仅包含一辆车和简单背景的图像中分割汽车,如 但是我从我的实现中得到的是这个 和 分别 但它非常容易处理几乎已经分割的图像,例如。 给出类似 的结果 我使用的代码是 import cv2 i
我正在开发一个项目,在该项目中我从另一个对象/函数中引用一个变量。然而我总是返回 false。我不确定我是否正确调用它。 这是验证函数: app.validation = function(){
数组只是伪装的对象吗?为什么/为什么不呢?他们以什么方式(这样/不是)? 我一直认为 JS 中的数组和对象本质上是相同的,主要是因为访问它们是相同的。 var obj = {'I': 'me'}; v
我正在使用 PlayN 构建一个涉及石头的游戏,用户必须在物理世界中移动(通过重力等)。我希望用户能够使用触摸板直接操纵石头,并通过以下方式给它们一个速度拖拽并扔掷它们。 现在我有一个实现,其中每个石
http://jsfiddle.net/goldrunt/jGL84/42/这是来自这个 JS fiddle 的第 84 行。通过取消注释第 141-146 行,可以对球应用 3 种不同的效果。 'b
我学习Linux平台下的OpenGL。最近,我尝试使用 glutBitmapCharacter() 创建的文本作为 glu 或 glut 提供的一些二次对象的纹理。但是,glutBitmapChara
我正在使用 AndEngine 创建一个带有 box2d 扩展名的游戏。我想实现一个条件,当两个物体碰撞时,它们应该被移除或重生。最初我尝试使用 if(sprite1.collidesWith(spr
我制作了一个小型 3d 引擎。 但我在旋转功能方面遇到了一些问题。它们使物体不时拉伸(stretch)。这是数学: this.rotateX = function(angle) { var c
我在 Canvas 上制作了一个矩形 mask ,我需要 mask 外的任何东西都具有 0.8 的不透明度,因此 mask 外的所有对象都被视为不透明请看一下 fiddle 。 http://jsfi
我是 Direct3D 的新手,我在一个项目中从网络摄像头拍照并在它前面绘制一些 3D 对象。 我能够使用正交投影将网络摄像头图像渲染为背景。 //init matrix D3DXMatri
我是一名优秀的程序员,十分优秀!