예제 #1
0
        private byte[] getDepthJPG(DepthReadResult result)
        {
            var texture = new Texture2D(result.depthWidth, result.depthHeight);

            for (var y = 0; y < result.depthHeight; y++)
            {
                for (var x = 0; x < result.depthWidth; x++)
                {
                    var   v = result.depthData[y * result.depthWidth + x];
                    Color color;
                    if (float.IsNaN(v))
                    {
                        color = new Color(0f, 1f, 0f);
                    }
                    else
                    {
                        color = new Color(v, v, v);
                    }
                    texture.SetPixel(x, y, color);
                }
            }

            texture.Apply();
            var jpg = texture.EncodeToJPG(100);

            Destroy(texture);
            return(jpg);
        }
예제 #2
0
        private byte[] getimgJPG(DepthReadResult result)
        {
            var texture = new Texture2D(result.imgWidth, result.imgHeight);

            for (var y = 0; y < result.imgHeight; y++)
            {
                for (var x = 0; x < result.imgWidth; x++)
                {
                    var b     = result.imgData[(y * result.imgWidth + x) * 4];
                    var g     = result.imgData[(y * result.imgWidth + x) * 4 + 1];
                    var r     = result.imgData[(y * result.imgWidth + x) * 4 + 2];
                    var a     = result.imgData[(y * result.imgWidth + x) * 4 + 3];
                    var color = new Color(r / 255f, g / 255f, b / 255f, a / 255f);
                    texture.SetPixel(x, y, color);
                }
            }

            texture.Apply();
            var jpg = texture.EncodeToJPG(100);

            Destroy(texture);
            return(jpg);
        }