public void OnNewFrame(Astra.ColorFrame frame)
    {
        if (frame.Width == 0 ||
            frame.Height == 0)
        {
            return;
        }

        if (_lastFrameIndex == frame.FrameIndex)
        {
            return;
        }

        _lastFrameIndex = frame.FrameIndex;
        frame.CopyData(ref _colorMapData);
        // unfortunately we have to convert from byte[] to float[]
        // as compute shaders don't support byte data type
        for (int i = 0; i < _colorMapDataFloat.Length; i++)
        {
            _colorMapDataFloat[i] = _colorMapData[i];
        }
        _colorMapBuffer.SetData(_colorMapDataFloat);
        RunShader();
        BakeShaderData();
    }
Beispiel #2
0
        public void OnNewFrame(Astra.ColorFrame frame)
        {
            if (frame.Width == 0 ||
                frame.Height == 0)
            {
                return;
            }

            if (_lastFrameIndex == frame.FrameIndex)
            {
                return;
            }

            _lastFrameIndex = frame.FrameIndex;

            EnsureTexture(frame.Width, frame.Height);
            _YImageTex.LoadRawTextureData(frame.DataPtr, (int)frame.Width * frame.Height);
            _YImageTex.Apply();
            var ptr = new IntPtr(frame.DataPtr.ToInt64() + frame.Width * frame.Height);

            _UVImageTex.LoadRawTextureData(ptr, (int)frame.Width * frame.Height / 2);
            _UVImageTex.Apply();
            GetComponent <Renderer>().material.SetTexture("_MainTex", _YImageTex);
            GetComponent <Renderer>().material.SetTexture("_UVTex", _UVImageTex);
        }
    public void OnNewFrame(Astra.ColorFrame frame)
    {
        if (frame.Width == 0 ||
            frame.Height == 0)
        {
            return;
        }

        if (_lastFrameIndex == frame.FrameIndex)
        {
            return;
        }

        _lastFrameIndex = frame.FrameIndex;

        EnsureTexture(frame.Width, frame.Height);
        _texture.LoadRawTextureData(frame.DataPtr, (int)frame.ByteLength);
        _texture.Apply();
    }