/// <summary>
 /// Gets latest frame from the frame stream.
 /// Frames update only if stream has been started.
 /// May be called from main thread only.
 /// </summary>
 /// <returns>Latest Distorted color stream frame.</returns>
 public VarjoDistortedColorFrame GetFrame()
 {
     lock (mutex)
     {
         var frame = new VarjoDistortedColorFrame();
         frame.timestamp    = data.timestamp;
         frame.metadata     = new VarjoCameraMetadata(data);
         frame.leftTexture  = leftBuffer.GetTexture2D();
         frame.rightTexture = rightBuffer.GetTexture2D();
         return(frame);
     }
 }
 /// <summary>
 /// Gets latest frame from the frame stream.
 /// Frames update only if stream has been started.
 /// May be called from main thread only.
 /// </summary>
 /// <returns>Latest Distorted color stream frame.</returns>
 public VarjoDistortedColorFrame GetFrame()
 {
     lock (mutex)
     {
         var frame = new VarjoDistortedColorFrame();
         frame.timestamp               = data.timestamp;
         frame.ev                      = data.ev;
         frame.exposureTime            = data.exposureTime;
         frame.whiteBalanceTemperature = data.whiteBalanceTemperature;
         frame.whiteBalanceGains       = new Color(
             (float)data.whiteBalanceColorGainR,
             (float)data.whiteBalanceColorGainG,
             (float)data.whiteBalanceColorGainB
             );
         frame.leftTexture  = leftBuffer.GetTexture2D();
         frame.rightTexture = rightBuffer.GetTexture2D();
         return(frame);
     }
 }
        /// <summary>
        /// Gets latest frame from the frame stream.
        /// Frames update only if stream has been started.
        /// May be called from main thread only.
        /// </summary>
        /// <returns>Latest Distorted color stream frame.</returns>
        public VarjoDistortedColorFrame GetFrame()
        {
            lock (mutex)
            {
                var frame = new VarjoDistortedColorFrame();
                frame.timestamp               = data.timestamp;
                frame.ev                      = data.ev;
                frame.exposureTime            = data.exposureTime;
                frame.whiteBalanceTemperature = data.whiteBalanceTemperature;
                frame.wbNormalizationData     = new VarjoWBNormalizationData();

                if (data.wbNormalizationData.wbGains != null)
                {
                    frame.wbNormalizationData.wbGains = new Color(
                        (float)data.wbNormalizationData.wbGains[0],
                        (float)data.wbNormalizationData.wbGains[1],
                        (float)data.wbNormalizationData.wbGains[2]
                        );
                }

                if (data.wbNormalizationData.invCCM != null)
                {
                    frame.wbNormalizationData.invCCM = new Matrix4x4(
                        new Vector4(
                            (float)data.wbNormalizationData.invCCM[0],
                            (float)data.wbNormalizationData.invCCM[1],
                            (float)data.wbNormalizationData.invCCM[2],
                            0.0f),
                        new Vector4(
                            (float)data.wbNormalizationData.invCCM[3],
                            (float)data.wbNormalizationData.invCCM[4],
                            (float)data.wbNormalizationData.invCCM[5],
                            0.0f),
                        new Vector4(
                            (float)data.wbNormalizationData.invCCM[6],
                            (float)data.wbNormalizationData.invCCM[7],
                            (float)data.wbNormalizationData.invCCM[8],
                            0.0f),
                        new Vector4(0.0f, 0.0f, 0.0f, 1.0f)
                        );
                }

                if (data.wbNormalizationData.ccm != null)
                {
                    frame.wbNormalizationData.ccm = new Matrix4x4(
                        new Vector4(
                            (float)data.wbNormalizationData.ccm[0],
                            (float)data.wbNormalizationData.ccm[1],
                            (float)data.wbNormalizationData.ccm[2],
                            0.0f),
                        new Vector4(
                            (float)data.wbNormalizationData.ccm[3],
                            (float)data.wbNormalizationData.ccm[4],
                            (float)data.wbNormalizationData.ccm[5],
                            0.0f),
                        new Vector4(
                            (float)data.wbNormalizationData.ccm[6],
                            (float)data.wbNormalizationData.ccm[7],
                            (float)data.wbNormalizationData.ccm[8],
                            0.0f),
                        new Vector4(0.0f, 0.0f, 0.0f, 1.0f)
                        );
                }

                frame.cameraCalibrationConstant = data.cameraCalibrationConstant;
                frame.leftTexture  = leftBuffer.GetTexture2D();
                frame.rightTexture = rightBuffer.GetTexture2D();
                return(frame);
            }
        }