RhSolutions-AddIn/RhSolutions.AddIn/Tools/OcrTool.cs

30 lines
711 B
C#

using System.Threading.Tasks;
using SnippingTool;
using VisionClient.Services;
namespace RhSolutions.Tools;
internal class OcrTool : Tool
{
public Application Application { get; set; }
private IYandexVisionClient client;
public OcrTool(ReaderFactory readerFactory, WriterFactory writerFactory, Application application, IYandexVisionClient visionClient) : base(readerFactory, writerFactory)
{
Application = application;
client = visionClient;
}
public override void Execute()
{
Application.Visible = false;
Task.Run(async delegate
{
await Task.Delay(100);
}).Wait();
string shot = Snipper.SnipBase64();
var result = client.ProcessImage(shot);
Application.Visible = true;
}
}