/// <summary>
        /// YUV-RAW conversion. YUV Raw has 2 bytes per pixel, not 4 like it is the case with
        /// RGB and YUV
        /// </summary>
        /// <param name="frameInfo">Frame info</param>
        /// <param name="rawColorData">Raw frame data</param>
        /// <param name="resultingImage">Processed visible image</param>
        private unsafe void DoProcessVisualImageForWebCamAlternateYUVRaw(
            KinectFrameInfo frameInfo,
            byte[] rawColorData,
            byte[] resultingImage)
        {
            int height = frameInfo.Height;
            int width  = frameInfo.Width;

            // The following fixed statement pins the location of
            // the src and dst objects in memory so that they will
            // not be moved by garbage collection (perf)
            fixed(byte *ptrSrc = rawColorData, ptrDest = resultingImage)
            {
                for (int y = 0; y < height; ++y)
                {
                    // we pre-calc those for perf reasons (profiler-verified to have a significant effect)
                    int yTImesWidth          = y * width;
                    int yTImesWidthPlusWidth = (y * width) + width;

                    for (int x = 0; x < width; ++x)
                    {
                        int i = (yTImesWidth + x) * 3;
                        int j = (yTImesWidthPlusWidth - x - 1) * 2;

                        *(short *)(ptrDest + i) = *(short *)(ptrSrc + j);
                    }
                }
            }
        }
        /// <summary>
        /// Non YUV-raw coversion
        /// </summary>
        /// <param name="frameInfo">Frame info</param>
        /// <param name="rawColorData">Raw frame data</param>
        /// <param name="visibleImage">Processed visible image</param>
        private unsafe void DoProcessVisualImageForWebCamAlternateRgbYuv(KinectFrameInfo frameInfo, byte[] rawColorData, byte[] visibleImage)
        {
            int height = frameInfo.Height;
            int width  = frameInfo.Width;

            // The following fixed statement pins the location of
            // the src and dst objects in memory so that they will
            // not be moved by garbage collection (perf)
            fixed(byte *ptrSrc = rawColorData, ptrDest = visibleImage)
            {
                // we need to cut the 4th byte to conform to 24 bit color image format expected by
                // cameras we also need to flip image along the vertical axis to make sure depth and
                // rgb images have same orientation (raw buffers are oppositely oriented)

                for (int y = 0; y < height; ++y)
                {
                    // we pre-calc those for perf reasons (profiler-verified to have a significant effect)
                    int yTImesWidth          = y * width;
                    int yTImesWidthPlusWidth = (y * width) + width;

                    for (int x = 0; x < width; ++x)
                    {
                        int i = (yTImesWidth + x) * 3;
                        int j = (yTImesWidthPlusWidth - x - 1) * 4;

                        *(ThreeByteStruct *)(ptrDest + i) = *(ThreeByteStruct *)(ptrSrc + j);
                    }
                }
            }
        }
 /// <summary>
 /// Binary serializaiton of Kinect frame info for cross-DSS node communicaiton
 /// </summary>
 /// <param name="frameInfo">Kinect frame info</param>
 /// <param name="writer">Binary Writer</param>
 private void SerializeFrameInfo(KinectFrameInfo frameInfo, BinaryWriter writer)
 {
     writer.Write(1);
     writer.Write((int)frameInfo.FrameNumber);
     writer.Write((int)frameInfo.BytesPerPixel);
     writer.Write((int)frameInfo.Height);
     writer.Write((int)frameInfo.Width);
     writer.Write((long)frameInfo.Timestamp);
 }
        /// <summary>
        /// Binary deserializer for Kinect frame info
        /// </summary>
        /// <param name="reader">Binary reader</param>
        /// <returns>New KinectFrame instance</returns>
        private KinectFrameInfo DeserializeFrameInfo(BinaryReader reader)
        {
            KinectFrameInfo frameInfo = new KinectFrameInfo();

            frameInfo.FrameNumber   = reader.ReadInt32();
            frameInfo.BytesPerPixel = reader.ReadInt32();
            frameInfo.Height        = reader.ReadInt32();
            frameInfo.Width         = reader.ReadInt32();
            frameInfo.Timestamp     = reader.ReadInt64();

            return(frameInfo);
        }
        /// <summary>
        /// Converts depth + player data returned by Kinect sensor to depth 'image' - a matrix of
        /// shorts with distances in mm. The depth frame returned from the Kinect is mirrored.
        /// We not only have to do bitshifts, but also flip the image.
        /// </summary>
        /// <param name="frameInfo">Frame info</param>
        /// <param name="rawDepthData">Raw frame data</param>
        /// <param name="depthImage">Procesed frame</param>
        private void DoProcessDepthAndPlayerIndexDataForDepthCamAlternate(
            KinectFrameInfo frameInfo,
            short[] rawDepthData,
            short[] depthImage)
        {
            int height = frameInfo.Height;
            int width  = frameInfo.Width;

            for (int y = 0; y < height; ++y)
            {
                // we pre-calc those for perf reasons (profiler-verified to have a significant effect)
                int yTImesWidth          = y * width;
                int yTImesWidthPlusWidth = (y * width) + width;

                for (int x = 0; x < width; ++x)
                {
                    int i = yTImesWidth + x;
                    int j = yTImesWidthPlusWidth - x - 1;

                    depthImage[i] = (short)(rawDepthData[j] >> 3);
                }
            }
        }