Esempio n. 1
0
        public OCRTemplate loadFile(string filename)
        {
            OCRTemplate ocrConfig = null;

            // check if file exists
            if (!File.Exists(filename))
            {
                MessageBox.Show($"OCR-File '{filename}' not found. OCR is not possible without the config-file.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            using (FileStream file = File.OpenRead(filename))
            {
                try
                {
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(OCRTemplate));
                    ocrConfig = (OCRTemplate)ser.ReadObject(file);
                    ocrConfig.init();
                }
                catch (Exception e)
                {
                    MessageBox.Show("File Couldn't be opened or read.\nErrormessage:\n\n" + e.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(ocrConfig);
        }
Esempio n. 2
0
        public OCRTemplate loadFile(string filename)
        {
            OCRTemplate ocrConfig = null;

            // check if file exists
            if (!File.Exists(filename))
            {
                MessageBox.Show("OCR-File '" + filename + "' not found. OCR is not possible without the config-file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(OCRTemplate));

            System.IO.FileStream file = System.IO.File.OpenRead(filename);

            try
            {
                ocrConfig = (OCRTemplate)ser.ReadObject(file);
                ocrConfig.init();
                Properties.Settings.Default.ocrFile = filename;
            }
            catch (Exception e)
            {
                MessageBox.Show("File Couldn't be opened or read.\nErrormessage:\n\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            file.Close();

            return(ocrConfig);
        }
Esempio n. 3
0
        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;
            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);
        }
Esempio n. 4
0
        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);
            }

            using (FileStream file = File.OpenRead(filePath))
            {
                try
                {
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(OCRTemplate));
                    ocrConfig = (OCRTemplate)ser.ReadObject(file);
                    ocrConfig.init();
                }
                catch (Exception ex)
                {
                    MessageBoxes.ExceptionMessageBox(ex, "File Couldn't be opened or read.");
                }
            }
            return(ocrConfig);
        }
Esempio n. 5
0
        public void loadOCRTemplate(string fileName)
        {
            OCRTemplate t = ArkOCR.OCR.ocrConfig.loadFile(fileName);

            if (t != null)
            {
                ArkOCR.OCR.ocrConfig = t;
                updateOCRLabel();
                updateOCRFontSizes();
                initLabelEntries();
            }
        }
Esempio n. 6
0
        public void loadOCRTemplate(string fileName)
        {
            OCRTemplate t = ArkOCR.OCR.ocrConfig.loadFile(fileName);

            if (t != null)
            {
                ArkOCR.OCR.ocrConfig = t;
                labelOCRFile.Text    = fileName + "\n\nResolution: " + t.resolutionWidth + " × " + t.resolutionHeight + "\nUI-Scaling: " + t.guiZoom;
                updateOCRFontSizes();
                initLabelEntries();
            }
        }
Esempio n. 7
0
        public void loadOCRTemplate(string fileName)
        {
            OCRTemplate t = ArkOCR.OCR.ocrConfig.loadFile(fileName);

            if (t != null)
            {
                ArkOCR.OCR.ocrConfig = t;
                updateOCRLabel();
                updateOCRFontSizes();
                initLabelEntries();
                nudResizing.Value = ArkOCR.OCR.ocrConfig.resize == 0 ? 1 : (decimal)ArkOCR.OCR.ocrConfig.resize;
            }
        }
Esempio n. 8
0
        private bool LoadOCRTemplate(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return(false);
            }

            ArkOCR.OCR.ocrConfig = OCRTemplate.LoadFile(filePath) ?? new OCRTemplate();
            UpdateOCRLabel(filePath);
            UpdateOcrFontSizes();
            InitLabelEntries();
            nudResizing.Value = ArkOCR.OCR.ocrConfig.resize == 0 ? 1 : (decimal)ArkOCR.OCR.ocrConfig.resize;
            return(true);
        }
Esempio n. 9
0
        public bool loadOCRTemplate(string fileName)
        {
            OCRTemplate t = ArkOCR.OCR.ocrConfig.loadFile(fileName);

            if (t == null)
            {
                return(false);
            }
            ArkOCR.OCR.ocrConfig = t;
            updateOCRLabel(fileName);
            updateOCRFontSizes();
            initLabelEntries();
            nudResizing.Value = ArkOCR.OCR.ocrConfig.resize == 0 ? 1 : (decimal)ArkOCR.OCR.ocrConfig.resize;
            return(true);
        }
Esempio n. 10
0
        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();
            }
Esempio n. 11
0
        private void buttonLoadOCRTemplate_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "OCR configuration File (*.json)|*.json";
            dlg.InitialDirectory = Application.StartupPath;
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                OCRTemplate t = ArkOCR.OCR.ocrConfig.loadFile(dlg.FileName);
                if (t != null)
                {
                    ArkOCR.OCR.ocrConfig = t;
                    labelOCRFile.Text    = dlg.FileName;
                }
            }
            initLabelEntries();
        }
Esempio n. 12
0
        public bool LoadOCRTemplate(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return(false);
            }
            if (ArkOCR.OCR.ocrConfig == null)
            {
                ArkOCR.OCR.ocrConfig = new OCRTemplate();
            }
            OCRTemplate t = ArkOCR.OCR.ocrConfig.LoadFile(fileName);

            if (t == null)
            {
                return(false);
            }
            ArkOCR.OCR.ocrConfig = t;
            UpdateOCRLabel(fileName);
            UpdateOCRFontSizes();
            InitLabelEntries();
            nudResizing.Value = ArkOCR.OCR.ocrConfig.resize == 0 ? 1 : (decimal)ArkOCR.OCR.ocrConfig.resize;
            return(true);
        }