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

31 lines
936 B
C#
Raw Permalink Normal View History

2020-12-12 14:18:31 +01:00
using Serwer.Core.Domain;
using Serwer.Infrastructure.Settings;
2020-12-12 14:18:31 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tesseract;
2020-12-12 14:18:31 +01:00
namespace Serwer.Infrastructure.Services
{
public class ImageService : IImageService
{
private readonly ISet<File> _files = new HashSet<File>();
private readonly string _env;
public ImageService(IHostEnviroment hostEnviroment)
2020-12-12 14:18:31 +01:00
{
_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);
2020-12-12 14:18:31 +01:00
}
}
}