private bool LoadAndInitializeOcrTemplate(string filePath) { if (string.IsNullOrEmpty(filePath)) { UpdateOcrLabel(); return(false); } var loadedOcrConfig = OcrTemplate.LoadFile(filePath); if (loadedOcrConfig == null) { filePath = null; } ArkOcr.Ocr.ocrConfig = loadedOcrConfig; ArkOcr.Ocr.LoadReplacingsFile(); UpdateOcrLabel(filePath); if (loadedOcrConfig == null) { return(false); } InitLabelEntries(); nudResizing.Value = ArkOcr.Ocr.ocrConfig.resize == 0 ? 1 : (decimal)ArkOcr.Ocr.ocrConfig.resize; CbTrainRecognition.Checked = ArkOcr.Ocr.ocrConfig.RecognitionPatterns.TrainingSettings.IsTrainingEnabled; CbSkipNameRecognition.Checked = ArkOcr.Ocr.ocrConfig.RecognitionPatterns.TrainingSettings.SkipName; CbSkipTribeRecognition.Checked = ArkOcr.Ocr.ocrConfig.RecognitionPatterns.TrainingSettings.SkipTribe; CbSkipOwnerRecognition.Checked = ArkOcr.Ocr.ocrConfig.RecognitionPatterns.TrainingSettings.SkipOwner; return(true); }
public static OcrTemplate LoadFile(string filePath) { OcrTemplate ocrConfig = null; // check if file exists if (!File.Exists(filePath)) { MessageBoxes.ShowMessageBox($"OCR file '{filePath}' not found. OCR is not possible without the config-file."); return(null); } if (FileService.LoadJsonFile(filePath, out OcrTemplate data, out var errorMessage, new Newtonsoft.Json.Converters.VersionConverter())) { ocrConfig = data; ocrConfig.InitializeOcrTemplate(); }