public void TakePhoto()
        {
            if (CompositorWrapper.IsInitialized)
            {
                var dslrTexture = CompositorWrapper.Instance.GetVideoCameraTexture();
                var fileName    = CalibrationDataHelper.GetUniqueFileName();
                CalibrationDataHelper.SaveChessboardImage(dslrTexture, fileName);

                if (!ProcessChessboardImage(dslrTexture))
                {
                    Debug.LogWarning($"Failed to process/locate chessboard in dataset: {fileName}");
                }
                else
                {
                    processedImageCount++;
                    CalibrationDataHelper.SaveChessboardDetectedImage(dslrTexture, fileName);
                    CalibrationDataHelper.SaveImage(chessboardHeatmap, "ChessboardHeatmap");
                    CalibrationDataHelper.SaveImage(chessboardCorners, "ChessboardCorners");
                }
            }
            else
            {
                Debug.LogWarning("CompositorWrapper isn't initialized, failed to take photo.");
            }
        }
        private void Update()
        {
            if (feedImage != null &&
                feedImage.texture == null)
            {
                feedImage.texture = CompositorWrapper.Instance.GetVideoCameraFeed();
            }

            if (cornersImage)
            {
                cornersImage.texture = chessboardCorners;
            }

            if (heatmapImage)
            {
                heatmapImage.texture = chessboardHeatmap;
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                var dslrTexture = CompositorWrapper.Instance.GetVideoCameraTexture();
                var fileName    = CalibrationDataHelper.GetUniqueFileName();
                CalibrationDataHelper.SaveChessboardImage(dslrTexture, fileName);

                if (!ProcessChessboardImage(dslrTexture))
                {
                    Debug.LogWarning($"Failed to process/locate chessboard in dataset: {fileName}");
                }
                else
                {
                    CalibrationDataHelper.SaveChessboardDetectedImage(dslrTexture, fileName);
                    CalibrationDataHelper.SaveImage(chessboardHeatmap, "ChessboardHeatmap");
                    CalibrationDataHelper.SaveImage(chessboardCorners, "ChessboardCorners");
                }
            }

            if (Input.GetKeyDown(KeyCode.Return))
            {
                Debug.Log("Starting Camera Intrinsics calculation.");
                intrinsics = CalibrationAPI.Instance.CalculateChessboardIntrinsics(chessSquareSize);
                Debug.Log($"Chessboard intrinsics reprojection error: {intrinsics.ToString()}");
                var file = CalibrationDataHelper.SaveCameraIntrinsics(intrinsics);
                Debug.Log($"Camera Intrinsics saved to file: {file}");
            }
        }
        private void Update()
        {
            if (feedImage != null &&
                feedImage.texture == null)
            {
                feedImage.texture = CompositorWrapper.Instance.GetVideoCameraFeed();
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                RequestHeadsetData();
            }

            if (headsetData != null)
            {
                lastDetectedMarkersCount = headsetData.markers.Count;
                if (headsetData.markers.Count < MinimumNumberOfDetectedMarkers)
                {
                    Debug.Log("Data set did not contain enough markers to use.");
                }
                else
                {
                    var dslrTexture = CompositorWrapper.Instance.GetVideoCameraTexture();
                    var fileName    = CalibrationDataHelper.GetUniqueFileName();
                    CalibrationDataHelper.SaveDSLRArUcoImage(dslrTexture, fileName);
                    CalibrationDataHelper.SaveHeadsetData(headsetData, fileName);

                    if (ProcessArUcoData(headsetData, dslrTexture))
                    {
                        processedDatasetCount++;
                        CalibrationDataHelper.SaveDSLRArUcoDetectedImage(dslrTexture, fileName);
                        CreateVisual(headsetData, fileName);
                    }
                }

                headsetData = null;
            }

            if (Input.GetKeyDown(KeyCode.Return))
            {
                CalculateExtrinsics();
            }
        }
        private void Update()
        {
            if (feedImage != null &&
                feedImage.texture == null)
            {
                feedImage.texture = CompositorWrapper.Instance.GetVideoCameraFeed();
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                if (networkingService != null &&
                    matchMakingService != null)
                {
                    var request = new HeadsetCalibrationDataRequest();
                    request.timestamp = Time.time;
                    var payload = request.Serialize();

                    if (networkingService.SendData(payload, NetworkPriority.Critical))
                    {
                        Debug.Log($"Sent headset calibration data request to HoloLens at {request.timestamp}");
                    }
                    else
                    {
                        Debug.LogWarning("Failed to send headset calibration data request to HoloLens");
                    }
                }

                if (headsetCalibration != null)
                {
                    Debug.Log("Requesting headset calibration data from VR Headset");
                    headsetCalibration.UpdateHeadsetCalibrationData();
                }
            }

            if (headsetData != null)
            {
                if (headsetData.markers.Count != expectedNumberOfMarkers)
                {
                    Debug.Log("Headset has not yet detected all of the markers on the calibration board, dropping payload from headset.");
                }
                else
                {
                    var dslrTexture = CompositorWrapper.Instance.GetVideoCameraTexture();
                    var fileName    = CalibrationDataHelper.GetUniqueFileName();
                    CalibrationDataHelper.SaveDSLRArUcoImage(dslrTexture, fileName);
                    CalibrationDataHelper.SaveHeadsetData(headsetData, fileName);

                    if (ProcessArUcoData(headsetData, dslrTexture))
                    {
                        CalibrationDataHelper.SaveDSLRArUcoDetectedImage(dslrTexture, fileName);
                        CreateVisual(headsetData, fileName);
                    }
                }

                headsetData = null;
            }

            if (Input.GetKeyDown(KeyCode.Return))
            {
                Debug.Log("Starting Individual Camera Extrinsics calculations.");
                cameraExtrinsics = CalibrationAPI.Instance.CalculateIndividualArUcoExtrinsics(dslrIntrinsics, parentVisuals.Count);
                if (cameraExtrinsics != null)
                {
                    foreach (var extrinsic in cameraExtrinsics)
                    {
                        Debug.Log($"Calculated extrinsics: {extrinsic}");
                    }
                    CreateExtrinsicsVisual(cameraExtrinsics);
                }

                Debug.Log("Starting the Global Camera Extrinsics calculation.");
                globalExtrinsics = CalibrationAPI.Instance.CalculateGlobalArUcoExtrinsics(dslrIntrinsics);
                if (globalExtrinsics != null)
                {
                    var fileName = CalibrationDataHelper.SaveCameraExtrinsics(globalExtrinsics);
                    Debug.Log($"Saved global extrinsics: {fileName}");
                    Debug.Log($"Found global extrinsics: {globalExtrinsics}");
                    var        position = globalExtrinsics.ViewFromWorld.GetColumn(3);
                    var        rotation = Quaternion.LookRotation(globalExtrinsics.ViewFromWorld.GetColumn(2), globalExtrinsics.ViewFromWorld.GetColumn(1));
                    GameObject camera   = null;
                    cameraVisualHelper.CreateOrUpdateVisual(ref camera, position, rotation);
                    camera.name = "Global Extrinsics";
                    GameObject hololens = null;
                    cameraVisualHelper.CreateOrUpdateVisual(ref hololens, Vector3.zero, Quaternion.identity);
                    hololens.name = "Global HoloLens";
                }
            }
        }