31 lines
936 B
C#
31 lines
936 B
C#
using Serwer.Core.Domain;
|
|
using Serwer.Infrastructure.Settings;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Tesseract;
|
|
|
|
namespace Serwer.Infrastructure.Services
|
|
{
|
|
public class ImageHandler : IImageHandler
|
|
{
|
|
private readonly ISet<File> _files = new HashSet<File>();
|
|
private readonly string _env;
|
|
public ImageHandler(IHostEnviroment hostEnviroment)
|
|
{
|
|
_env = hostEnviroment.RootPath;
|
|
}
|
|
public async Task<string> Process(string name, string contentType, byte[] bytes)
|
|
{
|
|
var engine = new TesseractEngine(System.IO.Path.Combine(_env, "tessdata"),"eng+equ", EngineMode.Default);
|
|
var img = Pix.LoadFromMemory(bytes);
|
|
var res = engine.Process(img);
|
|
var txt = res.GetText();
|
|
|
|
return await Task.FromResult(txt);
|
|
}
|
|
}
|
|
}
|