/// <summary> /// The skeleton data, the color image data, and the depth data are based on different /// coordinate systems. To show consistent images from all three streams in the sample’s /// display window, we need to convert coordinates in skeleton space to image space by /// following steps /// /// </summary> /// <param name="joint">Joint to get coordinates for</param> /// <returns>CCR Iterator</returns> private IEnumerator <ITask> JointToPointCoordinates(Joint joint) { int colorX = 0; int colorY = 0; kinectProxy.SkeletonToColorImageRequest request = new kinectProxy.SkeletonToColorImageRequest(); request.SkeletonVector = joint.Position; yield return(this.kinectPort.SkeletonToColorImage(request).Choice( SkeletonToColorImageResponse => { colorX = SkeletonToColorImageResponse.X; colorY = SkeletonToColorImageResponse.Y; }, failure => { // high freq call - no logging })); // Clip the values colorX = Math.Min(colorX, KinectUI.ColorImageWidth); colorY = Math.Min(colorY, KinectUI.ColorImageHeight); // Scale the color image coordinates to the size of the skeleton display on the screen this.cachedJointPoint = new Point( ((KinectUI.DisplayWindowWidth * colorX) / KinectUI.ColorImageWidth), ((KinectUI.DisplayWindowHeight * colorY) / KinectUI.ColorImageHeight)); }
/// <summary> /// The skeleton data, the color image data, and the depth data are based on different /// coordinate systems. To show consistent images from all three streams in the sample’s /// display window, we need to convert coordinates in skeleton space to image space by /// following steps /// </summary> /// <param name="joint">Joint to get coordinates for</param> /// <returns>CCR Iterator</returns> private IEnumerator<ITask> JointToPointCoordinates(Joint joint) { int colorX = 0; int colorY = 0; kinectProxy.SkeletonToColorImageRequest request = new kinectProxy.SkeletonToColorImageRequest(); request.SkeletonVector = joint.Position; yield return this.kinectPort.SkeletonToColorImage(request).Choice( SkeletonToColorImageResponse => { colorX = SkeletonToColorImageResponse.X; colorY = SkeletonToColorImageResponse.Y; }, failure => { // high freq call - no logging }); // Clip the values colorX = Math.Min(colorX, KinectUI.ColorImageWidth); colorY = Math.Min(colorY, KinectUI.ColorImageHeight); // Scale the color image coordinates to the size of the skeleton display on the screen this.cachedJointPoint = new Point( ((KinectUI.DisplayWindowWidth * colorX) / KinectUI.ColorImageWidth), ((KinectUI.DisplayWindowHeight * colorY) / KinectUI.ColorImageHeight)); }