예제 #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);
     }
 }
예제 #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;
 }
예제 #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();
            }
        }
예제 #4
0
 void sessionManager_SessionStart(ref xn.Point3D position)
 {
     this.flowRouter.SetActive(this.selectableSlider);
 }
예제 #5
0
 void selectableSlider_PrimaryPointCreate(ref xnv.HandPointContext context, ref xn.Point3D ptFocus)
 {
     this.SliderArea.BackColor = Color.Red;
 }
예제 #6
0
파일: Main.cs 프로젝트: hooface/as3_openni
 void sessionManager_SessionStart(ref xn.Point3D position)
 {
 }
예제 #7
0
파일: Main.cs 프로젝트: hooface/as3_openni
 void pointControl_PrimaryPointCreate(ref xnv.HandPointContext context, ref xn.Point3D pnt)
 {
     primaryHand = context;
 }
예제 #8
0
파일: Skeleton.cs 프로젝트: halllo/MKinect
 private MVector3D GetVector(xn.Point3D p)
 {
     return new MVector3D(p.X, p.Y, p.Z);
 }
예제 #9
0
 internal virtual void StartTracking(xn.Point3D point)
 {
     _handsGenerator.StartTracking(ref point);
     _isTracking = true;
 }
예제 #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));
     }
 }
예제 #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;
 }
예제 #15
0
파일: Skeleton.cs 프로젝트: halllo/MKinect
 private MVector3D GetVectorFromJoint(Dictionary<xn.SkeletonJoint, xn.SkeletonJointPosition> joints, xn.SkeletonJoint joint)
 {
     return this.GetVector(joints[joint].position);
 }
예제 #16
0
 internal xn.Point3D ConvertProjectiveToRealWorld(xn.Point3D projective)
 {
     return _videoTracker._depthNode.ConvertProjectiveToRealWorld(projective);
 }
예제 #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);
     }
 }
예제 #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();
 }
예제 #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;
            }
        }
예제 #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;
 }