Exemple #1
0
        /// <summary>
        /// According to the xml records being sent by the camera as initial sequence, a confidence image comes with 16 bits per pixel such that the lowest possible value is 0 and the highest possible value is 65535.
        /// Scale this range to [0, 1].
        /// </summary>
        /// <param name="rawConfidenceMap">Confidence map as provided by the camera</param>
        /// <returns>Confidence map as float image scaled to [0, 1] range</returns>
        private FloatCameraImage CalcConfidenceMap(UShortCameraImage rawConfidenceMap)
        {
            int   width   = rawConfidenceMap.Width;
            int   height  = rawConfidenceMap.Height;
            float scaling = 1.0f / (float)ushort.MaxValue;

            FloatCameraImage confidenceMap = new FloatCameraImage(width, height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    confidenceMap[y, x] = scaling * rawConfidenceMap[y, x];
                }
            }

            return(confidenceMap);
        }
Exemple #2
0
        /// <summary>
        /// Calculates the confidence map.
        /// </summary>
        /// <returns>Confidence map</returns>
        private UShortCameraImage CalcRawConfidenceMap()
        {
            UShortCameraImage result;

            lock (cameraLock)
            {
                result           = new UShortCameraImage(imageData.Width, imageData.Height);
                result.TimeStamp = (long)imageData.TimeStamp;
                int start = imageData.ConfidenceStartOffset;
                for (int i = 0; i < imageData.Height; ++i)
                {
                    for (int j = 0; j < imageData.Width; ++j)
                    {
                        // take two bytes and create integer (little endian)
                        result[i, j] = (ushort)((ushort)imageBuffer[start + 1] << 8 | (ushort)imageBuffer[start + 0]);
                        start       += 2;
                    }
                }
            }
            return(result);
        }