/// <summary> /// Enables the user to launch dense 3D reconstruction and meshing via COLMAP. /// </summary> /// <param name="workspace"></param> The workspace from which to perform this method. private void SubsectionDenseReconstruction() { EditorGUILayout.Space(); string workspace = dataHandler.dataDirectory; string label = "Reconstruct 3D mesh (.PLY) from sparse camera setup."; string tooltip = "Processed geometry will be stored at: \"" + COLMAPConnector.GetDelaunayFile(workspace) + "\"."; // Check if this option is available. bool isGUIEnabled = GUI.enabled; GUI.enabled = isGUIEnabled && (cameraSetup != null && cameraSetup.cameraModels != null) && workspace.Contains(COLMAPConnector.dense0DirName) && Application.isPlaying; GeneralToolkit.EditorRequirePlayMode(ref tooltip); // Display a button to launch the helper method. bool hasPressed = GeneralToolkit.EditorWordWrapLeftButton(new GUIContent("Run", tooltip), new GUIContent(label, tooltip)); // If the button is pressed, display a dialog to confirm. if (hasPressed) { label = "Existing data will be erased. Are you ready to proceed?"; tooltip = "Launching this process will erase data in the folder: \"" + workspace + "\". Are you ready to proceed?"; // If the user confirms, update the workspace directory and launch the method. if (EditorUtility.DisplayDialog(label, tooltip, "Yes", "No")) { StartCoroutine(COLMAPConnector.RunDenseReconstructionCoroutine(this, workspace)); } } // Reset the GUI. GUI.enabled = isGUIEnabled; EditorGUILayout.Space(); }
/// <summary> /// Enables the user to launch dense 3D reconstruction and meshing via COLMAP. /// </summary> /// <param name="workspace"></param> The workspace from which to perform this method. private void SubsectionDenseReconstruction() { EditorGUILayout.Space(); string workspace = dataHandler.dataDirectory; string label = "Reconstruct 3D mesh (.PLY) from sparse camera setup."; string tooltip = "Processed geometry will be stored at: \"" + COLMAPConnector.GetDelaunayFile(workspace) + "\"."; // Check if this option is available. bool isGUIEnabled = GUI.enabled; GUI.enabled = isGUIEnabled && (cameraSetup != null && cameraSetup.cameraModels != null && cameraSetup.cameraModels.Length > 0) && (dataHandler != null && dataHandler.imagePointCorrespondencesExist) && Application.isPlaying; GeneralToolkit.EditorRequirePlayMode(ref tooltip); // Display a button to launch the helper method. bool hasPressed = GeneralToolkit.EditorWordWrapLeftButton(new GUIContent("Run", tooltip), new GUIContent(label, tooltip)); // If the button is pressed, display a dialog to confirm. if (hasPressed) { label = "Existing data will be erased. Are you ready to proceed?"; tooltip = "WARNING: Before launching this step, please check that you are using a CUDA-capable GPU. Your current GPU is a " + SystemInfo.graphicsDeviceName + "."; tooltip += "\n\nLaunching this process will erase data in the folder: \"" + workspace + "\". Are you ready to proceed?"; // If the user confirms, update the workspace directory and launch the method. int chosenButton = EditorUtility.DisplayDialogComplex(label, tooltip, "Yes", "No", "Check whether my GPU is CUDA-capable"); if (chosenButton == 0) { StartCoroutine(COLMAPConnector.RunDenseReconstructionCoroutine(this, workspace, cameraSetup.cameraModels.Length)); } else if (chosenButton == 2) { Application.OpenURL("https://developer.nvidia.com/cuda-gpus"); } } // Reset the GUI. GUI.enabled = isGUIEnabled; EditorGUILayout.Space(); }
/// <summary> /// On enable, changes the workspace if entering edit mode after having performed reconstruction in play mode. /// </summary> void OnEnable() { if (!EditorApplication.isPlaying && GeneralToolkit.IsStartingNewScene()) { string indicatorPathAbsolute = Path.Combine(Application.dataPath, _updateDirectoryIndicatorPathEnd); if (File.Exists(indicatorPathAbsolute)) { COLMAPConnector.ChangeWorkspaceAfterSparseReconstruction(dataHandler); GeneralToolkit.Delete(indicatorPathAbsolute); AssetDatabase.Refresh(); } } }
/// <summary> /// Enables the user to launch sparse 3D reconstruction via COLMAP. /// </summary> /// <param name="serializedObject"></param> The serialized object to modify. private void SubsectionSparseReconstruction(SerializedObject serializedObject) { EditorGUILayout.Space(); string workspace = dataHandler.dataDirectory; string label = "Recover sparse camera setup from images."; string tooltip = "Images should be stored in the \"" + COLMAPConnector.GetImagesDir(workspace) + "\" folder.\n"; tooltip += "Camera setup information will be stored at: \"" + COLMAPConnector.GetCamerasFile(workspace) + "\"."; // Check if this option is available. bool isGUIEnabled = GUI.enabled; GUI.enabled = isGUIEnabled && (processingCaller.sourceColorCount > 1) && !(workspace.Contains(COLMAPConnector.dense0DirName)) && Application.isPlaying; GeneralToolkit.EditorRequirePlayMode(ref tooltip); // Display a button to launch the helper method. bool hasPressed = GeneralToolkit.EditorWordWrapLeftButton(new GUIContent("Run", tooltip), new GUIContent(label, tooltip)); // Display additional parameters. EditorGUILayout.Space(); if (GUI.enabled) { label = "Camera type"; tooltip = "COLMAP camera type of the camera(s) that acquired the source images."; SerializedProperty propertyCOLMAPCameraIndex = serializedObject.FindProperty(_propertyNameCOLMAPCameraIndex); propertyCOLMAPCameraIndex.intValue = EditorGUILayout.Popup(new GUIContent(label, tooltip), propertyCOLMAPCameraIndex.intValue, COLMAPConnector.COLMAPCameraTypes.ToArray()); label = "Is single camera"; tooltip = "This value should be set to true if the source images were acquired by the same camera, false otherwise."; SerializedProperty propertyIsSingleCamera = serializedObject.FindProperty(_propertyNameIsSingleCamera); propertyIsSingleCamera.boolValue = EditorGUILayout.Toggle(new GUIContent(label, tooltip), propertyIsSingleCamera.boolValue); label = "Max. image size: "; tooltip = "Maximum image size for the undistortion step. The resized images will be the ones used for rendering."; SerializedProperty propertyMaxImageSize = serializedObject.FindProperty(_propertyNameMaxImageSize); propertyMaxImageSize.intValue = EditorGUILayout.IntSlider(new GUIContent(label, tooltip), propertyMaxImageSize.intValue, 1, 8192); } // If the button is pressed, display a dialog to confirm. if (hasPressed) { label = "Existing data will be erased. Are you ready to proceed?"; tooltip = "Launching this process will erase data in the folder: \"" + workspace + "\". Are you ready to proceed?"; // If the user confirms, launch the method. if (EditorUtility.DisplayDialog(label, tooltip, "Yes", "No")) { StartCoroutine(COLMAPConnector.RunSparseReconstructionCoroutine(processingCaller, workspace, _COLMAPCameraIndex, _isSingleCamera, _maxImageSize)); } hasPerformedSparseReconstruction = true; ChangeWorkspaceAfterSparseReconstruction(); } // Reset the GUI. GUI.enabled = isGUIEnabled; EditorGUILayout.Space(); }
/// <summary> /// Changes the workspace after having performed sparse reconstruction. /// </summary> private void ChangeWorkspaceAfterSparseReconstruction() { string newDirectory = COLMAPConnector.GetDense0Dir(dataHandler.dataDirectory); dataHandler.ChangeDataDirectory(newDirectory); }