RawToPlayerIndex() public static method

public static RawToPlayerIndex ( short raw ) : int
raw short
return int
Beispiel #1
0
        public static void ColorPlayers(short[] depthFrame, byte[] colorFrame)
        {
            Array.Clear(colorFrame, 0, colorFrame.Length);
            for (int depthIndex = 0, colorIndex = 0; colorIndex < colorFrame.Length; depthIndex++,
                 colorIndex += Bgr32BytesPerPixel)
            {
                short pixel  = depthFrame[depthIndex];
                int   player = DepthUtil.RawToPlayerIndex(pixel);

                if (player != 0)
                {
                    colorFrame[colorIndex + RedIndex]   = 0xff;
                    colorFrame[colorIndex + GreenIndex] = 0;
                    colorFrame[colorIndex + BlueIndex]  = 0;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates depth player masks.
        /// </summary>
        /// <param name="depthFrame"></param>
        void UpdatePlayerMask(short[] depthFrame)
        {
            CvInvoke.cvZero(DepthPlayerMask.Ptr);
            var data = DepthPlayerMask.Data;

            for (int r = 0; r < height; r++)
            {
                for (int c = 0; c < width; c++)
                {
                    var   index       = r * width + c;
                    short pixel       = depthFrame[index];
                    int   playerIndex = DepthUtil.RawToPlayerIndex(pixel);
                    if (playerIndex > 0)
                    {
                        data[r, c, 0] = 255;
                    }
                }
            }

            CvInvoke.cvMorphologyEx(DepthPlayerMask.Ptr, DepthPlayerMask.Ptr,
                                    IntPtr.Zero, IntPtr.Zero, CV_MORPH_OP.CV_MOP_OPEN, CvOpenIter);
        }