Пример #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
        internal static void StartProgramTask(string fileNameWithArguments, object starter)
        {
            string fileName = "";
               string arguments = "";

               try
               {
               // Search for the extension. Take everything before as file name, and everything after as arguments.
               int iExt = -1;
               foreach (string ext in SupportedExtensions)
               {
                   iExt = fileNameWithArguments.IndexOf(ext);
                   if (iExt > -1)
                   {
                       fileName = fileNameWithArguments.Substring(0, iExt + ext.Length);
                       arguments = fileNameWithArguments.Remove(0, fileName.Length).Trim();

                       break;
                   }
               }

               // If program file is unsupported, skip execution and warn user.
               if (iExt == -1)
               {
                   Logger.Instance.LogFormat(LogType.Warning, starter, Resources.ProgramNotSupported, fileNameWithArguments, string.Join(", ", SupportedExtensions));
                   return;
               }

               ProcessWrapper proc = new ProcessWrapper();
               proc.FileName = fileName;
               proc.WorkingDirectory = Path.GetDirectoryName(fileName);
               proc.Arguments = arguments;

               proc.Start();
               }
               catch (Exception ex)
               {
               Logger.Instance.LogFormat(LogType.Error, starter, Resources.ProgramStartFailed, fileNameWithArguments);
               Logger.Instance.LogException(starter, ex);
               }
        }