• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GestureData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中GestureData的典型用法代码示例。如果您正苦于以下问题:C# GestureData类的具体用法?C# GestureData怎么用?C# GestureData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GestureData类属于命名空间,在下文中一共展示了GestureData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: endOfGestureCallback

    /// <summary>
    /// End of gesture movement callback.
    /// </summary>
    /// <param name='data'>
    /// Data of the gesture gathered.
    /// </param>
    public void endOfGestureCallback(GestureData data)
    {
        GestureUtils.EnumGestures gResult;

        Debug.Log("Gesture ended!");
        List<Vector2> pointList = new List<Vector2>();
        GestureData normalizedData = data.getNormalizedGestureData(CANVAS_SIZE);

        GestureFrame previousFrame = (GestureFrame)normalizedData.frames[0];
        pointList.Add(new Vector2(previousFrame.position.x, previousFrame.position.y));
        for (int i = 1; i < normalizedData.frames.Count; i++) {
            GestureFrame currentFrame = (GestureFrame)normalizedData.frames[i];

            if ((Math.Abs(currentFrame.position.x - previousFrame.position.x) < NORMAL_FRAME_VARIATION) &&
                (Math.Abs(currentFrame.position.y - previousFrame.position.y) < NORMAL_FRAME_VARIATION)) {

                pointList.Add(new Vector2(currentFrame.position.x, currentFrame.position.y));
                previousFrame = currentFrame;
            }

        }

        //At gesture end, draw the normalized data.
        Vector2 previousPoint = pointList[0];
        for (int i = 1; i < pointList.Count; i++) {
            Vector2 currentPoint = pointList[i];
            DrawLine(canvas, previousPoint.x, previousPoint.y, currentPoint.x, currentPoint.y, Color.black);
            previousPoint = currentPoint;
        }

        canvas.Apply();

        //The checker method only receives canvas if you want the points used drawn on the screen,
        //can just receive a points list otherwise.
        gResult = gu.GestureChecker(pointList, canvas, CANVAS_SIZE);

        switch(gResult) {
        case GestureUtils.EnumGestures.DownZigZag:
            Debug.Log("Downwards Zig Zag!");
            status = "Downwards Zig Zag!";
            break;
        case GestureUtils.EnumGestures.RightZigZag:
            Debug.Log("Rightwards Zig Zag!");
            status = "Rightwards Zig Zag!";
            break;
        case GestureUtils.EnumGestures.Square:
            Debug.Log("Square!");
            status = "Square!";
            break;
        default:
            Debug.Log("No Gesture found.");
            status = "Nothing.";
            break;
        }
    }
开发者ID:riazi,项目名称:leap_patterns,代码行数:61,代码来源:LeapController.cs


示例2: AddToQueue

        public int AddToQueue(GestureData data)
        {
            //Decrement the semaphore to make sure the spot is available
            this.requestGestureDataSem.WaitOne();

            lock (_threadLock)
            {
                dataQueue.Enqueue(data);
            }

            //Increament the semaphore to indicate there is work to do
            int previousCount = handleRequests.Release();

            return previousCount;
        }
开发者ID:jchahal,项目名称:KinectForPCGames,代码行数:15,代码来源:GestureDispatcher.cs


示例3: SetGestureJoint

 private static void SetGestureJoint(ref GestureData gestureData, float timestamp, int joint, Vector3 jointPos)
 {
     gestureData.joint = joint;
     gestureData.jointPos = jointPos;
     gestureData.timestamp = timestamp;
     gestureData.state++;
 }
开发者ID:songwanfu,项目名称:MotionSensing3DSolarSystem,代码行数:7,代码来源:KinectGestures.cs


示例4: SetGestureCancelled

 private static void SetGestureCancelled(ref GestureData gestureData)
 {
     gestureData.state = 0;
     gestureData.progress = 0f;
     gestureData.cancelled = true;
 }
开发者ID:songwanfu,项目名称:MotionSensing3DSolarSystem,代码行数:6,代码来源:KinectGestures.cs


示例5: IsGestureFiredByHand

        /**
            @brief Return whether the specified gesture is fired for a specific hand in the current frame, and if so retrieve its data.
            @param[in] gestureName - the name of the gesture to be checked.
            @param[in] handID - the ID of the hand whose alert should be retrieved. 
            @param[out] gestureData - the information for the fired gesture.
		
            @return true if the gesture was fired, false otherwise.
            @see GestureData
        */
        public Boolean IsGestureFiredByHand(String gestureName, Int32 handID, out GestureData gestureData)
        {
            return IsGestureFiredByHandINT(instance, gestureName, handID, out gestureData);
        }
开发者ID:mbahar94,项目名称:libpxcclr.cs,代码行数:13,代码来源:pxcmhanddata.cs


示例6: IsGestureFired

        /** 
            @brief Check whether a gesture was fired and if so return its details.
		
            @param[in] gestureName - the name of the gesture to be checked.
            @param[out] gestureData - the information for the fired gesture.
		
            @return true if the gesture was fired, false otherwise.
		
            @see GestureData
        */
        public Boolean IsGestureFired(String gestureName, out GestureData gestureData)
        {
            return IsGestureFiredINT(instance, gestureName, out gestureData);
        }
开发者ID:mbahar94,项目名称:libpxcclr.cs,代码行数:14,代码来源:pxcmhanddata.cs


示例7: SetScreenPos

	protected void SetScreenPos(long userId, ref GestureData gestureData, ref Vector3[] jointsPos, ref bool[] jointsTracked)
	{
		Vector3 handPos = jointsPos[rightHandIndex];
		bool calculateCoords = false;
		
		if(gestureData.joint == rightHandIndex)
		{
			if(jointsTracked[rightHandIndex] /**&& jointsTracked[rightElbowIndex] && jointsTracked[rightShoulderIndex]*/)
			{
				calculateCoords = true;
			}
		}
		else if(gestureData.joint == leftHandIndex)
		{
			if(jointsTracked[leftHandIndex] /**&& jointsTracked[leftElbowIndex] && jointsTracked[leftShoulderIndex]*/)
			{
				handPos = jointsPos[leftHandIndex];
				calculateCoords = true;
			}
		}
		
		if(calculateCoords)
		{
			if(jointsTracked[hipCenterIndex] && jointsTracked[shoulderCenterIndex] && 
				jointsTracked[leftShoulderIndex] && jointsTracked[rightShoulderIndex])
			{
				Vector3 shoulderToHips = jointsPos[shoulderCenterIndex] - jointsPos[hipCenterIndex];
				Vector3 rightToLeft = jointsPos[rightShoulderIndex] - jointsPos[leftShoulderIndex];
				
				gestureData.tagVector2.x = rightToLeft.x; // * 1.2f;
				gestureData.tagVector2.y = shoulderToHips.y; // * 1.2f;
				
				if(gestureData.joint == rightHandIndex)
				{
					gestureData.tagVector.x = jointsPos[rightShoulderIndex].x - gestureData.tagVector2.x / 2;
					gestureData.tagVector.y = jointsPos[hipCenterIndex].y;
				}
				else
				{
					gestureData.tagVector.x = jointsPos[leftShoulderIndex].x - gestureData.tagVector2.x / 2;
					gestureData.tagVector.y = jointsPos[hipCenterIndex].y;
				}
			}
	
			if(gestureData.tagVector2.x != 0 && gestureData.tagVector2.y != 0)
			{
				Vector3 relHandPos = handPos - gestureData.tagVector;
				gestureData.screenPos.x = Mathf.Clamp01(relHandPos.x / gestureData.tagVector2.x);
				gestureData.screenPos.y = Mathf.Clamp01(relHandPos.y / gestureData.tagVector2.y);
			}
			
		}
	}
开发者ID:anteaterho,项目名称:SpoutTestTemp,代码行数:53,代码来源:KinectGestures.cs


示例8: QueryFiredGestureDataINT

 internal static pxcmStatus QueryFiredGestureDataINT(IntPtr instance, Int32 index, out GestureData gestureData)
 {
     gestureData = new GestureData();
     return PXCMHandData_QueryFiredGestureData(instance, index, gestureData);
 }
开发者ID:mbahar94,项目名称:libpxcclr.cs,代码行数:5,代码来源:pxcmhanddata.cs


示例9: CheckForGesture

    //    private static void SetWheelRotation(uint userId, ref GestureData gestureData, Vector3 initialPos, Vector3 currentPos)
    //    {
    //        float angle = Vector3.Angle(initialPos, currentPos) * Mathf.Sign(currentPos.y - initialPos.y);
    //        gestureData.screenPos.z = angle;
    //    }
    // estimate the next state and completeness of the gesture
    public static void CheckForGesture(uint userId, ref GestureData gestureData, float timestamp, ref Vector3[] jointsPos, ref bool[] jointsTracked)
    {
        if(gestureData.complete)
            return;

        float bandSize = (jointsPos[shoulderCenterIndex].y - jointsPos[hipCenterIndex].y);
        float gestureTop = jointsPos[shoulderCenterIndex].y + bandSize / 2;
        float gestureBottom = jointsPos[shoulderCenterIndex].y - bandSize;
        float gestureRight = jointsPos[rightHipIndex].x;
        float gestureLeft = jointsPos[leftHipIndex].x;

        switch(gestureData.gesture)
        {
            // check for RaiseRightHand
            case Gestures.RaiseRightHand:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                           (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                        }
                        break;

                    case 1:  // gesture complete
                        bool isInPose = jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                            (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f;

                        Vector3 jointPos = jointsPos[gestureData.joint];
                        CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, KinectWrapper.Constants.PoseCompleteDuration);
                        break;
                }
                break;

            // check for RaiseLeftHand
            case Gestures.RaiseLeftHand:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                                (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, leftHandIndex, jointsPos[leftHandIndex]);
                        }
                        break;

                    case 1:  // gesture complete
                        bool isInPose = jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                            (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f;

                        Vector3 jointPos = jointsPos[gestureData.joint];
                        CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, KinectWrapper.Constants.PoseCompleteDuration);
                        break;
                }
                break;

            // check for Psi
            case Gestures.Psi:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                           (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f &&
                           jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                           (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                        }
                        break;

                    case 1:  // gesture complete
                        bool isInPose = jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                            (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f &&
                            jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                            (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f;

                        Vector3 jointPos = jointsPos[gestureData.joint];
                        CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, KinectWrapper.Constants.PoseCompleteDuration);
                        break;
                }
                break;

            // check for Tpose
            case Gestures.Tpose:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightElbowIndex] && jointsTracked[rightShoulderIndex] &&
                           Mathf.Abs(jointsPos[rightElbowIndex].y - jointsPos[rightShoulderIndex].y) < 0.1f &&  // 0.07f
                           Mathf.Abs(jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) < 0.1f &&  // 0.7f
                           jointsTracked[leftHandIndex] && jointsTracked[leftElbowIndex] && jointsTracked[leftShoulderIndex] &&
                           Mathf.Abs(jointsPos[leftElbowIndex].y - jointsPos[leftShoulderIndex].y) < 0.1f &&
                           Mathf.Abs(jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) < 0.1f)
//.........这里部分代码省略.........
开发者ID:songwanfu,项目名称:MotionSensing3DSolarSystem,代码行数:101,代码来源:KinectGestures.cs


示例10: ProcessNewGestureData

        public int ProcessNewGestureData(GestureData newGestureData)
        {
            int result = (int)ResultCodes.Success;

            do
            {
                SkeletonData trackedSkeleton = (from skeletons in newGestureData.GetSkeletonFrame().Skeletons
                                                where skeletons.TrackingState == SkeletonTrackingState.Tracked
                                                select skeletons).FirstOrDefault();

                if (trackedSkeleton == null)
                {
                    result = (int)ResultCodes.NullTrackedSkeleton;
                    break;
                }

                GestureBase.NuiElement nuiElement = new GestureBase.NuiElement();

                nuiElement.SetSkeletonFrame(newGestureData.GetSkeletonFrame());
                nuiElement.SetTimeStamp(DateTime.Now);

                if (legsGesture != null) legsGesture.AddToQueue(nuiElement);
                if (mouseGesture != null) mouseGesture.AddToQueue(nuiElement);

                if (frontbackGesture != null) frontbackGesture.AddToQueue(nuiElement);
                if (jumpGesture != null) jumpGesture.AddToQueue(nuiElement);

                if (shootGesture != null) shootGesture.AddToQueue(nuiElement);

                if (!this.stopVisualThreads)
                {
                    TransformedSkeletonDrawing.SkeletalDrawingData newDrawingData = new TransformedSkeletonDrawing.SkeletalDrawingData();
                    newDrawingData.SetSkeletalFrame(newGestureData.GetSkeletonFrame());

                    this.drawSkeleton.AddToQueue(newDrawingData);
                }

            } while (false);

            return result;
        }
开发者ID:jchahal,项目名称:KinectForPCGames,代码行数:41,代码来源:GestureDispatcher.cs


示例11: CheckForGesture

    // estimate the next state and completeness of the gesture
    public static void CheckForGesture(uint userId, ref GestureData gestureData, float timestamp, ref Vector3[] jointsPos, ref bool[] jointsTracked)
    {
        if(gestureData.complete)
            return;

        switch(gestureData.gesture)
        {
            // check for RaiseHand
            case Gestures.RaiseHand:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                           (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                        }
                        else if(jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                                (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, leftHandIndex, jointsPos[leftHandIndex]);
                        }
                        break;

                        case 1:  // gesture complete
                            bool isInPose = gestureData.joint == rightHandIndex ?
                                jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                                (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f :
                                jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                                (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f;

                            Vector3 jointPos = jointsPos[gestureData.joint];
                            CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, Constants.PoseCompleteDuration);
                            break;
                }
                break;

            // check for Psi
            case Gestures.Psi:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                           (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f &&
                           jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                           (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                        }
                        break;

                        case 1:  // gesture complete
                            bool isInPose = jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                                (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f &&
                                jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                                (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f;

                            Vector3 jointPos = jointsPos[gestureData.joint];
                            CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, Constants.PoseCompleteDuration);
                            break;
                }
                break;

            // check for Wave
            case Gestures.Wave:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection - phase 1
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightElbowIndex] &&
                           (jointsPos[rightHandIndex].y - jointsPos[rightElbowIndex].y) > 0.1f &&
                           (jointsPos[rightHandIndex].x - jointsPos[rightElbowIndex].x) > 0.05f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                            gestureData.progress = 0.3f;
                        }
                        else if(jointsTracked[leftHandIndex] && jointsTracked[leftElbowIndex] &&
                                (jointsPos[leftHandIndex].y - jointsPos[leftElbowIndex].y) > 0.1f &&
                                (jointsPos[leftHandIndex].x - jointsPos[leftElbowIndex].x) < -0.05f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, leftHandIndex, jointsPos[leftHandIndex]);
                            gestureData.progress = 0.3f;
                        }
                        break;

                        case 1:  // gesture - phase 2
                            if((timestamp - gestureData.timestamp) < 1.5f)
                            {
                                bool isInPose = gestureData.joint == rightHandIndex ?
                                    jointsTracked[rightHandIndex] && jointsTracked[rightElbowIndex] &&
                                    (jointsPos[rightHandIndex].y - jointsPos[rightElbowIndex].y) > 0.1f &&
                                    (jointsPos[rightHandIndex].x - jointsPos[rightElbowIndex].x) < -0.05f :
                                    jointsTracked[leftHandIndex] && jointsTracked[leftElbowIndex] &&
                                    (jointsPos[leftHandIndex].y - jointsPos[leftElbowIndex].y) > 0.1f &&
                                    (jointsPos[leftHandIndex].x - jointsPos[leftElbowIndex].x) > 0.05f;

                                if(isInPose)
                                {
                                    gestureData.timestamp = timestamp;
                                    gestureData.state++;
//.........这里部分代码省略.........
开发者ID:krg265,项目名称:Kinect-Game,代码行数:101,代码来源:KinectWrapper.cs


示例12: SetScreenPos

    private static void SetScreenPos(uint userId, ref GestureData gestureData, ref Vector3[] jointsPos, ref bool[] jointsTracked)
    {
        Vector3 handPos = jointsPos[rightHandIndex];
        Vector3 elbowPos = jointsPos[rightElbowIndex];
        Vector3 shoulderPos = jointsPos[rightShoulderIndex];
        bool calculateCoords = false;

        if(gestureData.joint == rightHandIndex)
        {
            if(jointsTracked[rightHandIndex] && jointsTracked[rightElbowIndex] && jointsTracked[rightShoulderIndex])
            {
                calculateCoords = true;
            }
        }
        else if(gestureData.joint == leftHandIndex)
        {
            if(jointsTracked[leftHandIndex] && jointsTracked[leftElbowIndex] && jointsTracked[leftShoulderIndex])
            {
                handPos = jointsPos[leftHandIndex];
                elbowPos = jointsPos[leftElbowIndex];
                shoulderPos = jointsPos[leftShoulderIndex];

                calculateCoords = true;
            }
        }

        if(calculateCoords)
        {
            if(gestureData.tagFloat == 0f || gestureData.userId != userId)
            {
                // get length from shoulder to hand (screen range)
                Vector3 shoulderToElbow = elbowPos - shoulderPos;
                Vector3 elbowToHand = handPos - elbowPos;
                gestureData.tagFloat = (shoulderToElbow.magnitude + elbowToHand.magnitude);
            }

            Vector3 shoulderToHand = handPos - shoulderPos;
            gestureData.screenPos.x = Mathf.Clamp01((gestureData.tagFloat / 2 + shoulderToHand.x) / gestureData.tagFloat);
            gestureData.screenPos.y = Mathf.Clamp01((gestureData.tagFloat / 2 + shoulderToHand.y) / gestureData.tagFloat);

            //Debug.Log(string.Format("{0} - S: {1}, H: {2}, SH: {3}, L : {4}", gestureData.gesture, shoulderPos, handPos, shoulderToHand, gestureData.tagFloat));
        }
    }
开发者ID:krg265,项目名称:Kinect-Game,代码行数:43,代码来源:KinectWrapper.cs


示例13: CheckForGesture

        // estimate the next state and completeness of the gesture
        /// <summary>
        /// estimate the state and progress of the given gesture.
        /// </summary>
        /// <param name="userId">User ID</param>
        /// <param name="gestureData">Gesture-data structure</param>
        /// <param name="timestamp">Current time</param>
        /// <param name="jointsPos">Joints-position array</param>
        /// <param name="jointsTracked">Joints-tracked array</param>
        public static void CheckForGesture(long userId, ref GestureData gestureData, float timestamp, ref Vector3[] jointsPos, ref bool[] jointsTracked)
        {
            if (gestureData.complete)
                return;

            float bandSize = (jointsPos[shoulderCenterIndex].y - jointsPos[hipCenterIndex].y);
            float gestureTop = jointsPos[shoulderCenterIndex].y + bandSize * 1.2f / 3f;
            float gestureBottom = jointsPos[shoulderCenterIndex].y - bandSize * 1.8f / 3f;
            /*
            float gestureRight = jointsPos[rightHipIndex].x;
            float gestureLeft = jointsPos[leftHipIndex].x;
            */

            switch (gestureData.gesture)
            {
                // check for RaiseRightHand
                case Gestures.RaiseRightHand:
                    switch (gestureData.state)
                    {
                        case 0:  // gesture detection
                            if (jointsTracked[rightHandIndex] && jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                                (jointsPos[rightHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f &&
                                   (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) < 0f)
                            {
                                SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                            }
                            break;

                        case 1:  // gesture complete
                            bool isInPose = jointsTracked[rightHandIndex] && jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                                (jointsPos[rightHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f &&
                                (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) < 0f;

                            Vector3 jointPos = jointsPos[gestureData.joint];
                            CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, KinectInterop.Constants.PoseCompleteDuration);
                            break;
                    }
                    break;

                // check for RaiseLeftHand
                case Gestures.RaiseLeftHand:
                    switch (gestureData.state)
                    {
                        case 0:  // gesture detection
                            if (jointsTracked[leftHandIndex] && jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                                (jointsPos[leftHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f &&
                                   (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) < 0f)
                            {
                                SetGestureJoint(ref gestureData, timestamp, leftHandIndex, jointsPos[leftHandIndex]);
                            }
                            break;

                        case 1:  // gesture complete
                            bool isInPose = jointsTracked[leftHandIndex] && jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                                (jointsPos[leftHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f &&
                                (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) < 0f;

                            Vector3 jointPos = jointsPos[gestureData.joint];
                            CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, KinectInterop.Constants.PoseCompleteDuration);
                            break;
                    }
                    break;

                // check for Psi
                case Gestures.Psi:
                    switch (gestureData.state)
                    {
                        case 0:  // gesture detection
                            if (jointsTracked[rightHandIndex] && jointsTracked[leftHandIndex] && jointsTracked[shoulderCenterIndex] &&
                               (jointsPos[rightHandIndex].y - jointsPos[shoulderCenterIndex].y) > 0.1f &&
                               (jointsPos[leftHandIndex].y - jointsPos[shoulderCenterIndex].y) > 0.1f)
                            {
                                SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                            }
                            break;

                        case 1:  // gesture complete
                            bool isInPose = jointsTracked[rightHandIndex] && jointsTracked[leftHandIndex] && jointsTracked[shoulderCenterIndex] &&
                                (jointsPos[rightHandIndex].y - jointsPos[shoulderCenterIndex].y) > 0.1f &&
                                (jointsPos[leftHandIndex].y - jointsPos[shoulderCenterIndex].y) > 0.1f;

                            Vector3 jointPos = jointsPos[gestureData.joint];
                            CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, KinectInterop.Constants.PoseCompleteDuration);
                            break;
                    }
                    break;

                // check for Tpose
                case Gestures.Tpose:
                    switch (gestureData.state)
                    {
//.........这里部分代码省略.........
开发者ID:BrainProject,项目名称:UnityTemp,代码行数:101,代码来源:KinectGestures.cs


示例14: getNormalizedGestureData

    /// <summary>
    /// Gets the normalized gesture data.
    /// </summary>
    /// <returns>
    /// The normalized gesture data.
    /// </returns>
    /// <param name='resolution'>
    /// Resolution to normalize to.
    /// </param>
    public GestureData getNormalizedGestureData(float resolution)
    {
        var dx = (this.maximumX - this.minimumX) * 1.0f;
        var dy = (this.maximumY - this.minimumY) * 1.0f;

        if (dx > dy)
            dy = dx;
        else
            dx = dy;

        GestureData normalizedData = new GestureData();

        for (var i = 0; i < this.frames.Count; i++) {
            GestureFrame frame = (GestureFrame)this.frames[i];

            float x = (frame.position.x * 1.0f - this.minimumX) / dx * resolution;
            float y = resolution - (frame.position.y * 1.0f - this.minimumY) / dy * resolution;

            GestureFrame normalizedFrame = new GestureFrame(new Vector(x, y, 0.0f), frame.velocity, frame.timestamp);
            normalizedData.appendFrame(normalizedFrame);
        }

        return normalizedData;
    }
开发者ID:riazi,项目名称:leap_patterns,代码行数:33,代码来源:GestureData.cs


示例15: SetScreenPos

    private static void SetScreenPos(uint userId, ref GestureData gestureData, ref Vector3[] jointsPos, ref bool[] jointsTracked)
    {
        Vector3 handPos = jointsPos[rightHandIndex];
        //		Vector3 elbowPos = jointsPos[rightElbowIndex];
        //		Vector3 shoulderPos = jointsPos[rightShoulderIndex];
        bool calculateCoords = false;

        if(gestureData.joint == rightHandIndex)
        {
            if(jointsTracked[rightHandIndex] /**&& jointsTracked[rightElbowIndex] && jointsTracked[rightShoulderIndex]*/)
            {
                calculateCoords = true;
            }
        }
        else if(gestureData.joint == leftHandIndex)
        {
            if(jointsTracked[leftHandIndex] /**&& jointsTracked[leftElbowIndex] && jointsTracked[leftShoulderIndex]*/)
            {
                handPos = jointsPos[leftHandIndex];
        //				elbowPos = jointsPos[leftElbowIndex];
        //				shoulderPos = jointsPos[leftShoulderIndex];

                calculateCoords = true;
            }
        }

        if(calculateCoords)
        {
        //			if(gestureData.tagFloat == 0f || gestureData.userId != userId)
        //			{
        //				// get length from shoulder to hand (screen range)
        //				Vector3 shoulderToElbow = elbowPos - shoulderPos;
        //				Vector3 elbowToHand = handPos - elbowPos;
        //				gestureData.tagFloat = (shoulderToElbow.magnitude + elbowToHand.magnitude);
        //			}

            if(jointsTracked[hipCenterIndex] && jointsTracked[shoulderCenterIndex] &&
                jointsTracked[leftShoulderIndex] && jointsTracked[rightShoulderIndex])
            {
                Vector3 neckToHips = jointsPos[shoulderCenterIndex] - jointsPos[hipCenterIndex];
                Vector3 rightToLeft = jointsPos[rightShoulderIndex] - jointsPos[leftShoulderIndex];

                gestureData.tagVector2.x = rightToLeft.x; // * 1.2f;
                gestureData.tagVector2.y = neckToHips.y; // * 1.2f;

                if(gestureData.joint == rightHandIndex)
                {
                    gestureData.tagVector.x = jointsPos[rightShoulderIndex].x - gestureData.tagVector2.x / 2;
                    gestureData.tagVector.y = jointsPos[hipCenterIndex].y;
                }
                else
                {
                    gestureData.tagVector.x = jointsPos[leftShoulderIndex].x - gestureData.tagVector2.x / 2;
                    gestureData.tagVector.y = jointsPos[hipCenterIndex].y;
                }
            }

        //			Vector3 shoulderToHand = handPos - shoulderPos;
        //			gestureData.screenPos.x = Mathf.Clamp01((gestureData.tagFloat / 2 + shoulderToHand.x) / gestureData.tagFloat);
        //			gestureData.screenPos.y = Mathf.Clamp01((gestureData.tagFloat / 2 + shoulderToHand.y) / gestureData.tagFloat);

            if(gestureData.tagVector2.x != 0 && gestureData.tagVector2.y != 0)
            {
                Vector3 relHandPos = handPos - gestureData.tagVector;
                gestureData.screenPos.x = Mathf.Clamp01(relHandPos.x / gestureData.tagVector2.x);
                gestureData.screenPos.y = Mathf.Clamp01(relHandPos.y / gestureData.tagVector2.y);
            }

            //Debug.Log(string.Format("{0} - S: {1}, H: {2}, SH: {3}, L : {4}", gestureData.gesture, shoulderPos, handPos, shoulderToHand, gestureData.tagFloat));
        }
    }
开发者ID:songwanfu,项目名称:MotionSensing3DSolarSystem,代码行数:71,代码来源:KinectGestures.cs


示例16: SetWheelRotation

 private static void SetWheelRotation(uint userId, ref GestureData gestureData, Vector3 initialPos, Vector3 currentPos)
 {
     float angle = Vector3.Angle(initialPos, currentPos) * Mathf.Sign(currentPos.y - initialPos.y);
     gestureData.screenPos.z = angle;
 }
开发者ID:ReaperCZ,项目名称:UnityTemp,代码行数:5,代码来源:KinectWrapper.cs


示例17: SetZoomFactor

    private static void SetZoomFactor(uint userId, ref GestureData gestureData, float initialZoom, ref Vector3[] jointsPos, ref bool[] jointsTracked)
    {
        Vector3 vectorZooming = jointsPos[rightHandIndex] - jointsPos[leftHandIndex];

        if(gestureData.tagFloat == 0f || gestureData.userId != userId)
        {
            gestureData.tagFloat = 0.5f; // this is 100%
        }

        float distZooming = vectorZooming.magnitude;
        gestureData.screenPos.z = initialZoom + (distZooming / gestureData.tagFloat);
    }
开发者ID:songwanfu,项目名称:MotionSensing3DSolarSystem,代码行数:12,代码来源:KinectGestures.cs


示例18: CheckForGesture

    // estimate the next state and completeness of the gesture
    public static void CheckForGesture(uint userId, ref GestureData gestureData, float timestamp, ref Vector3[] jointsPos, ref bool[] jointsTracked)
    {
        if(gestureData.complete)
            return;

        switch(gestureData.gesture)
        {
            // check for RaiseRightHand
            case Gestures.RaiseRightHand:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                           (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                        }
                        break;

                    case 1:  // gesture complete
                        bool isInPose = jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                            (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f;

                        Vector3 jointPos = jointsPos[gestureData.joint];
                        CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, Constants.PoseCompleteDuration);
                        break;
                }
                break;

            // check for RaiseLeftHand
            case Gestures.RaiseLeftHand:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                                (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, leftHandIndex, jointsPos[leftHandIndex]);
                        }
                        break;

                    case 1:  // gesture complete
                        bool isInPose = jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                            (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f;

                        Vector3 jointPos = jointsPos[gestureData.joint];
                        CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, Constants.PoseCompleteDuration);
                        break;
                }
                break;

            // check for Psi
            case Gestures.Psi:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                           (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f &&
                           jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                           (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                        }
                        break;

                    case 1:  // gesture complete
                        bool isInPose = jointsTracked[rightHandIndex] && jointsTracked[rightShoulderIndex] &&
                            (jointsPos[rightHandIndex].y - jointsPos[rightShoulderIndex].y) > 0.1f &&
                            jointsTracked[leftHandIndex] && jointsTracked[leftShoulderIndex] &&
                            (jointsPos[leftHandIndex].y - jointsPos[leftShoulderIndex].y) > 0.1f;

                        Vector3 jointPos = jointsPos[gestureData.joint];
                        CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, Constants.PoseCompleteDuration);
                        break;
                }
                break;

            // check for Stop
            case Gestures.Stop:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection
                        if(jointsTracked[rightHandIndex] && jointsTracked[rightHipIndex] &&
                           (jointsPos[rightHandIndex].y - jointsPos[rightHipIndex].y) < 0f &&
                           jointsTracked[leftHandIndex] && jointsTracked[leftHipIndex] &&
                           (jointsPos[leftHandIndex].y - jointsPos[leftHipIndex].y) < 0f)
                        {
                            SetGestureJoint(ref gestureData, timestamp, rightHandIndex, jointsPos[rightHandIndex]);
                        }
                        break;

                    case 1:  // gesture complete
                        bool isInPose = jointsTracked[rightHandInde 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GestureEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# Gesture类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap