Exemplo n.º 1
0
        public Kinect()
        {
            IDataSourceFactory dataSourceFactory = new SDKDataSourceFactory();
            var handDataSource = new HandDataSource(dataSourceFactory.CreateShapeDataSource());

            handDataSource.NewDataAvailable += new NewDataHandler <HandCollection>(handDataSource_NewDataAvailable);
            handDataSource.Start();
        }
Exemplo n.º 2
0
        void InitKinect()
        {
            foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {
                    this._kinectDevice = potentialSensor;
                    break;
                }
            }

            if (null != this._kinectDevice)
            {
                //_kinectDevice = KinectSensor.KinectSensors[0];
                _kinectDevice.SkeletonStream.Enable();
                _kinectDevice.ColorStream.Enable();
                _kinectDevice.DepthStream.Enable();
                _kinectDevice.ColorFrameReady    += new EventHandler <ColorImageFrameReadyEventArgs>(myKinect_ColorFrameReady);
                _kinectDevice.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(SkeletonHandler);
                try
                {
                    _kinectDevice.Start();
                    skeletonData = new Skeleton[_kinectDevice.SkeletonStream.FrameSkeletonArrayLength];
                    EnableNearModeSkeletalTracking();

                    // restPosCheck.Start(); //start restPos check thread.
                }
                catch (IOException)
                {
                    this._kinectDevice = null;
                }

                System.Diagnostics.Debug.WriteLine("detected:=========" + _kinectDevice.Status);
                //button for gesture recording.ADD.
                btnRecord.Enabled = true;
                btnRecord.Click  += new EventHandler(btnRecord_Click);

                BtnCameraUp.Enabled   = true;
                BtnCameraDown.Enabled = true;
                BtnCameraUp.Click    += new EventHandler(BtnCameraUpClick);
                BtnCameraDown.Click  += new EventHandler(BtnCameraDownClick);
                btnTestbegin.Enabled  = true;
                btnTestbegin.Click   += new EventHandler(Testingbegin_click);
            }

            #region CCT code
            //CCT hand tracking code:
            try
            {
                this.clusteringSettings.MaximumDepthThreshold = 2000;                                //added threshold. as per CCT eg
                IDataSourceFactory dataSourceFactory = new SDKDataSourceFactory(useNearMode: false); //trying new modded src
                var handDataSource = new HandDataSource(dataSourceFactory.CreateShapeDataSource(this.clusteringSettings, this.shapeSettings), this.handDetectionSettings);
                handDataSource.NewDataAvailable += new NewDataHandler <HandCollection>(handDataSource_NewDataAvailable);
                handDataSource.Start();
                //System.Diagnostics.Debug.WriteLine("hand data src started");
            }
            catch (ArgumentOutOfRangeException exc)
            {
                //Cursor.Current = Cursors.Default;
                //MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                System.Diagnostics.Debug.WriteLine("===Error using CCT !!=========== " + exc.Message);
                //return;
            }
            #endregion
        }