Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.96 KB  |  hits: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Kinect Custom Cursor
  2. using Microsoft.Research.Kinect.Nui;
  3.  
  4. Runtime nui = Runtime.Kinects[0];
  5. nui.Initialize(RuntimeOptions.UseSkeletalTracking);
  6. nui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady);
  7.  
  8. void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
  9. {
  10.     SkeletonFrame sf = e.SkeletonFrame;
  11.     SkeletonData d = (from s in sf.Skeletons
  12.                       where s.TrackingState == SkeletonTrackingState.Tracked
  13.                       select s).FirstOrDefault();
  14.  
  15.      if (d != null)
  16.      {
  17.           SetHandPosition(imageCursor, d.Joints[JointID.HandLeft]);
  18.      }
  19. }
  20.  
  21. void SetHandPosition(FrameworkElement e, Joint joint)
  22. {
  23.     Joint scaledJoint = Coding4Fun.Kinect.Wpf.SkeletalExtensions.ScaleTo(joint, 600, 400, 0.75f, 0.75f);
  24.  
  25.     Canvas.SetLeft(e, scaledJoint.Position.X);
  26.     Canvas.SetTop(e, scaledJoint.Position.Y);
  27. }
  28.        
  29. private void button1_MouseEnter(object sender, MouseEventArgs e)
  30. {
  31. ....        
  32. }