Kinect user Detection

前端 未结 5 1819
Happy的楠姐
Happy的楠姐 2020-11-28 14:42

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 per

相关标签:
5条回答
  • 2020-11-28 15:30

    In one of the kinect quick start tutorials there is a method for detecting only one user. I tried it for my own application and it worked.

    using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
    {
        if (skeletonFrame == null)
                    return;
    
        Skeleton[] skeletons= new Skeleton[skeletonFrame.SkeletonArrayLength];
        skeletonFrame.CopySkeletonDataTo(skeletons);
    
        if (skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
                    return;
    
        Skeleton skeleton = (from s in skeletons
                                     where s.TrackingState == SkeletonTrackingState.Tracked
                                     select s).FirstOrDefault();
        if (skeleton == null) return;
    
        // TODO: Do something to the skeleton data...
    
    }
    
    0 讨论(0)
  • 2020-11-28 15:33

    Kinect will detec the new user cause it is his job :) BUT remember that every user has his own ID so you always know that the first user is first and second is second. That way you can work only on the skeleton of the user that you want to work with

    0 讨论(0)
  • 2020-11-28 15:38

    If i understand your question correctly this is not possible, you can't modify the Kinects behaviour and how it detects users ( If there is nothing in the Framework; i don't think there is something ).

    You have to solve this in your code.

    0 讨论(0)
  • 2020-11-28 15:41
    KinectManager kinectManager = KinectManager.Instance;
    AvatarController avatarCtrl = avatar ? avatar.gameObject.GetComponent<AvatarController> () : null;
    
    if (kinectManager != null && kinectManager.IsInitialized () && avatar != null && avatarCtrl && kinectManager.IsUserTracked (avatarCtrl.playerId)) {
            //User detected. You can do the remaining thing.
    }
    
    0 讨论(0)
  • 2020-11-28 15:44

    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
     }      
    
    0 讨论(0)
提交回复
热议问题