public void SaveToCustomData() { MyIniParseResult result; if (!customData.TryParse(Me.CustomData, out result)) { throw new Exception(result.ToString()); } customData.Set("3DPrinter", "maxX", maxX); customData.SetComment("3DPrinter", "maxX", " Work area dimentions:"); customData.Set("3DPrinter", "maxY", maxY); customData.Set("3DPrinter", "maxZ", maxZ); customData.Set("3DPrinter", "minX", minX); customData.Set("3DPrinter", "minY", minY); customData.Set("3DPrinter", "minZ", minZ); customData.Set("3DPrinter", "mode", mode.ToString()); customData.SetComment("3DPrinter", "mode", " Mode: grinding or welding"); customData.Set("3DPrinter", "toolLength", toolLength); customData.SetComment("3DPrinter", "toolLength", " Tool Length in number of blocks(default:10)"); customData.Set("3DPrinter", "returnAfterDone", returnAfterDone); customData.SetComment("3DPrinter", "returnAfterDone", " Return to home position after completion?"); customData.Set("3DPrinter", "maxMovementSpeed", maxMovementSpeed); customData.SetComment("3DPrinter", "maxMovementSpeed", " Fastest pistons can move (0.0-5.0)"); customData.Set("3DPrinter", "grindingSpeed", grindingSpeed); customData.SetComment("3DPrinter", "grindingSpeed", " Max piston speed while grinding (default:0.5)"); customData.Set("3DPrinter", "weldingSpeed", weldingSpeed); customData.SetComment("3DPrinter", "weldingSpeed", " Max piston speed while welding (default:0.2)"); Me.CustomData = customData.ToString(); }
public override string ToString() { return(Mode.ToString()); }
internal void Train() { //Generate local folder if not exists if (!Directory.Exists(LOCAL_FOLDER_TEMP)) { Directory.CreateDirectory(LOCAL_FOLDER_TEMP); } if (!noCopy) { Directory.SetCurrentDirectory(LOCAL_FOLDER_TEMP); } else { Directory.SetCurrentDirectory(imagesDirectory.FullName); } // Check the presence of Tesseract exe inside folder FileInfo tesseractExe = new FileInfo(Path.Combine(tesseractDirectory.FullName, "tesseract.exe")); if (!tesseractExe.Exists) { throw new Exception("Tesseract.exe has not been found inside the provided path. Please provide a valid Tesseract data folder"); } if (emode == EMode.BOX_CREATE) { logger?.Log("Starting process of box creation...", true); // Retrieve TIF images for training var images = retrieveTifImages(imagesDirectory); // Copy TIF images locally List <FileInfo> localImages = new List <FileInfo>(); if (!noCopy) { localImages = copyImagesLocally(images); } else { localImages = images; } // Create boxes createBoxes(localImages, tesseractExe); logger?.Log("Box creation completed. Please check they are correct and start training with mode 'train'", true); } else if (emode == EMode.TRAIN) { logger?.Log("Starting process of training...", true); var trainModel = new TrainModel(); var localDirectoryInfo = new DirectoryInfo("."); trainModel.Images = retrieveTifImages(localDirectoryInfo); trainModel.Boxes = retrieveBoxesFile(localDirectoryInfo); // Creation of train file createTrainFile(trainModel, tesseractExe); trainModel.Train = retrieveTrainFiles(localDirectoryInfo); // Creation of unicharset file createUnicharset(trainModel, localDirectoryInfo); // Creation of font properties file createFontPropertiesFile(trainModel); // Creation of clustering file createClusteringFile(trainModel); // Creation of mftraining file createMfTrainingFile(trainModel); // Creation of cntraining file createCnTrainingFile(trainModel); // Creation of unicharambigs file createUnicharambigs(tesseractExe); // Rename all file renameFile(localDirectoryInfo); // Combine all data in order to generate final training file combineData(); } else { throw new Exception(string.Format("Invalid mode: {0}", emode.ToString())); } }