Example #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 = "";
        }
Example #2
0
        /// <summary>
        /// Runs every time our 2D coordinates are ready.
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="a">Skeleton 2Ddata Coord Event Args</param>
        //private void NuiSkeleton2DdataCoordReady(object sender, Skeleton2DdataCoordEventArgs a)
        //{
        //    if (a.GetPoint(0) != null)
        //        if (!double.IsNaN(a.GetPoint(0).X))
        //        {
        //            //KinectBlenderServer.PublishData(a.getJSON());
        //        //KinectBlenderServer.PublishData("Point: X=" + a.GetPoint(0).X + ", Y=" + a.GetPoint(0).Y+",");
        //            //lblCoordinate.Content = "Point: X=" + a.GetPoint(0).X + ", Y=" + a.GetPoint(0).Y;
        //        }
        //        else
        //        {

        //            //lblCoordinate.Content = "Invalid point";
        //        }
        //    currentBufferFrame.Text = _video.Count.ToString();

        //    // We need a sensible number of frames before we start attempting to match gestures against remembered sequences
        //    if (_video.Count > MinimumFrames && _capturing == false)
        //    {
        //        ////Debug.WriteLine("Reading and video.Count=" + video.Count);
        //        //string s = _dtw.Recognize(_video);
        //        //results.Text = "Recognised as: " + s;
        //        //if (!s.Contains("__UNKNOWN"))
        //        //{
        //        //    // There was no match so reset the buffer
        //        //    _video = new ArrayList();
        //        //}
        //    }

        //    // Ensures that we remember only the last x frames
        //    if (_video.Count > BufferSize)
        //    {
        //        // If we are currently capturing and we reach the maximum buffer size then automatically store
        //        if (_capturing)
        //        {
        //            DtwStoreClick(null, null);
        //        }
        //        else
        //        {
        //            // Remove the first frame in the buffer
        //            _video.RemoveAt(0);
        //        }
        //    }

        //    // Decide which skeleton frames to capture. Only do so if the frames actually returned a number.
        //    // For some reason my Kinect/PC setup didn't always return a double in range (i.e. infinity) even when standing completely within the frame.
        //    // TODO Weird. Need to investigate this
        //    if (!double.IsNaN(a.GetPoint(0).X))
        //    {
        //        // Optionally register only 1 frame out of every n
        //        _flipFlop = (_flipFlop + 1) % Ignore;
        //        if (_flipFlop == 0)
        //        {
        //            _video.Add(a.GetCoords());
        //        }
        //    }

        //    // Update the debug window with Sequences information
        //    //dtwTextOutput.Text = _dtw.RetrieveText();
        //}


        private void NuiSkeletonNormalizedDataCoordReady(object sender, SkeletonNormalizedDataEventArgs a)
        {
            //System.Windows.MessageBox.Show("Event fired");
            Skeleton data = a.GetSkeleton();

            //double winLeft = ((Grid)System.Windows.Application.Current.MainWindow.Content).Margin.Left;
            //double winHeight = ((Grid)System.Windows.Application.Current.MainWindow.Content).RenderSize.Height;
            //double winWidth = ((Grid)System.Windows.Application.Current.MainWindow.Content).RenderSize.Width;


            //double winLeft = ((System.Windows.Controls.Panel)labelCursor.Parent).Margin.Left;
            //double winHeight = ((System.Windows.Controls.Panel)labelCursor.Parent).RenderSize.Height;
            //double winWidth = ((System.Windows.Controls.Panel)labelCursor.Parent).RenderSize.Width;

            lblCoordinate.Content = data.Joints[JointType.Head].Position.Z;



            //double left = (data.Joints[JointType.HandRight].Position.X + 1) / 2;
            //double top = (data.Joints[JointType.HandRight].Position.Y + 1) / 2;

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


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


            //newLbl.Margin = new Thickness(labelLeft,
            //                                    winHeight-labelTop,
            //                                    0,
            //                                    0);

            lblCoord2.Content = data.Joints[JointType.FootLeft].Position.Z;
        }
Example #3
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 = "";

        }