c# - 如何使用谷歌图像到文本 API 获取文本的 XY 坐标?
问题描述
我正在尝试使用 Google.Cloud.Vision.V1的 Windows 应用程序我能够提取文本并能够翻译,但我目前的意图是获取图像上文本的 XY 坐标,所以稍后我可以显示翻译文本在原始图像上的确切位置。
有人可以告诉我如何实现吗?
我目前的方法如下
var credential = GoogleCredential.FromFile(JsonFilePath).CreateScoped(ImageAnnotatorClient.DefaultScopes);
var channel = new Grpc.Core.Channel(ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials());
var client = ImageAnnotatorClient.Create();
var image = Image.FromFile(@"D:\Work Temp\image_2.JPG");
// Performs label detection on the image file
var response = client.DetectText(image); // TODO: need to get XY Coordinates of those texts
foreach (var annotation in response)
{
if (annotation.Description != null)
{
Console.WriteLine(annotation.Description);
translatedText.Add(TranslateTextSample(annotation.Description, "en"));
}
}
textTranslate.Lines = translatedText.ToArray();
解决方案
推荐阅读
- python - 为什么 tensorflow 和 pytorch 中的 Resnet 模型给出不同的特征长度?
- reactjs - 材料表覆盖分页组件导致警告
- python - 如何在 python 中对齐替换的文本文件?
- mailkit - 关于 Mailkit 的查询
- flutter - Flutter ADS:为什么插页式广告在测试模式下有效,但在 Play Market 中无效?
- autohotkey - 如何在 If Else 中使用 GetKeyState 命令?
- tailwind-css - 在 TailWind CSS 中使用颜色
- python-3.x - 划分 range(len(dataframe[column])) 而不是值?
- r - mgcv 中的 GAM 错误:theta 估计中的步骤失败
- firebase - 优化firebase云功能的网络连接