Exemple #1
0
        public static void ProcessFiles(TesseractArgs a)
        {
            var tesseractPath = GetTesseractPath();

            var maxDegreeOfParallelism = Environment.ProcessorCount;

            Parallel.ForEach(a.inputFiles, new ParallelOptions {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            },
                             (fileName) =>
            {
                var imageFile = File.ReadAllBytes(fileName);
                var text      = ParseText(tesseractPath, imageFile, a.lang.ToString());

                if (a.outputFiles != null)
                {
                    TF.SaveFile(text, a.outputFiles[fileName]);
                }

                if (a.writingOnConsole)
                {
                    Console.WriteLine("File:" + fileName + "\n" + text + "\n");
                }
            });
        }
Exemple #2
0
        public static void Test()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            var testFiles = FS.GetFiles(@"d:\Documents\BitBucket\How-to-use-tesseract-ocr-4.0-with-csharp\samples\a\");
            var a         = new TesseractArgs {
                lang = TessearactLang.ces, inputFiles = testFiles, writingOnConsole = true, outputFiles = null
            };

            ProcessFiles(a);

            stopwatch.Stop();
            Console.WriteLine("Duration: " + stopwatch.Elapsed);
            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();

            string output         = string.Empty;
            var    tempOutputFile = Path.GetTempPath() + Guid.NewGuid();
            var    tempImageFile  = Path.GetTempFileName();
        }