/// <summary>
 /// Depending on color format, the frame is passed on or buffered for conversion.
 /// </summary>
 private void OnFrameArrived(object sender, FrameArrivedEventArgs e)
 {
     if (Format == ColorFormat.Grayscale)
     {
         _frame = e.Frame;
         FPSUtils.VideoTick();
         FrameArrived?.Invoke(this, e);
     }
     else
     {
         if (IsProcessingFrame)
         {
             return;
         }
         IsProcessingFrame  = true;
         CurrentCameraFrame = e.Frame;
     }
 }
        /// <summary>
        /// Invoked if the NV12 to RGB conversion is complete and the data is ready to be read to the CPU.
        /// </summary>
        private void OnCompleteReadback(AsyncGPUReadbackRequest request)
        {
            if (request.hasError)
            {
                Debug.LogError("GPU readback error");
                return;
            }

            MatUtils.copyToMat(request.GetData <uint>(), _rgb);
            Core.flip(_rgb, _rgb, 0); // image is flipped on x-axis
            CameraFrame           newFrame = new CameraFrame(_rgb, CurrentCameraFrame.Intrinsic, CurrentCameraFrame.Extrinsic, CurrentCameraFrame.Width, CurrentCameraFrame.Height, CurrentCameraFrame.FrameCount, Format);
            FrameArrivedEventArgs args     = new FrameArrivedEventArgs(newFrame);

            _frame = newFrame;
            FrameArrived?.Invoke(this, args);
            FPSUtils.VideoTick();
            NewFrameAvailable = true;
            IsProcessingFrame = false;
        }