Ejemplo n.º 1
0
    // methods to encompass the pose detection capability

    /// @brief Gets a string array of supported poses
    ///
    /// @return An array of supported poses, null if invalid or no supported poses
    public string[] GetAllAvailablePoses()
    {
        if (!Valid)
        {
            return(null);
        }
        PoseDetectionCapability cap = UserNode.PoseDetectionCapability;

        if (cap == null)
        {
            return(null);
        }
        return(cap.GetAllAvailablePoses());
    }
Ejemplo n.º 2
0
    /// @brief Initialize the user and skeleton information
    ///
    /// This method initializes the user and skeleton information. It assumes the
    /// context is already valid (otherwise we fail).
    /// @note - Since we use a singleton pattern, multiple initializations will simply delete
    /// the old information and create new one!
    /// @note - It is the responsibility of the initializer to call @ref Dispose.
    /// @param context the context used
    /// @param logger the logger object we will enter logs into
    /// @return true on success, false on failure.
    public bool Init(NIEventLogger logger, NIContext context)
    {
        NIOpenNICheckVersion.Instance.ValidatePrerequisite();
        Dispose(); // to make sure we are not initialized
        if (InitWithContext(logger, context) == false)
        {
            return(false);
        }

        m_userGenerator = context.CreateNode(NodeType.User) as UserGenerator;
        if (m_userGenerator == null || m_userGenerator.SkeletonCapability == null)
        {
            Log("Failed to create proper user generator.", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.Skeleton, NIEventLogger.VerboseLevel.Errors);
            // we either don't have a user generator or the user generator we received does not have a skeleton
            Dispose();
            return(false);
        }
        // skeleton heuristics tries to handle the skeleton when the confidence is low. It can
        // have two values: 0 (no heuristics) or 255 (use heuristics).
        m_userGenerator.SetIntProperty("SkeletonHeuristics", 255);
        // makes sure we use all joints
        m_userGenerator.SkeletonCapability.SetSkeletonProfile(SkeletonProfile.All);
        PoseDetectionCapability cap = UserNode.PoseDetectionCapability;

        if (cap != null)
        {
            m_legalPoses = cap.GetAllAvailablePoses();
        }
        else
        {
            m_legalPoses = null;
        }
        m_poseDetectionCounter    = new List <poseDetectionReferenceCounter>();
        m_userGenerator.LostUser += new EventHandler <UserLostEventArgs>(LostUserCallback);

        return(true);
    }