public async Task <IHttpActionResult> Post()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var provider = new MultipartMemoryStreamProvider();//For now I read the file in memory, but that is not needed, it could be saved directly to disk.
            await Request.Content.ReadAsMultipartAsync(provider);

            foreach (var file in provider.Contents)
            {
                var buffer = await file.ReadAsByteArrayAsync();

                string tempFileName = Path.GetTempFileName();
                File.WriteAllBytes(tempFileName, buffer);
                WindowsOcrExecutor ocrExecutor = new WindowsOcrExecutor(new NoOpOcrCache());//TODO: Should be SINGLETON, created using DI Container
                var ocrResult = await ocrExecutor.GetOcrResultAsync(tempFileName);

                File.Delete(tempFileName);
                return(Ok(ocrResult));
            }

            return(Ok());
        }
        public void works_with_bad_lang()
        {
            WindowsOcrExecutor windowsOcrExecutor = new WindowsOcrExecutor(new NoOpOcrCache());
            var res = windowsOcrExecutor.GetOcrResult(path, "_BAD_LANGUAGE_", true);

            Assert.IsNotNull(res);
            var isOutputEmpty = string.IsNullOrEmpty(windowsOcrExecutor.debugPsOutput.ToString());

            Assert.IsTrue(isOutputEmpty);
        }
        private static void RunOcrForAllClocksInParallel()
        {
            var dir = @"C:\Users\mihai.petrutiu\Downloads\clocks\clocks\";

            string[]           files       = Directory.GetFiles(dir).Where(f => f.EndsWith("png")).ToArray();
            WindowsOcrExecutor ocrExecutor = new WindowsOcrExecutor(new NoOpOcrCache());

            Parallel.For(0, files.Length, async(i) =>
            {
                var result = await ocrExecutor.GetOcrResultAsync(files[i]);
                Console.WriteLine(result.Text);
                Console.WriteLine(i);
            });
            Console.ReadKey();
        }