示例#1
0
    /// @brief Gets the current pose status.
    ///
    /// @param userID The openNI user id whose status we seek
    /// @param poseName The name of the pose we want status on
    /// @param status a reference to the status we want to fill.
    /// @return true on success and false on failure.
    public bool GetPoseStatus(int userID, string poseName, ref NIPoseDetectionStateStatus status)
    {
        if (!Valid)
        {
            return(false);
        }
        PoseDetectionCapability cap = UserNode.PoseDetectionCapability;

        if (cap == null)
        {
            return(false);
        }
        PoseDetectionStateStatus openNIStatus;

        try
        {
            openNIStatus = cap.GetPoseStatus(userID, poseName);
        }
        catch (System.Exception ex)
        {
            Log("Failed to get pose status for userID " + userID + " pose " + poseName + " with message " + ex.Message, NIEventLogger.Categories.Misc, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors);
            return(false);
        }

        status.m_eState  = openNIStatus.m_eState;
        status.m_eStatus = openNIStatus.m_eStatus;
        if (openNIStatus.m_poseTime <= 0 || openNIStatus.m_eState == PoseDetectionState.OutOfPose)
        {
            status.m_timePoseHeld = -1.0f;
        }
        else
        {
            long userGeneratorTime = m_userGenerator.Timestamp;
            if (userGeneratorTime <= openNIStatus.m_poseTime)
            {
                status.m_timePoseHeld = -1.0f;
            }
            else
            {
                userGeneratorTime     -= openNIStatus.m_poseTime;
                status.m_timePoseHeld  = (float)userGeneratorTime;
                status.m_timePoseHeld /= 1000000.0f;     // to transform from microseconds to seconds
                status.m_timePoseHeld *= Time.timeScale; // to convert the coodrinates based on Time scale
            }
        }
        return(true);
    }
    /// @brief Gets the current pose status.
    /// 
    /// @param userID The openNI user id whose status we seek
    /// @param poseName The name of the pose we want status on
    /// @param status a reference to the status we want to fill.
    /// @return true on success and false on failure.
    public bool GetPoseStatus(int userID, string poseName, ref NIPoseDetectionStateStatus status)
    {
        if (!Valid)
            return false;
        PoseDetectionCapability cap = UserNode.PoseDetectionCapability;
        if (cap == null)
            return false;
        PoseDetectionStateStatus openNIStatus;
        try
        {
             openNIStatus = cap.GetPoseStatus(userID, poseName);
        }
        catch (System.Exception ex)
        {
            Log("Failed to get pose status for userID " + userID + " pose " + poseName + " with message "+ex.Message, NIEventLogger.Categories.Misc, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors);
            return false;
        }

        status.m_eState = openNIStatus.m_eState;
        status.m_eStatus = openNIStatus.m_eStatus;
        if (openNIStatus.m_poseTime <= 0 || openNIStatus.m_eState == PoseDetectionState.OutOfPose)
        {
            status.m_timePoseHeld = -1.0f;
        }
        else
        {
            long userGeneratorTime = m_userGenerator.Timestamp;
            if (userGeneratorTime <= openNIStatus.m_poseTime)
            {
                status.m_timePoseHeld = -1.0f;
            }
            else
            {
                userGeneratorTime -= openNIStatus.m_poseTime;
                status.m_timePoseHeld = (float)userGeneratorTime;
                status.m_timePoseHeld /= 1000000.0f; // to transform from microseconds to seconds
                status.m_timePoseHeld *= Time.timeScale; // to convert the coodrinates based on Time scale
            }
        }
        return true;
    }