/// <summary> /// Moves the acquisition camera into the desired poses, and acquires the corresponding color and depth data. /// </summary> /// <returns></returns> private IEnumerator CaptureSceneCoroutine() { // Inform the user that the process has started. GeneralToolkit.ResetCancelableProgressBar(true, true); Debug.Log(GeneralToolkit.FormatScriptMessage(typeof(Acquisition), "Started acquiring scene data.")); // Find the camera models if needed. if (cameraSetup.cameraModels == null) { cameraSetup.FindCameraModels(); } if (cameraSetup.cameraModels == null) { yield break; } // Store the initial preview index. int initialPreviewIndex = cameraSetup.previewIndex; // Store the pose data and camera parameters into a file. SaveAcquisitionInformation(dataHandler, cameraSetup); // If desired, save the scene's meshes as a global asset. if (_copyGlobalMesh) { SaveGlobalMesh(); } // Acquire data for each source pose. for (int i = 0; i < cameraSetup.cameraModels.Length; i++) { // Display and update the progress bar. DisplayAndUpdateCancelableProgressBar(); if (GeneralToolkit.progressBarCanceled) { break; } // Change the preview index to the current camera. cameraSetup.previewIndex = i; string imageName = cameraSetup.cameraModels[i].imageName; // Update the camera model for the preview camera, thereby rendering to the target color and depth textures. UpdatePreviewCameraModel(true); // Save the color texture as a file. GeneralToolkit.SaveRenderTextureToPNG(_previewCameraManager.targetTexture, Path.Combine(dataHandler.colorDirectory, imageName)); // If depth data is to be acquired, save the scene's depth (encoded as a 3-channel RGB texture) as a file. if (_acquireDepthData) { _distanceToColorMat.SetInt(shaderNameIsPrecise, 1); Graphics.Blit(_targetDepthTexture, _distanceAsColorTexture, _distanceToColorMat); GeneralToolkit.SaveRenderTextureToPNG(_distanceAsColorTexture, Path.Combine(dataHandler.depthDirectory, imageName)); } yield return(null); } // If the process completes without being canceled, inform the user. if (!GeneralToolkit.progressBarCanceled) { Debug.Log(GeneralToolkit.FormatScriptMessage(typeof(Acquisition), "Successfully acquired scene data.")); Debug.Log(GeneralToolkit.FormatScriptMessage(typeof(Acquisition), "Data can be found in directory: " + dataHandler.dataDirectory + ".")); } // Reset displayed information. GeneralToolkit.ResetCancelableProgressBar(false, false); // Reset the preview camera's pose. cameraSetup.previewIndex = initialPreviewIndex; UpdatePreviewCameraModel(false); UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); }