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

30 lines
711 B
C#
Raw Normal View History

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