Search code examples
c#kinect

Kinect user Detection


I am developing an application When an kinect sensor detects an skeleton that person can work on it if other person comes near to the existing user it detects the second person.
I want to restrict to the user the kinect sensor first detects it if other user comes this should not detect the other one.
thanks in advance


Solution

  • Also see Jurgeon D's answer on Kinect SDK player detection, as it deals with skeleton index. @Fixus is also right in that you could use a ID. But if you mean more than 2 people are detected, then only one is detected, that is not programming, that is in the Kinect's hardware and @FelixK. was right.

    Skeletal Index

    void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) 
    {
        SkeletonFrame sf = e.SkeletonFrame;
        //check which skeletons in array are active and
        // use that array indexes for player index
        SkeletonData player1 = sf.Skeletons[playerIndex1];
        SkeletonData player2 = sf.Skeletons[playerIndex2];
    }
    

    Skeletal IDs

    void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
    {
        SkeletonFrame sf = e.SkeletonFrame;
    
        if (sf.TrackingState == SkeletalTrackingState.Tracked)
         {
              int ID1 = sf.TrackingID;
         }
    

    Also the code for detecting humans

     DepthImageFrame depthFrame;
     short[] rawDepthData = new short[depthFrame.PixelDataLength];
     depthFrame.CopyPixelDataTo(rawDepthData); 
     Byte[] pixels = new byte[depthFrame.Height * depthFrame.Width * 4];     
     int player = rawDepthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
    
     if (player > 0)
     {
         //do something
     }