Exemple #1
0
        /// <summary>
        /// Starts to capture from leapmotion device.
        /// </summary>
        /// <param name="features">The active features for this instance. <see cref="LeapFeatures"/></param>
        /// <returns>Whether the device is ready.</returns>
        public bool StartSensor(LeapFeatures features)
        {
            this.CurrentFeatures = features;
            this.controller      = new Controller();

            if (this.controller == null)
            {
                this.IsReady = false;
                Console.WriteLine("Cannot connect to controller. Make sure you have Leap Motion v2.0+ installed");
            }
            else
            {
                if (features.HasFlag(LeapFeatures.CameraImages))
                {
                    if (!this.controller.IsPolicySet(Controller.PolicyFlag.POLICY_IMAGES))
                    {
                        this.controller.SetPolicy(Controller.PolicyFlag.POLICY_IMAGES);
                    }

                    this.InitializeTexture2D(LeapImageWith, LeapImageHeight, out this.depthTexture);
                }

                if (features.HasFlag(LeapFeatures.HMDMode))
                {
                    LeapExtensions.HWDModeEnable = true;

                    if (!this.controller.IsPolicySet(Controller.PolicyFlag.POLICY_OPTIMIZE_HMD))
                    {
                        this.controller.SetPolicy(Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
                    }
                }

                if (features.HasFlag(LeapFeatures.Gestures))
                {
                    this.controller.EnableGesture(Gesture.GestureType.TYPECIRCLE);
                    this.controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP);
                    this.controller.EnableGesture(Gesture.GestureType.TYPEKEYTAP);
                    this.controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
                }

                this.IsReady = true;
            }

            this.Update(TimeSpan.Zero);

            return(this.IsReady);
        }
        /// <summary>
        /// Starts to capture from leapmotion device.
        /// </summary>
        /// <param name="features">The active features for this instance. <see cref="LeapFeatures"/></param>
        /// <returns>Whether the device is ready.</returns>
        public bool StartSensor(LeapFeatures features)
        {
            this.CurrentFeatures = features;
            this.controller = new Controller();

            if (this.controller == null)
            {
                this.IsReady = false;
                Console.WriteLine("Cannot connect to controller. Make sure you have Leap Motion v2.0+ installed");
            }
            else
            {
                if (features.HasFlag(LeapFeatures.CameraImages))
                {
                    if (!this.controller.IsPolicySet(Controller.PolicyFlag.POLICY_IMAGES))
                    {
                        this.controller.SetPolicy(Controller.PolicyFlag.POLICY_IMAGES);
                    }

                    this.InitializeTexture2D(LeapImageWith, LeapImageHeight, out this.depthTexture);
                }

                if (features.HasFlag(LeapFeatures.HMDMode))
                {
                    LeapExtensions.HWDModeEnable = true;

                    if (!this.controller.IsPolicySet(Controller.PolicyFlag.POLICY_OPTIMIZE_HMD))
                    {
                        this.controller.SetPolicy(Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
                    }
                }

                if (features.HasFlag(LeapFeatures.Gestures))
                {
                    this.controller.EnableGesture(Gesture.GestureType.TYPECIRCLE);
                    this.controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP);
                    this.controller.EnableGesture(Gesture.GestureType.TYPEKEYTAP);
                    this.controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
                }

                this.IsReady = true;
            }

            this.Update(TimeSpan.Zero);

            return this.IsReady;
        }