Poszukiwacz/Serwer/Serwer.Infrastructure/Services/ImageService.cs

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 ImageService : IImageService
{
private readonly ISet<File> _files = new HashSet<File>();
private readonly string _env;
public ImageService(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);
}
}
}