How to get depth player from Kinect SDK C # data?

The implementation of a group project trying to do something when a player (in particular, a player) is close / far, so we wrote this function. (We are not allowed to use skeleton functions)

private void FindDepth(DepthImageFrame depthFrame) { short[] rawDepthData = new short[depthFrame.PixelDataLength]; depthFrame.CopyPixelDataTo(rawDepthData); Byte[] pixels = new byte[depthFrame.Height * depthFrame.Width * 4]; for (int depthIndex = 0; depthIndex < rawDepthData.Length; depthIndex++) { int player = rawDepthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask; int depth = rawDepthData[depthIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth; if (player > 0) { playerDepth = rawDepthData[depthIndex]; } } } 

Why doesn't it properly capture the depth of the player by capturing one pixel?

+4
source share
2 answers

The deep pixel is represented as 16 bits. The lower 3 bits provide the player index and the remaining 13 bits provide depth, for example. {bit depth} {bit index player}

{0100 1011 1001 0} {010}

so that to find the player index we AND by DepthImageFrame.PlayerIndexBitmask as shown below

(0100 1011 1001 0010) AND (0000 0000 0000 0111) = 0000 0000 0000 0010 = 2 i.e. second player

and in order to find the distance, we shift to the right by 3 bits, which return 13 bits, as shown below 0000 1001 0111 0010 = 2418, i.e. 2418 mm

+3
source

It is important to remember that player numbers are only added to the depth image if skeleton tracking is enabled. If skeleton tracking is turned off, the player number at each depth value is 0.

0
source

Source: https://habr.com/ru/post/1401699/


All Articles