コード例 #1
0
        /// <summary>
        /// Coroutine that runs the stereo command.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="workspace"></param> The workspace from which to perform this step.
        /// <param name="displayProgressBar"></param> True if the progress bar should be displayed, false otherwise.
        /// <param name="stopOnError"></param> True if the process should stop on error, false otherwise.
        /// <param name="progressBarParams"></param> Parameters for the progress bar.
        /// <returns></returns>
        public static IEnumerator RunStereoCommand(MonoBehaviour caller, string workspace, bool displayProgressBar, bool stopOnError, string[] progressBarParams)
        {
            string command = "CALL " + COLMAPSettings.formattedCOLMAPExePath + " patch_match_stereo";

            command += " --workspace_path ./";
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(COLMAPConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));
        }
コード例 #2
0
        /// <summary>
        /// Coroutine that performs automatic retopology on a given mesh using the Instant Meshes implementation.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="workspace"></param> The workspace from which to launch the command.
        /// <param name="inputFilePath"></param> The full path to the input .PLY or .OBJ file.
        /// <param name="outputFilePath"></param> The full path to the output .PLY or .OBJ file.
        /// <param name="blenderHelper"></param> The helper component for Blender.
        /// <returns></returns>
        public static IEnumerator RunInstantMeshesCoroutine(MonoBehaviour caller, string workspace, string inputFilePath, string outputFilePath, BlenderHelper blenderHelper)
        {
            // Indicate to the user that the process has started.
            GeneralToolkit.ResetCancelableProgressBar(true, true);
            // Initialize the command parameters.
            bool displayProgressBar = true;
            bool stopOnError        = true;

            string[] progressBarParams = new string[3];
            progressBarParams[0] = "2";
            progressBarParams[1] = "Automatic retopology";
            progressBarParams[2] = "Processing canceled by user.";
            // Prepare the command.
            string formattedExePath = InstantMeshesSettings.formattedInstantMeshesExePath;
            string command          = "CALL " + formattedExePath;

            command += " --output " + GeneralToolkit.FormatPathForCommand(outputFilePath);
            command += " --deterministic --boundaries --rosy 6 --posy 6";
            // If there is a Blender helper, use the determined mesh face count to define the desired face count.
            if (blenderHelper != null && blenderHelper.meshFaceCount != -1)
            {
                command += " --faces " + GeneralToolkit.ToString(blenderHelper.meshFaceCount);
            }
            // Launch the command.
            command += " " + GeneralToolkit.FormatPathForCommand(inputFilePath);
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(InstantMeshesConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));

            // If there is a Blender helper, update the mesh's face count.
            if (blenderHelper != null)
            {
                blenderHelper.CheckOBJMeshInfo(workspace);
            }
            // Indicate to the user that the process has ended.
            GeneralToolkit.ResetCancelableProgressBar(false, false);
        }
コード例 #3
0
        /// <summary>
        /// Coroutine that runs the feature matching command.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="workspace"></param> The workspace from which to perform this step.
        /// <param name="displayProgressBar"></param> True if the progress bar should be displayed, false otherwise.
        /// <param name="stopOnError"></param> True if the process should stop on error, false otherwise.
        /// <param name="progressBarParams"></param> Parameters for the progress bar.
        /// <returns></returns>
        public static IEnumerator RunFeatureMatchingCommand(MonoBehaviour caller, string workspace, bool displayProgressBar, bool stopOnError, string[] progressBarParams)
        {
            string command = "CALL " + COLMAPSettings.formattedCOLMAPExePath + " exhaustive_matcher";

            command += " --database_path ./" + databaseFileName;
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(COLMAPConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));
        }
コード例 #4
0
        /// <summary>
        /// Coroutine that runs the Delaunay meshing command.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="workspace"></param> The workspace from which to perform this step.
        /// <param name="displayProgressBar"></param> True if the progress bar should be displayed, false otherwise.
        /// <param name="stopOnError"></param> True if the process should stop on error, false otherwise.
        /// <param name="progressBarParams"></param> Parameters for the progress bar.
        /// <returns></returns>
        public static IEnumerator RunDelaunayMeshingCommand(MonoBehaviour caller, string workspace, bool displayProgressBar, bool stopOnError, string[] progressBarParams)
        {
            string command = "CALL " + COLMAPSettings.formattedCOLMAPExePath + " delaunay_mesher";

            command += " --input_path ./";
            command += " --output_path ./" + delaunayFileName;
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(COLMAPConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));
        }
コード例 #5
0
        /// <summary>
        /// Coroutine that runs the undistortion command.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="workspace"></param> The workspace from which to perform this step.
        /// <param name="displayProgressBar"></param> True if the progress bar should be displayed, false otherwise.
        /// <param name="stopOnError"></param> True if the process should stop on error, false otherwise.
        /// <param name="progressBarParams"></param> Parameters for the progress bar.
        /// <param name="maxImageSize"></param> Parameter specifying the maximum image size for this step.
        /// <returns></returns>
        public static IEnumerator RunUndistortionCommand(MonoBehaviour caller, string workspace, bool displayProgressBar, bool stopOnError, string[] progressBarParams, int maxImageSize)
        {
            string command = "CALL " + COLMAPSettings.formattedCOLMAPExePath + " image_undistorter";

            command += " --image_path ./" + imagesDirName;
            command += " --input_path ./" + sparse0DirName;
            command += " --output_path ./" + dense0DirName;
            command += " --max_image_size " + GeneralToolkit.ToString(maxImageSize);
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(COLMAPConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));
        }
コード例 #6
0
        /// <summary>
        /// Coroutine that runs the exporting model as text command.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="workspace"></param> The workspace from which to perform this step.
        /// <param name="displayProgressBar"></param> True if the progress bar should be displayed, false otherwise.
        /// <param name="stopOnError"></param> True if the process should stop on error, false otherwise.
        /// <param name="progressBarParams"></param> Parameters for the progress bar.
        /// <returns></returns>
        public static IEnumerator RunExportModelAsTextCommand(MonoBehaviour caller, string workspace, bool displayProgressBar, bool stopOnError, string[] progressBarParams)
        {
            string inoutName = Directory.Exists(GetSparse0Dir(workspace)) ? sparse0DirName : sparseDirName;
            string command   = "CALL " + COLMAPSettings.formattedCOLMAPExePath + " model_converter";

            command += " --input_path ./" + inoutName;
            command += " --output_path ./" + inoutName;
            command += " --output_type TXT";
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(COLMAPConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));
        }
コード例 #7
0
        /// <summary>
        /// Coroutine that runs the mapping command.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="workspace"></param> The workspace from which to perform this step.
        /// <param name="displayProgressBar"></param> True if the progress bar should be displayed, false otherwise.
        /// <param name="stopOnError"></param> True if the process should stop on error, false otherwise.
        /// <param name="progressBarParams"></param> Parameters for the progress bar.
        /// <param name="isCameraModelKnown"></param> True if the camera model is already known, false otherwise.
        /// <returns></returns>
        public static IEnumerator RunMappingCommand(MonoBehaviour caller, string workspace, bool displayProgressBar, bool stopOnError, string[] progressBarParams, bool isCameraModelKnown)
        {
            string command = "CALL " + COLMAPSettings.formattedCOLMAPExePath + " mapper";

            command += " --database_path ./" + databaseFileName;
            command += " --image_path ./" + imagesDirName;
            command += " --output_path ./" + sparseDirName;
            if (isCameraModelKnown)
            {
                command += " --Mapper.ba_refine_focal_length 0 --Mapper.ba_refine_extra_params 0";
            }
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(COLMAPConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));
        }
コード例 #8
0
        /// <summary>
        /// Coroutine that applies the Smart UV Project algorithm to the given .OBJ file.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="inputFilePath"></param> The full path to the input .OBJ file.
        /// <param name="outputFilePath"></param> The full path to the output .OBJ file.
        /// <returns></returns>
        public static IEnumerator RunSmartUVProjectOBJCoroutine(MonoBehaviour caller, string inputFilePath, string outputFilePath)
        {
            // Initialize the coroutine.
            bool displayProgressBar; bool stopOnError; string[] progressBarParams;

            InitBlenderCoroutine(true, out displayProgressBar, out stopOnError, out progressBarParams);
            progressBarParams[1] = "Smart UV Project on .OBJ";
            // Launch the command.
            string command = FormatBlenderCommand(_smartUVProjectOBJFileName, inputFilePath, outputFilePath);

            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(BlenderConnector), command, _externalPythonScriptsDir, displayProgressBar, null, _harmlessWarnings, stopOnError, progressBarParams)));

            // Clear the coroutine.
            ClearBlenderCoroutine();
        }
コード例 #9
0
        /// <summary>
        /// Coroutine that simplifies the mesh in a .OBJ file using the decimation modifier.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="inputFilePath"></param> The full path to the input .OBJ file.
        /// <param name="outputFilePath"></param> The full path to the output .OBJ file.
        /// <param name="storeFaceCount"></param> Action that stores the mesh's face count.
        /// <returns></returns>
        public static IEnumerator RunSimplifyOBJCoroutine(MonoBehaviour caller, string inputFilePath, string outputFilePath, System.Diagnostics.DataReceivedEventHandler storeFaceCount)
        {
            // Initialize the coroutine.
            bool displayProgressBar; bool stopOnError; string[] progressBarParams;

            InitBlenderCoroutine(true, out displayProgressBar, out stopOnError, out progressBarParams);
            progressBarParams[1] = "Convert .PLY to .OBJ";
            // Launch the command.
            string command = FormatBlenderCommand(_simplifyOBJFileName, inputFilePath, outputFilePath);

            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(BlenderConnector), command, _externalPythonScriptsDir, displayProgressBar, storeFaceCount, _harmlessWarnings, stopOnError, progressBarParams)));

            // Clear the coroutine.
            ClearBlenderCoroutine();
        }
コード例 #10
0
        /// <summary>
        /// Coroutine that runs the feature extraction command.
        /// </summary>
        /// <param name="caller"></param> The object calling this method.
        /// <param name="workspace"></param> The workspace from which to perform this step.
        /// <param name="displayProgressBar"></param> True if the progress bar should be displayed, false otherwise.
        /// <param name="stopOnError"></param> True if the process should stop on error, false otherwise.
        /// <param name="progressBarParams"></param> Parameters for the progress bar.
        /// <param name="COLMAPCameraIndex"></param> The index of the type of source camera (in the list of COLMAP cameras).
        /// <param name="isSingleCamera"></param> True if the source images were acquired by the same camera, false otherwise.
        /// <param name="focalLengthFactor"></param> Parameter for feature extraction.
        /// <returns></returns>
        public static IEnumerator RunFeatureExtractionCommand(MonoBehaviour caller, string workspace, bool displayProgressBar, bool stopOnError, string[] progressBarParams, int COLMAPCameraIndex, bool isSingleCamera, float focalLengthFactor)
        {
            string command = "CALL " + COLMAPSettings.formattedCOLMAPExePath + " feature_extractor";

            command += " --database_path ./" + databaseFileName;
            command += " --image_path ./" + imagesDirName;
            command += " --ImageReader.camera_model " + COLMAPCameraTypes[COLMAPCameraIndex];
            if (isSingleCamera)
            {
                command += " --ImageReader.single_camera 1";
            }
            if (focalLengthFactor > 0)
            {
                command += " --ImageReader.default_focal_length_factor " + GeneralToolkit.ToString(focalLengthFactor);
            }
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(COLMAPConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));
        }
コード例 #11
0
        /// <summary>
        /// Coroutine that applies the Smart UV Project algorithm to the given .OBJ file.
        /// </summary>
        /// <param name="caller"></param> The Blender helper calling this method.
        /// <param name="inputFilePath"></param> The full path to the input .OBJ file.
        /// <param name="outputFilePath"></param> The full path to the output .OBJ file.
        /// <returns></returns>
        public static IEnumerator RunSmartUVProjectOBJCoroutine(BlenderHelper caller, string inputFilePath, string outputFilePath)
        {
            // Indicate to the user that the process has started.
            GeneralToolkit.ResetCancelableProgressBar(true, true);
            // Initialize the coroutine parameters.
            bool displayProgressBar; bool stopOnError; string[] progressBarParams;

            InitBlenderCoroutineParams(true, out displayProgressBar, out stopOnError, out progressBarParams);
            progressBarParams[1] = "Smart UV Project on .OBJ";
            // Launch the command.
            string command = FormatBlenderCommand(_smartUVProjectOBJFileName, inputFilePath, outputFilePath);

            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(BlenderConnector), command, _externalPythonScriptsDir, displayProgressBar, null, _harmlessWarnings, stopOnError, progressBarParams)));

            // Display the uv-mapped mesh in the Scene view.
            caller.DisplayMeshInSceneView(outputFilePath);
            // Indicate to the user that the process has ended.
            GeneralToolkit.ResetCancelableProgressBar(false, false);
        }
コード例 #12
0
        // /// <summary>
        // /// Coroutine that checks an .OBJ's mesh information.
        // /// </summary>
        // /// <param name="caller"></param> The object calling this method.
        // /// <param name="inputFilePath"></param> The full path to the input .OBJ file.
        // /// <param name="storeFaceCount"></param> Action that stores the mesh's face count.
        // /// <returns></returns>
        // public static IEnumerator RunCheckOBJMeshInfoCoroutine(MonoBehaviour caller, string inputFilePath, System.Diagnostics.DataReceivedEventHandler storeFaceCount)
        // {
        //     // Indicate to the user that the process has started.
        //     GeneralToolkit.ResetCancelableProgressBar(true, false);
        //     // Initialize the coroutine parameters.
        //     bool displayProgressBar; bool stopOnError; string[] progressBarParams;
        //     InitBlenderCoroutineParams(false, out displayProgressBar, out stopOnError, out progressBarParams);
        //     progressBarParams[1] = "Check .OBJ mesh information";
        //     // Launch the command.
        //     string command = FormatBlenderCommand(_checkOBJMeshInfoFileName, inputFilePath);
        //     yield return caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(BlenderConnector), command, _externalPythonScriptsDir, displayProgressBar, storeFaceCount, _harmlessWarnings, stopOnError, progressBarParams));
        //     // Indicate to the user that the process has ended.
        //     GeneralToolkit.ResetCancelableProgressBar(false, false);
        // }

        /// <summary>
        /// Coroutine that simplifies the mesh in a .OBJ file using the decimation modifier.
        /// </summary>
        /// <param name="caller"></param> The Blender helper calling this method.
        /// <param name="inputFilePath"></param> The full path to the input .OBJ file.
        /// <param name="outputFilePath"></param> The full path to the output .OBJ file.
        /// <param name="storeFaceCount"></param> Action that stores the mesh's face count.
        /// <returns></returns>
        public static IEnumerator RunSimplifyOBJCoroutine(BlenderHelper caller, string inputFilePath, string outputFilePath, System.Diagnostics.DataReceivedEventHandler storeFaceCount)
        {
            // Indicate to the user that the process has started.
            GeneralToolkit.ResetCancelableProgressBar(true, true);
            // Initialize the coroutine parameters.
            bool displayProgressBar; bool stopOnError; string[] progressBarParams;

            InitBlenderCoroutineParams(true, out displayProgressBar, out stopOnError, out progressBarParams);
            progressBarParams[1] = "Convert .PLY to .OBJ";
            // Launch the command.
            string command = FormatBlenderCommand(_simplifyOBJFileName, inputFilePath, outputFilePath);

            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(BlenderConnector), command, _externalPythonScriptsDir, displayProgressBar, storeFaceCount, _harmlessWarnings, stopOnError, progressBarParams)));

            // Display the simplified mesh in the Scene view.
            caller.DisplayMeshInSceneView(outputFilePath);
            // Indicate to the user that the process has ended.
            GeneralToolkit.ResetCancelableProgressBar(false, false);
        }
コード例 #13
0
        /// <summary>
        /// Coroutine that performs automatic retopology on a given mesh using the Instant Meshes implementation.
        /// </summary>
        /// <param name="caller"></param> The Instant Meshes helper calling this method.
        /// <param name="workspace"></param> The workspace from which to launch the command.
        /// <param name="inputFilePath"></param> The full path to the input .PLY or .OBJ file.
        /// <param name="outputFilePath"></param> The full path to the output .PLY or .OBJ file.
        /// <param name="reduceVertexCount"></param> Whether to reduce the vertex count to the recommended value.
        /// <returns></returns>
        public static IEnumerator RunInstantMeshesCoroutine(InstantMeshesHelper caller, string workspace, string inputFilePath, string outputFilePath, bool reduceVertexCount)
        {
            // Indicate to the user that the process has started.
            GeneralToolkit.ResetCancelableProgressBar(true, true);
            // If the initial face count is needed, display the input mesh to get it.
            if (!reduceVertexCount)
            {
                caller.DisplayMeshInSceneView(inputFilePath);
            }
            // Initialize the command parameters.
            bool displayProgressBar = true;
            bool stopOnError        = true;

            string[] progressBarParams = new string[3];
            progressBarParams[0] = "2";
            progressBarParams[1] = "Automatic retopology";
            progressBarParams[2] = "Processing canceled by user.";
            // Prepare the command.
            string formattedExePath = InstantMeshesSettings.formattedInstantMeshesExePath;
            string command          = "CALL " + formattedExePath;

            command += " --output " + GeneralToolkit.FormatPathForCommand(outputFilePath);
            command += " --deterministic --boundaries --rosy 6 --posy 6";
            // If desired, use the determined mesh face count to define the desired face count.
            if (!reduceVertexCount)
            {
                command += " --faces " + GeneralToolkit.ToString(caller.loadedMeshFaceCount);
            }
            // Launch the command.
            command += " " + GeneralToolkit.FormatPathForCommand(inputFilePath);
            yield return(caller.StartCoroutine(GeneralToolkit.RunCommandCoroutine(typeof(InstantMeshesConnector), command, workspace, displayProgressBar, null, null, stopOnError, progressBarParams)));

            // Display the transformed mesh in the Scene view.
            caller.DisplayMeshInSceneView(outputFilePath);
            // Indicate to the user that the process has ended.
            GeneralToolkit.ResetCancelableProgressBar(false, false);
        }