static void ExtendCRProjImages(string[] args) { string prjFile = args[1]; string imgFolder = args[2]; RCProjFile crPrj = new RCProjFile(); crPrj.LoadXML(prjFile); crPrj.AddImages(imgFolder); if (args.Length > 3) { for (int a = 3; a < args.Length; a++) { string folder = args[a]; crPrj.AddImages(folder); } } crPrj.SaveXML(prjFile); return; }
public void RunCRProjCreation(string[] args) { string[] imgFolder = new string[4]; if (!Directory.Exists(args[1])) { Program.AddLog("RCProjFile: No Image Path." + args[1]); return; } imgFolder[0] = args[1]; string scene_name = args[6]; string output_folder = Path.Combine(project_folder, scene_name); if (!Directory.Exists(output_folder)) { Directory.CreateDirectory(output_folder); } int nbSection = Convert.ToInt32(args[5]); int nbStep = section_info[nbSection * 7]; int nbStep2 = section_info[nbSection * 7 + 1]; int nbOverlap = section_info[nbSection * 7 + 2]; int nbFront = section_info[nbSection * 7 + 3]; int nbLeft = section_info[nbSection * 7 + 4]; int nbRight = section_info[nbSection * 7 + 5]; int nbBack = section_info[nbSection * 7 + 6]; ImagesManager imgMgr = new ImagesManager(); imgMgr.SelectFolder(0, imgFolder[0]); if (args[2] == "NULL") { imgFolder[1] = ""; } else { if (Directory.Exists(args[2])) { imgFolder[1] = args[2]; imgMgr.SelectFolder(1, imgFolder[1]); } } if (args[3] == "NULL") { imgFolder[2] = ""; } else { if (Directory.Exists(args[3])) { imgFolder[2] = args[3]; imgMgr.SelectFolder(2, imgFolder[2]); } } if (args[4] == "NULL") { imgFolder[3] = ""; } else { if (Directory.Exists(args[4])) { imgFolder[3] = args[4]; imgMgr.SelectFolder(3, imgFolder[3]); } } ImagesInfo imgInfo = imgMgr.folderList[0]; int nbImgTotal = imgInfo.m_images_list.Count; int nbTempImgTotal = nbImgTotal - nbFront * nbStep; int nbCRPrj = 1; int nbTempCRPrj = (nbTempImgTotal + (nbFront - nbOverlap) * nbStep - 1) / ((nbFront - nbOverlap) * nbStep); nbCRPrj += nbTempCRPrj; int[] nSec = new int[nbCRPrj]; CRProjInfo[] projInfo = new CRProjInfo[nbCRPrj]; for (int a = 0; a < nbCRPrj; a++) { projInfo[a] = new CRProjInfo(); } string first_img_filename = ""; //Front int maxImg = imgInfo.max_count; var result = imgInfo.m_images_list.OrderBy(i => i.Key); int count = 0; int countPrj = 0; foreach (var node in result) { if (count >= nbFront) { countPrj++; count = nbOverlap; } int idx = node.Key; int mod = idx % nbStep; if (mod != 0) { continue; } if (first_img_filename.Length < 3) { first_img_filename = node.Value; } projInfo[countPrj].imageList.Add(idx, node.Value); if (count >= nbFront - nbOverlap && countPrj < nbCRPrj - 1) { projInfo[countPrj + 1].imageList.Add(idx, node.Value); } count++; } //Left if (imgMgr.folderList.ContainsKey(1) && nbLeft > 1) { ImagesInfo imgInfo1 = imgMgr.folderList[1]; for (int a = 0; a < nbCRPrj; a++) { foreach (var node in projInfo[a].imageList) { int frontidx = node.Key; int mod = frontidx % nbStep2; if (mod != 0) { continue; } if (!imgInfo1.m_images_list.ContainsKey(frontidx)) { continue; } string filename = imgInfo1.m_images_list[frontidx]; projInfo[a].leftList.Add(frontidx, filename); } } } //Right if (imgMgr.folderList.ContainsKey(2) && nbRight > 1) { ImagesInfo imgInfo1 = imgMgr.folderList[2]; for (int a = 0; a < nbCRPrj; a++) { foreach (var node in projInfo[a].imageList) { int frontidx = node.Key; int mod = frontidx % nbStep2; if (mod != 0) { continue; } if (!imgInfo1.m_images_list.ContainsKey(frontidx)) { continue; } string filename = imgInfo1.m_images_list[frontidx]; projInfo[a].rightList.Add(frontidx, filename); } } } //Back if (imgMgr.folderList.ContainsKey(3) && nbBack > 1) { ImagesInfo imgInfo1 = imgMgr.folderList[3]; for (int a = 0; a < nbCRPrj; a++) { foreach (var node in projInfo[a].imageList) { int frontidx = node.Key; int mod = frontidx % nbStep2; if (mod != 0) { continue; } if (!imgInfo1.m_images_list.ContainsKey(frontidx)) { continue; } string filename = imgInfo1.m_images_list[frontidx]; projInfo[a].backList.Add(frontidx, filename); } } } // for (int a = 0; a < nbCRPrj; a++) { string prjName = string.Format("{0}_{1}.rcproj", scene_name, a); string output_project = Path.Combine(output_folder, prjName); projInfo[a].proj_name = output_project; } if (first_img_filename.Length < 3) { return; } //send command for (int a = 0; a < nbCRPrj; a++) { BuildNewProject(projInfo[a].proj_name, first_img_filename); } // for (int a = 0; a < nbCRPrj; a++) { RCProjFile projFile = new RCProjFile(); projFile.LoadXML(projInfo[a].proj_name); int nTotal = projInfo[a].imageList.Count; nTotal += projInfo[a].leftList.Count; nTotal += projInfo[a].rightList.Count; nTotal += projInfo[a].backList.Count; string[] tempList = new string[nTotal]; int temp_count = 0; foreach (var node in projInfo[a].imageList) { tempList[temp_count] = node.Value; temp_count++; } foreach (var node in projInfo[a].leftList) { tempList[temp_count] = node.Value; temp_count++; } foreach (var node in projInfo[a].rightList) { tempList[temp_count] = node.Value; temp_count++; } foreach (var node in projInfo[a].backList) { tempList[temp_count] = node.Value; temp_count++; } projFile.RemoveImages(); projFile.AddImages(tempList); projFile.SaveXML(projInfo[a].proj_name); } return; }