Example #1
0
        public Camera(params PXCMHandConfiguration.OnFiredGestureDelegate[] dlgts)
        {
            // Create the manager
            this._session = PXCMSession.CreateInstance();
            this._mngr    = this._session.CreateSenseManager();

            // streammmm
            PXCMVideoModule.DataDesc desc = new PXCMVideoModule.DataDesc();
            desc.deviceInfo.streams = PXCMCapture.StreamType.STREAM_TYPE_COLOR | PXCMCapture.StreamType.STREAM_TYPE_DEPTH;
            this._mngr.EnableStreams(desc);
            //this._mngr.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, Camera.WIDTH, Camera.HEIGHT, 30);
            //this._mngr.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, Camera.WIDTH, Camera.HEIGHT, 30);


            // Hands
            this._mngr.EnableHand();
            this._hand     = this._mngr.QueryHand();
            this._handData = this._hand.CreateOutput();

            // Hands config
            PXCMHandConfiguration conf = this._hand.CreateActiveConfiguration();

            conf.EnableGesture("spreadfingers", false);
            conf.EnableGesture("thumb_up", false);

            // Subscribe hands alerts
            conf.EnableAllAlerts();
            conf.SubscribeAlert(this.onFiredAlert);

            // Subscribe all gestures
            foreach (PXCMHandConfiguration.OnFiredGestureDelegate subscriber in dlgts)
            {
                conf.SubscribeGesture(subscriber);
            }

            // and the private one for debug
            conf.SubscribeGesture(this.onFiredGesture);

            // Apply it all
            conf.ApplyChanges();

            // Set events
            this._handler = new PXCMSenseManager.Handler();
            this._handler.onModuleProcessedFrame = this.onModuleProcessedFrame;

            this._mngr.Init(this._handler);
        }
Example #2
0
        /// <summary> 手の検出の初期化 </summary>
        private void InitializeHandTracking()
        {
            // 手の検出器を取得する
            handAnalyzer = senseManager.QueryHand();
            if (handAnalyzer == null)
            {
                throw new Exception("手の検出器の取得に失敗しました");
            }

            // 手のデータを作成する
            handData = handAnalyzer.CreateOutput();
            if (handData == null)
            {
                throw new Exception("手の検出器の作成に失敗しました");
            }

            // RealSense カメラであれば、プロパティを設定する
            var device = senseManager.QueryCaptureManager().QueryDevice();

            PXCMCapture.DeviceInfo dinfo;
            device.QueryDeviceInfo(out dinfo);
            if (dinfo.model == PXCMCapture.DeviceModel.DEVICE_MODEL_IVCAM)
            {
                device.SetDepthConfidenceThreshold(1);
                //device.SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED );
                device.SetIVCAMFilterOption(6);
            }

            // 手の検出の設定
            config = handAnalyzer.CreateActiveConfiguration();
            //config.EnableSegmentationImage(true);
            config.EnableJointSpeed(PXCMHandData.JointType.JOINT_MIDDLE_TIP, PXCMHandData.JointSpeedType.JOINT_SPEED_AVERAGE, 100);
            //config.EnableGesture("v_sign");
            config.EnableGesture("thumb_up");
            config.EnableGesture("thumb_down");
            //config.EnableGesture("tap");
            //config.EnableGesture("fist");
            config.SubscribeGesture(OnFiredGesture);
            config.ApplyChanges();
            config.Update();
            gestureTimer.Start();
        }
 public override void Listen()
 {
     // attach the controller to the PXCM sensor
     _senseManager = Session.CreateSenseManager();      
     _senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30);
     _senseManager.EnableHand();
     _handModule = _senseManager.QueryHand();
     _handData = _handModule.CreateOutput();
     _handConfiguration = _handModule.CreateActiveConfiguration();
     _handConfiguration.SubscribeGesture(_handGestureHandler);
     _handConfiguration.SubscribeAlert(_handAlertHandler);
     _handConfiguration.EnableAlert(PXCMHandData.AlertType.ALERT_HAND_TRACKED);
     _handConfiguration.EnableAlert(PXCMHandData.AlertType.ALERT_HAND_CALIBRATED);
     _handConfiguration.EnableGesture("full_pinch");
     _handConfiguration.EnableGesture("thumb_up");
     _handConfiguration.ApplyChanges();
     _senseManager.Init(_handler);
     sensorActive = true;
     _senseManager.StreamFrames(true);
     _senseManager.Close();           
     }
Example #4
0
        // RS
        private void STButton_Click(object sender, RoutedEventArgs e) {
            EXButton.IsEnabled = true;
            STButton.IsEnabled = false;
            // init the sense manager
            _senseManager = PXCMSenseManager.CreateInstance();
            // enable hand analysis in the multimodal pipeline
            _senseManager.EnableTouchlessController();
            // init the pipeline
            if (_senseManager.Init() < pxcmStatus.PXCM_STATUS_NO_ERROR) {
                MessageBox.Show("RealSense Camera init failed");
            }
            // get an instance of the touchless control
            _touchlessController = _senseManager.QueryTouchlessController();
            // register fo ux event
            _touchlessController.SubscribeEvent(OnTouchlessControllerUXEventHandler); //event
            _touchlessController.SubscribeAlert(OnFiredAlertEventHandler);  //alert
            // configuration
            pxcmStatus rc;
            PXCMTouchlessController.ProfileInfo pInfo;
            rc = _touchlessController.QueryProfile(out pInfo);
            pInfo.config = PXCMTouchlessController.ProfileInfo.Configuration.Configuration_Allow_Zoom
                | PXCMTouchlessController.ProfileInfo.Configuration.Configuration_Allow_Selection
                | PXCMTouchlessController.ProfileInfo.Configuration.Configuration_Allow_Back;
            rc = _touchlessController.SetProfile(pInfo);
            // configure hand module
            _hand = _senseManager.QueryHand();
            _handConfig = _hand.CreateActiveConfiguration();
            _handConfig.EnableGesture("thumb_up", true); // true is importment
            _handConfig.EnableGesture("v_sign", true);
            _handConfig.SubscribeGesture(OnFiredGestureEventHandler);
            _handConfig.ApplyChanges();

            // processing loop
            _processingThread = new Thread(new ThreadStart(ProcessingThread));
            _processingThread.Start();
        }