Note that there are some explanatory texts on larger screens.

plurals
  1. POGet only ONE player in kinect
    primarykey
    data
    text
    <p>i want to track only one person through the kinect and i wanna track its skeletal data and at the same time i want to show the depth from containing only that player but not the other players.</p> <p>Attached here is the code responsible for that, CAN anyone HELP ?!!</p> <pre><code>void mySensor_AllFramesReady(object sender, AllFramesReadyEventArgs e) { if (closing) return; using (DepthImageFrame depthFrame = e.OpenDepthImageFrame()) { if (depthFrame == null) { return; } byte[] pixels = GenerateDepthImage(depthFrame); int stride = depthFrame.Width * 4; depthImage.Source = BitmapSource.Create(depthFrame.Width, depthFrame.Height, 96, 96, PixelFormats.Bgra32, null, pixels, stride); } //Get a skeleton Skeleton first = GetFirstSkeleton(e); ProcessSkeletalData(first, e); } </code></pre> <p>and here is the method of generating depth image:</p> <pre><code>private byte[] GenerateDepthImage(DepthImageFrame depthFrame) { //get the raw data from kinect with the depth for every pixel short[] rawDepthData = new short[depthFrame.PixelDataLength]; depthFrame.CopyPixelDataTo(rawDepthData); //use depthFrame to create the image to display on-screen //depthFrame contains color information for all pixels in image //Height x Width x 4 (Red, Green, Blue, empty byte) Byte[] pixels = new byte[depthFrame.Height * depthFrame.Width * 4]; //Bgr32 - Blue, Green, Red, empty byte //Bgra32 - Blue, Green, Red, transparency //You must set transparency for Bgra as .NET defaults a byte to 0 = fully transparent //hardcoded locations to Blue, Green, Red (BGR) index positions const int BlueIndex = 0; const int GreenIndex = 1; const int RedIndex = 2; const int AlphaIndex = 3; //loop through all distances //pick a RGB color based on distance for (int depthIndex = 0, colorIndex = 0; depthIndex &lt; rawDepthData.Length &amp;&amp; colorIndex &lt; pixels.Length; depthIndex++, colorIndex += 4) { //get the player (requires skeleton tracking enabled for values) int player = rawDepthData[depthIndex] &amp; DepthImageFrame.PlayerIndexBitmask; //gets the depth value int depth = rawDepthData[depthIndex] &gt;&gt; DepthImageFrame.PlayerIndexBitmaskWidth; pixels[colorIndex + BlueIndex] = 255; pixels[colorIndex + GreenIndex] = 255; pixels[colorIndex + RedIndex] = 255; pixels[colorIndex + AlphaIndex] = 0; //Color all players //Debug.WriteLine(player); if (player &gt; 0 ) { pixels[colorIndex + BlueIndex] = 0; pixels[colorIndex + GreenIndex] = 0; pixels[colorIndex + RedIndex] = 0; pixels[colorIndex + AlphaIndex] = 40; } } return pixels; } </code></pre> <p>The code of GetFirstSkeleton MEthod</p> <pre><code>Skeleton GetFirstSkeleton(AllFramesReadyEventArgs e) { using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame()) { if (skeletonFrameData == null) return null; skeletonFrameData.CopySkeletonDataTo(allSkeletons); //get the first tracked skeleton Skeleton first = (from s in allSkeletons where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault(); return first; } } </code></pre> <p>The problem is here i have all the players UP TO 6 players detected by the depth image while only one by the skeleton tracking and i want to have only one in both, the same player.</p> <p>When i changed from player > 0 to player ==1 it didn't work because the player is not always with id 1.</p> <p>Any idea how to solve the matter ?!</p> <p>Thanks a lot, Michael</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload