3

I tried following the algorithm but it does not work. I can't figure what is the problem. Can somebody help me?

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);
    }
}
Community
  • 1
  • 1
Rikki
  • 55
  • 3

1 Answers1

0

Without having some graphical data it's hard to help (I'm also without proper hardware). Anyway, I suggest you two things:

  • since it's a graphical procedure, debug everything saving or showing any intermediate step (threshold, contours, convexhull)
  • change to a simpler approach. For example:
    1. apply a threshold (resulting in a 0/1 map of your hands)
    2. for each row, count 0/1 transitions
    3. test the maximum number of transitions: i.e., if it's above 7, hands are open

Let me know if it works :-)

Sga
  • 3,608
  • 2
  • 36
  • 47