C# Kinect Drawing Point Over Tracked Hand -


i have following code:

if (frame != null)                 {                     canvas.children.clear();                     _bodies = new body[frame.bodyframesource.bodycount];                      frame.getandrefreshbodydata(_bodies);                      foreach (var body in _bodies)                     {                          if (body != null)                         {                             if (body.istracked)                             {                                 // choose hand track                                 string whichhand = "right"; //change "left" in order track left hand                                 joint handright = body.joints[jointtype.handright];                                   if (whichhand.equals("right"))                                 {                                      string righthandstate = "-"; //find right hand state                                      switch (body.handrightstate)                                     {                                         case handstate.open:                                             righthandstate = "open";                                             break;                                         case handstate.closed:                                             righthandstate = "closed";                                             break;                                         default:                                             break;                                     }                                     canvas.drawpoint(handright, _sensor.coordinatemapper);                                 } 

here drawpoint code:

public static void drawpoint(this canvas canvas, joint joint, coordinatemapper mapper) {     if (joint.trackingstate == trackingstate.nottracked) return;      point point = joint.scale(mapper);      ellipse ellipse = new ellipse     {         width = 20,         height = 20,         fill = new solidcolorbrush(colors.lightblue)     };      canvas.setleft(ellipse, point.x - ellipse.width / 2);     canvas.settop(ellipse, point.y - ellipse.height / 2);      canvas.children.add(ellipse); } 

and scale:

public static point scale(this joint joint, coordinatemapper mapper) {     point point = new point();      colorspacepoint colorpoint = mapper.mapcamerapointtocolorspace(joint.position);     point.x *= float.isinfinity(colorpoint.x) ? 0.0 : colorpoint.x;     point.y *= float.isinfinity(colorpoint.y) ? 0.0 : colorpoint.y;      return point; } 

the problem have while circle drawn, not drawn on hand. instead stays in top left corner (0,0), i'm guessing it's not getting updated properly. tell me going on or problem is? in center of hand (which being tracked fine because state of hand gets updated immediately) , follow hand move it.

the _sensor kinect sensor.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -