Ejemplo n.º 1
0
        /// <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();
        }