Ejemplo n.º 1
0
        private void NuiSkeletonNormalizedDataCoordReady(object sender, SkeletonNormalizedDataEventArgs a)
        {
            Skeleton data = a.GetSkeleton();

            //double winHeight = canvas1.RenderSize.Height;
            //double winWidth = canvas1.RenderSize.Width;

            double left       = data.Joints[JointType.HandRight].Position.X;
            double top        = 0.5 - data.Joints[JointType.HandRight].Position.Y;
            double deltaLeftZ = ((data.Joints[JointType.HandLeft].Position.Z - leftHand.Z) * 5);

            deltaLeftZ = normal(deltaLeftZ);

            if (top > 0)
            {
            }
            else if (top < 0)
            {
                top *= 1.2;
            }

            if (left < 0)
            {
                left *= 1.1;
            }

            //lblCoordinate.Content = "x= " + left.ToString("#.##");
            //lblCoord2.Content = "y= " + top.ToString("#.##");
            //labelVoice.Content = "z= " + deltaLeftZ.ToString("#.##");

            KinectBlenderServer.PublishData(voiceCommand + "," + left + "," + (top) + "," + deltaLeftZ);
            //voiceCommand = "";
        }
Ejemplo n.º 2
0
 public static KinectBlenderServer getServer()
 {
     if (server == null)
     {
         server = new KinectBlenderServer();
     }
     return(server);
 }
Ejemplo n.º 3
0
 private void runServer()
 {
     try
     {
         networkServer = KinectBlenderServer.getServer();
     }
     catch
     {
     }
 }
Ejemplo n.º 4
0
        private void SreSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //System.Windows.MessageBox.Show("Recognized");

            if (e.Result.Confidence < 0.7)
            {
                lblCoordinate.Content = "Confidence score too low";
            }
            else
            {
                string result = e.Result.Text.ToUpperInvariant();

                KinectBlenderServer.PublishData("Voice command " + result + " - Confidence score: " + e.Result.Confidence);
                lblCoordinate.Content = "Voice command " + result + " - Confidence score: " + e.Result.Confidence;
            }
        }
Ejemplo n.º 5
0
        private void NuiSkeletonNormalizedDataCoordReady(object sender, SkeletonNormalizedDataEventArgs a)
        {
            //System.Windows.MessageBox.Show("Event fired");
            Skeleton data = a.GetSkeleton();


            //double winLeft = canvas1.Margin.Left;
            //double winHeight = canvas1.RenderSize.Height;
            //double winWidth = canvas1.RenderSize.Width;

            double left = data.Joints[JointType.HandRight].Position.X;
            double top = 0.5 - data.Joints[JointType.HandRight].Position.Y;
            //double depth = data.Joints[JointType.HandRight].Position.Z;



            //double labelLeft = Math.Max(Math.Min(left * winWidth, winWidth), 0);
            //double labelTop = Math.Max(Math.Min(top * winHeight, winHeight), 0);

            //double zUp = 0.5 - data.Joints[JointType.HandLeft].Position.Y;
            double deltaLeftZ = ((data.Joints[JointType.HandLeft].Position.Z - leftHand.Z) * 5);


            //double newDepth = deltaLeftZ;//((depth - rightHand.Z))*2;
            //double labelTopZ = Math.Max(Math.Min(zUp * winHeight, winHeight), 0);

            //System.Windows.Controls.Label newLbl = labelCursor;


            //labelCursor.Margin = new Thickness(0, 0, 10, 10);
            //labelCursor.Margin = new Thickness(labelLeft,
            //                                    labelTop - top,
            //                                    0,
            //                                    0);

            //labelLeftZ.Margin = new Thickness(winLeft,
            //                                        labelTopZ - top,
            //                                        0,
            //                                        0);



            //labelLeftZ.Width += newDepth2;
            //labelCursor.Width = Math.Min(100, Math.Max(10, labelCursor.Width + newDepth));
            //labelLeftZ.Height += newDepth2;
            //labelCursor.Height = Math.Min(100, Math.Max(10, labelCursor.Height + newDepth));



            //labelCursor.Width = Math.Min(30, Math.Max(10, labelCursor.Width));



            if (isSynchronizing)
            {
                isSynchronized = true;
                //labelCenter.Margin = new Thickness(labelLeft,
                //                                    0,//labelTop - top,
                //                                    0,
                //                                    0);
                //labelZ.Margin = new Thickness(winLeft,
                //                                    labelTopZ - top,
                //                                    0,
                //                                    0);
                rightHand = data.Joints[JointType.HandRight].Position;
                leftHand = data.Joints[JointType.HandLeft].Position;

                isSynchronizing = false;
            }

            if (isSynchronized)
            {
                left -= rightHand.X;
                top -= rightHand.Y;
                deltaLeftZ -= rightHand.Z;

            }

            //left = normal((left * 2) - 1);
            //top = normal((top * 2) - 1);
            //left = normal((left * 2) - 1);
            deltaLeftZ = normal(deltaLeftZ);

            if (top > 0)
            {

            }
            else if (top < 0)
            {
                top *= 1.2;
            }

            if (left < 0)
            {
                left *= 1.1;
            }

            //left = left - 0.5;
            //left *= 2.0;

            lblCoordinate.Content = "x= " + left.ToString("#.##");
            lblCoord2.Content = "y= " + top.ToString("#.##");
            labelVoice.Content = "z= " + deltaLeftZ.ToString("#.##");

            KinectBlenderServer.PublishData(voiceCommand + "," + left + "," + top + "," + deltaLeftZ);
            //voiceCommand = "";

        }