Exemplo n.º 1
0
 void _handGenerator_HandCreate(ProductionNode node, uint id, ref xn.Point3D position, float fTime)
 {
     if (_startTime == 0)
     {
         _traceHistory = new SortedList<float, xn.Point3D>();
         _startTime = fTime;
         _traceHistory.Add(0, position);
         _id = id;
         System.Diagnostics.Debug.WriteLine("Hand created");
     }
     else
     {
         _handsGenerator.StopTracking(id);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Checks if a swipe is completed
 /// </summary>
 /// <param name="lastPosition">The last position of the swip</param>
 /// <param name="duration">The duration of the swipe</param>
 /// <param name="change">The change in position of the swipe</param>
 /// <param name="detectingGesture">The swipe that is being checked</param>
 /// <returns>A boolean to indicate that the swipe is completed</returns>
 private bool CheckPushCompleted(xn.Point3D lastPosition, float duration, float change, Gestures detectingGesture)
 {
     if (change >= _treshHold)
     {
         //Check if the swipe was fast enough.
         //If it is to slow it is not a swipe
         float speed = ((change / 1000) / duration);
         if (speed > _speedTreshold)
         {
             PushGestureRecognisedEventHandler(this, new PushGestureRecognisedEventArgs(detectingGesture, lastPosition, speed));
         }
         //Reset settings
         ResetValues();
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
        /*
        private Bitmap CreateBitmap(byte[] data)
        {
            // Do the magic to create a bitmap
            int stride = _camWidth * _bytesPerPixel;
            GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
            int scan0 = (int)handle.AddrOfPinnedObject();
            scan0 += (_camHeight - 1) * stride;
            Bitmap b = new Bitmap(_camWidth, _camHeight, -stride, PixelFormat.Format24bppRgb, (IntPtr)scan0);

            // Now you can free the handle
            handle.Free();

            return b;
        }
        */
        /*
        private void CreateImageBitmap(XnMImageMetaData imageMd, out InteropBitmap interopBitmap, out Bitmap bitmap)
        {
            var format = MapPixelFormat(imageMd.PixelFormat);
            var bmpWidth = (int)imageMd.FullXRes;
            var bmpHeight = (int)imageMd.FullYRes;

            var numBytes = (uint)(bmpWidth * bmpHeight * format.BitsPerPixel / 8);
            var stride = (bmpWidth * format.BitsPerPixel / 8);

            var section = NativeMethods.CreateFileMapping(NativeMethods.INVALID_HANDLE_VALUE, IntPtr.Zero, NativeMethods.PAGE_READWRITE, 0, numBytes, null);
            var map = NativeMethods.MapViewOfFile(section, NativeMethods.FILE_MAP_ALL_ACCESS, 0, 0, numBytes);

            interopBitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(section,
                bmpWidth, bmpHeight, format, stride, 0);

            bitmap = new Bitmap(bmpWidth, bmpHeight, stride, PixelFormat.Format24bppRgb, map);

            NativeMethods.CloseHandle(section);
        }
        */
        private static System.Windows.Media.PixelFormat MapPixelFormat(xn.PixelFormat xnMPixelFormat)
        {
            switch (xnMPixelFormat)
            {
                case xn.PixelFormat.Grayscale8Bit:
                    return PixelFormats.Gray8;
                case xn.PixelFormat.Grayscale16Bit:
                    return PixelFormats.Gray16;
                case xn.PixelFormat.RGB24:
                    return PixelFormats.Rgb24;

                case xn.PixelFormat.YUV422:
                default:
                    throw new NotSupportedException();
            }
        }
Exemplo n.º 4
0
 void sessionManager_SessionStart(ref xn.Point3D position)
 {
     this.flowRouter.SetActive(this.selectableSlider);
 }
Exemplo n.º 5
0
 void selectableSlider_PrimaryPointCreate(ref xnv.HandPointContext context, ref xn.Point3D ptFocus)
 {
     this.SliderArea.BackColor = Color.Red;
 }
Exemplo n.º 6
0
 void sessionManager_SessionStart(ref xn.Point3D position)
 {
 }
Exemplo n.º 7
0
 void pointControl_PrimaryPointCreate(ref xnv.HandPointContext context, ref xn.Point3D pnt)
 {
     primaryHand = context;
 }
Exemplo n.º 8
0
 private MVector3D GetVector(xn.Point3D p)
 {
     return new MVector3D(p.X, p.Y, p.Z);
 }
Exemplo n.º 9
0
 internal virtual void StartTracking(xn.Point3D point)
 {
     _handsGenerator.StartTracking(ref point);
     _isTracking = true;
 }
Exemplo n.º 10
0
 void _gestureGenerator_GestureRecognized(ProductionNode node, string strGesture, ref xn.Point3D idPosition, ref xn.Point3D endPosition)
 {
     Gestures gesture;
     if(Enum.TryParse<Gestures>(strGesture, out gesture))
     {
         Point3D point = new Point3D(idPosition.X, idPosition.Y, idPosition.Z);
         GestureDetected(this, new GestureRecognisedEventArgs(gesture, point));
     }
 }
Exemplo n.º 11
0
 void _gestureGenerator_GestureProgress(ProductionNode node, string strGesture, ref xn.Point3D position, float progress)
 {
     //throw new NotImplementedException();
 }
 public PushGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point, float speed)
 {
     _gesture = gesture;
     _point = new Point3D(point.X, point.Y, point.Z);
     _speed = speed;
 }
 public SwipeGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point)
 {
     _gesture = gesture;
     _point = new Point3D(point.X, point.Y, point.Z) ;
 }
 public StillGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point, float fTime)
 {
     _gesture = gesture;
     _point = new Point3D(point.X, point.Y, point.Z);
     _timeHold = fTime;
 }
Exemplo n.º 15
0
 private MVector3D GetVectorFromJoint(Dictionary<xn.SkeletonJoint, xn.SkeletonJointPosition> joints, xn.SkeletonJoint joint)
 {
     return this.GetVector(joints[joint].position);
 }
Exemplo n.º 16
0
 internal xn.Point3D ConvertProjectiveToRealWorld(xn.Point3D projective)
 {
     return _videoTracker._depthNode.ConvertProjectiveToRealWorld(projective);
 }
Exemplo n.º 17
0
 void _handGenerator_HandUpdate(ProductionNode node, uint id, ref xn.Point3D position, float fTime)
 {
     if (id == _id)
     {
         float timeTracking = fTime - _startTime;
         _traceHistory.Add(timeTracking, position);
         CheckStatus();
         System.Diagnostics.Debug.WriteLine("Hand update for " + timeTracking);
     }
 }
Exemplo n.º 18
0
 void _startSessionGenerator_GestureProgress(ProductionNode node, string strGesture, ref xn.Point3D position, float progress)
 {
     System.Diagnostics.Debug.WriteLine("Gesture Progress:" + progress);
     //throw new NotImplementedException();
 }
Exemplo n.º 19
0
        void _startSessionGenerator_GestureRecognized(ProductionNode node, string strGesture, ref xn.Point3D idPosition, ref xn.Point3D endPosition)
        {
            System.Diagnostics.Debug.WriteLine("Gesture Recognized:" + strGesture);
            switch (strGesture)
            {
                case "Wave":
                case "Click":
                    if (State == SessionState.Stopped)
                    {

                        State = SessionState.Starting;
                        _startSessionGenerator.RemoveGesture("Wave");
                        _startSessionGenerator.RemoveGesture("Click");
                        _startSessionGenerator.AddGesture("RaiseHand");
                        _gestureGenerator.StartGenerating();
                    }
                    break;
                case "RaiseHand":
                    if (State == SessionState.Halted || State == SessionState.Starting)
                    {
                        System.Diagnostics.Debug.WriteLine("Raised hand");
                        foreach (var hg in _handGestures)
                        {
                            if(!hg.IsTracking) hg.StartTracking(idPosition);
                        }
                        State = SessionState.InProgress;
                    }
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Checks if a swipe is completed
 /// </summary>
 /// <param name="lastPosition">The last position of the swip</param>
 /// <param name="duration">The duration of the swipe</param>
 /// <param name="change">The change in position of the swipe</param>
 /// <param name="detectingGesture">The swipe that is being checked</param>
 /// <returns>A boolean to indicate that the swipe is completed</returns>
 private bool CheckSwipeCompleted(xn.Point3D lastPosition, float duration, float change, Gestures detectingGesture)
 {
     if (change >= _treshHold)
     {
         //Check if the swipe was fast enough.
         //If it is to slow it is not a swipe
         float speed = ((change / 1000) / duration);
         if (speed > _speedTreshold)
         {
             SwipeGestureRecognisedEventHandler(this, new SwipeGestureRecognisedEventArgs(detectingGesture, lastPosition));
         }
         //Reset settings
         ResetValues();
         return true;
     }
     else
     {
         switch (detectingGesture)
         {
             case Gestures.SwipeRight:
             case Gestures.SwipeLeft:
                 ResetHorizontalValues();
                 break;
             case Gestures.SwipeDown:
             case Gestures.SwipeUp:
                 ResetVerticalValues();
                 break;
         }
     }
     return false;
 }