我尝试遵循该算法,但它不起作用。我不知道是什么问题。 有人可以帮我吗?
Where can I learn/find examples of gesture recognitions streamed from Kinect, using OpenCV?
Image<Gray, Byte> dest = new Image<Gray, Byte>(this.bitmap.Width, this.bitmap.Height);
CvInvoke.cvThreshold(src, dest, 220, 300, Emgu.CV.CvEnum.THRESH.CV_THRESH_BINARY);
Bitmap nem1 = new Bitmap(dest.Bitmap);
this.bitmap = nem1;
Graphics g = Graphics.FromImage(this.bitmap);
using (MemStorage storage = new MemStorage()) //allocate storage for contour approximation
{
for (Contour<Point> contours = dest.FindContours();
contours != null;
contours = contours.HNext)
{
g.DrawRectangle(new Pen(new SolidBrush(Color.Green)),contours.BoundingRectangle);
IntPtr seq = CvInvoke.cvConvexHull2(contours,storage.Ptr, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE, 0);
IntPtr defects = CvInvoke.cvConvexityDefects(contours, seq, storage);
Seq<Point> tr= contours.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
Seq<Emgu.CV.Structure.MCvConvexityDefect> te = contours.GetConvexityDefacts(storage, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
g.DrawRectangle(new Pen(new SolidBrush(Color.Green)), tr.BoundingRectangle);
}
}
最佳答案
没有一些图形数据就很难提供帮助(我也没有合适的硬件)。不管怎样,我建议你做两件事:
- 因为它是一个图形程序,调试所有内容,保存或显示任何中间步骤(阈值、轮廓、凸包)
- 改用更简单的方法。例如:
- 应用阈值(生成您的手的 0/1 图)
- 对于每一行,计算 0/1 转换
- 测试最大转换次数:即,如果超过 7,则双手打开
让我知道它是否有效:-)
关于c# - 检测张开的拳头和闭合的拳头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4802688/