} } if ((y - Ultimoy) > Par_) { this.YMais.Visibility =Visibility.Visible; Ultimoy = y; Valor += 4; } else { if ((y - Ultimoy) < -Par_) { this.YMenos.Visibility =Visibility.Visible; Ultimoy = y; Valor += 8; } else { this.YMais.Visibility =Visibility.Hidden; this.YMenos.Visibility =Visibility.Hidden; } } if ((z - Ultimoz) > Par_) { this.ZMais.Visibility =Visibility.Visible; Ultimoz = z; Valor += 16; } else { if ((z - Ultimoz) < -Par_) { this.ZMenos.Visibility =Visibility.Visible; Ultimoz = z; Valor += 32; } else { this.ZMais.Visibility =Visibility.Hidden; this.ZMenos.Visibility =Visibility.Hidden; } } Paralela.Escrever(Convert.ToInt32("0378",16), Convert.ToByte(Valor)); Thread.Sleep(200); } private Point getDisplayPosition(Jointjoint) { float depthX, depthY; nui.SkeletonEngine.SkeletonToDepthImage(joint.Position, out depthX, outdepthY); depthX = depthX * 320; //convert to320, 240 space depthY = depthY * 240; //convert to320, 240 space int colorX, colorY; ImageViewArea iv = newImageViewArea(); // onlyImageResolution.Resolution640x480 is supported at this point nui.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(ImageResolution.Resolution640x480,iv, (int)depthX, (int)depthY, (short)0, out colorX, out colorY); // map back to skeleton.Width &skeleton.Height) return newPoint((int)(skeleton.Width * colorX / 640.0), (int)(skeleton.Height * colorY /480)); } PolylinegetBodySegment(Microsoft.Research.Kinect.Nui.JointsCollection joints, Brushbrush, params JointID[] ids) { PointCollection points = newPointCollection(ids.Length); //for (int i = 0; i <ids.Length; ++i ) //{ var jtme =joints[JointID.HandRight]; points.Add(getDisplayPosition(jtme)); jtme = joints[JointID.ElbowRight]; points.Add(getDisplayPosition(jtme)); jtme =joints[JointID.ShoulderRight]; points.Add(getDisplayPosition(jtme)); jtme = joints[JointID.HipRight]; points.Add(getDisplayPosition(jtme)); //} Polyline polyline = new Polyline(); polyline.Points = points; polyline.Stroke = brush; polyline.StrokeThickness = 5; return polyline; } void nui_SkeletonFrameReady(objectsender, SkeletonFrameReadyEventArgs e) { SkeletonFrame skeletonFrame =e.SkeletonFrame; int iSkeleton = 0; Brush[] brushes = new Brush[6]; brushes[0] = newSolidColorBrush(Color.FromRgb(255, 0, 0)); brushes[1] = newSolidColorBrush(Color.FromRgb(0, 255, 0)); brushes[2] = newSolidColorBrush(Color.FromRgb(64, 255, 255)); brushes[3] = newSolidColorBrush(Color.FromRgb(255, 255, 64)); brushes[4] = newSolidColorBrush(Color.FromRgb(255, 64, 255)); brushes[5] = newSolidColorBrush(Color.FromRgb(128, 128, 255)); skeleton.Children.Clear(); foreach (SkeletonData data inskeletonFrame.Skeletons) { if(SkeletonTrackingState.Tracked == data.TrackingState) { Brush brush =brushes[iSkeleton % brushes.Length]; skeleton.Children.Add(getBodySegment(data.Joints,brush, JointID.HipCenter, JointID.Spine, JointID.ShoulderCenter,JointID.Head)); skeleton.Children.Add(getBodySegment(data.Joints, brush,JointID.ShoulderCenter, JointID.ShoulderLeft, JointID.ElbowLeft, JointID.WristLeft,JointID.HandLeft)); skeleton.Children.Add(getBodySegment(data.Joints, brush,JointID.ShoulderCenter, JointID.ShoulderRight, JointID.ElbowRight,JointID.WristRight, JointID.HandRight)); skeleton.Children.Add(getBodySegment(data.Joints,brush, JointID.HipCenter, JointID.HipLeft, JointID.KneeLeft, JointID.AnkleLeft,JointID.FootLeft)); skeleton.Children.Add(getBodySegment(data.Joints, brush,JointID.HipCenter, JointID.HipRight, JointID.KneeRight, JointID.AnkleRight,JointID.FootRight)); foreach (Joint joint indata.Joints) { if ((joint.ID ==JointID.HandRight) || (joint.ID ==JointID.ElbowRight) || (joint.ID ==JointID.HipRight) || (joint.ID ==JointID.ShoulderRight)) { Point jointPos =getDisplayPosition(joint); Line jointLine = newLine(); jointLine.X1 =jointPos.X - 5; jointLine.X2 =jointLine.X1 + 6; jointLine.Y1 =jointLine.Y2 = jointPos.Y; jointLine.Stroke =jointColors[joint.ID]; jointLine.StrokeThickness = 9; skeleton.Children.Add(jointLine); } } var jtmd =data.Joints[JointID.HandRight]; var jtme =data.Joints[JointID.HandLeft]; XYZ(jtmd, jtme); } iSkeleton++; } } void nui_ColorFrameReady(object sender,ImageFrameReadyEventArgs e) { PlanarImage Image =e.ImageFrame.Image; video.Source = BitmapSource.Create( Image.Width, Image.Height, 96,96, PixelFormats.Bgr32, null, Image.Bits, Image.Width * Image.BytesPerPixel); } private void Window_Closed(objectsender, EventArgs e) { nui.Uninitialize(); Environment.Exit(0); } private void image1_ImageFailed(objectsender, ExceptionRoutedEventArgs e) { } }}APENDICE B Programacaodo robo em RAPIDCONST robtargetPT_00:=[[1207.77,-2275.18,885.74],[0.333647,0.642084,-0.329619,0.606432],[-1,-1,2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];PERS robtarget Pjob:=[[1207.77,-2275.18,885.74],[0.333647,0.642084,-0.329619,0.606432],[-1,-1,2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];PROC KINECT() MoveJ PT_00,v1000,z20,TGarra; While DI_06 = Hight; IF DI_00 = Hight; Pjob.trans.y := Pjob.trans.Y + 30; END IF; IF DI_01 = Hight; Pjob.trans.y := Pjob.trans.Y - 30; END IF; IF DI_02 = Hight; Pjob.trans.z := Pjob.trans.z + 30; END IF; IF DI_03 = Hight; Pjob.trans.z := Pjob.trans.z - 30; IF DI_04 = Hight; Pjob.trans.x := Pjob.trans.x + 30; END IF; IF DI_05 = Hight; Pjob.trans.y := Pjob.trans.Y - 30; END IF; MoveJ Pjob,v1000,z20,TGarra; ENDWHILE;