コード例 #1
0
        string[] IOcrSoftware.ProcessImage(OcrProcessOptions options)
        {
            using (ProcessWrapper proc = new ProcessWrapper())
            {
                // If there is no custom directory
                if (string.IsNullOrEmpty(options.SoftwarePath))
                {
                    proc.WorkingDirectory = Path.Combine(Utilities.GetWorkingDirectory(), "tesseract");
                }
                else
                {
                    proc.WorkingDirectory = options.SoftwarePath;
                }

                proc.FileName  = Path.Combine(proc.WorkingDirectory, "tesseract.exe");
                proc.Arguments = string.Format("\"{0}\" \"{1}\"  -psm 6 quiet", options.ImagePath, options.AnalyzedFileDestinationPath);

                proc.StartAndWait();
            }

            // Correct txt path for tesseract (it will append .txt under windows always)
            string analyzedFile = options.AnalyzedFileDestinationPath + ".txt";

            return(File.ReadAllLines(analyzedFile));
        }
コード例 #2
0
        public string DoImport()
        {
            var processParameter = ProcessParameters.MongoDump;
            var wrapper          = new ProcessWrapper(processParameter);

            wrapper.StartAndWait();
            return(wrapper.GetText());
        }
コード例 #3
0
        string[] IOcrSoftware.ProcessImage(OcrProcessOptions options)
        {
            using (ProcessWrapper proc = new ProcessWrapper())
            {
                string tesseractPath = Path.Combine(Utilities.GetWorkingDirectory(), "tesseract");

                try
                {
                    Environment.SetEnvironmentVariable(EnvTessdata, tesseractPath);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.OcrSoftwareTesseractError);
                    Logger.Instance.LogException(this, ex);
                }


                // If there is no custom directory
                if (string.IsNullOrEmpty(options.SoftwarePath))
                {
                    proc.WorkingDirectory = tesseractPath;
                }
                else
                {
                    proc.WorkingDirectory = options.SoftwarePath;
                }

                proc.FileName  = Path.Combine(proc.WorkingDirectory, "tesseract.exe");
                proc.Arguments = string.Format("\"{0}\" \"{1}\"  -psm 6 quiet", options.ImagePath, options.AnalyzedFileDestinationPath);

                proc.StartAndWait();
            }

            // Correct txt path for tesseract (it will append .txt under windows always)
            string analyzedFile = options.AnalyzedFileDestinationPath + ".txt";

            return(File.ReadAllLines(analyzedFile));
        }