static void RunMeshroomCompute( string MeshroomComputeBin, string ImagesDir, string graph, ComputeProgress ComputeProgressCB) { /* remove previous cache dir, if it exists */ Utils.RemoveDir(Meshroom.GetCacheDir(ImagesDir)); /* start meshroom compute process */ var proc = Utils.Run(MeshroomComputeBin, graph); var graphName = Path.GetFileNameWithoutExtension(graph); var stepsPoller = MeshroomProgress.GetPoller(ImagesDir); while (!proc.HasExited) { var done = stepsPoller.PollStepsDone(); var total = stepsPoller.TotalSteps; ComputeProgressCB(graphName, (float)done / (float)total); Thread.Sleep(1300); } var exitCode = proc.ExitCode; if (exitCode != 0) { var err = string.Format("{0} failed, exit code {1}", MeshroomComputeBin, exitCode); throw new Exception(err); } CopyCamerasSFMFile(ImagesDir, graphName); }
static IEnumerable <string> NodeCacheDirs(string CacheDir) { foreach (var nodeRoot in Directory.GetDirectories(CacheDir)) { yield return(Meshroom.GetNodeCacheDir(nodeRoot)); } }
static void WaitForCamInitDir(string path) { var camInitRoot = Path.Combine(path, "CameraInit"); while (!Directory.Exists(camInitRoot)) { Thread.Sleep(500); } string nodeDir; while ((nodeDir = Meshroom.GetNodeCacheDir(camInitRoot)) == null) { Thread.Sleep(1500); } string statusFile = Path.Combine(nodeDir, "status"); while (!File.Exists(statusFile)) { Thread.Sleep(500); } while (!Status.isDone(statusFile)) { Thread.Sleep(500); } }
public static ComputeProgress GetPoller(string path) { var CacheDir = Meshroom.GetCacheDir(path); WaitForCamInitDir(CacheDir); return(new ComputeProgress(StatusFiles(CacheDir))); }
static void CopyCamerasSFMFile(string ImagesDir, string graphName) { var MeshroomCacheDir = Meshroom.GetCacheDir(ImagesDir); var SfmCacheDir = Meshroom.GetNodeCacheDir( Path.Combine(MeshroomCacheDir, "StructureFromMotion")); var camsSfmFile = Path.Combine(SfmCacheDir, "cameras.sfm"); var destFile = Path.Combine(ImagesDir, $"{graphName}.sfm"); File.Copy(camsSfmFile, destFile, true); }
static void RemoveCacheDir(string ImagesDir, int chunkNum) { var cacheDir = Meshroom.GetCacheDir(ImagesDir); if (SAVE_MESHROOM_CACHE && Directory.Exists(cacheDir)) { var destDir = Path.Combine(ImagesDir, $"MeshroomCache{chunkNum}"); Log.Msg($"saving '{cacheDir}' to '{destDir}'"); Directory.Move(cacheDir, destDir); } Utils.RemoveDir(cacheDir); }
public static void PhotogrammImages( string MeshroomComputeBin, string SensorDatabase, string VocTree, string ImagesDir, TimeBase TimeBase, uint LastFrame, ComputeProgress ComputeProgressCB) { var chunks = Chunks.GetChunks(TimeBase, LastFrame); var graphs = MeshroomGraphs(SensorDatabase, VocTree, ImagesDir, chunks); foreach (var graph in graphs) { RunMeshroomCompute(MeshroomComputeBin, ImagesDir, graph, ComputeProgressCB); } /* clean-up last meshroom cache directory */ Utils.RemoveDir(Meshroom.GetCacheDir(ImagesDir)); }