Google cloud platform 谷歌OCR语言提示
这里的文档页面上说:您可以指定语言提示,以帮助OCR更准确地检测图像中的文本。有人知道我将在代码中的何处指定语言提示吗?我正在使用.net控制台应用程序对其进行编程Google cloud platform 谷歌OCR语言提示,google-cloud-platform,ocr,google-cloud-vision,Google Cloud Platform,Ocr,Google Cloud Vision,这里的文档页面上说:您可以指定语言提示,以帮助OCR更准确地检测图像中的文本。有人知道我将在代码中的何处指定语言提示吗?我正在使用.net控制台应用程序对其进行编程 using Google.Cloud.Vision.V1; using System; namespace GoogleCloudSamples { public class QuickStart { public static void Main(string[] args) {
using Google.Cloud.Vision.V1;
using System;
namespace GoogleCloudSamples
{
public class QuickStart
{
public static void Main(string[] args)
{
// Instantiates a client
var client = ImageAnnotatorClient.Create();
// Load the image file into memory
var image = Image.FromFile("wakeupcat.jpg");
// Performs label detection on the image file
var response = client.DetectLabels(image);
foreach (var annotation in response)
{
if (annotation.Description != null)
Console.WriteLine(annotation.Description);
}
}
}
}
我似乎无法访问ImageContext类的语言提示属性,因为它是只读的。有没有办法创建一个ImageContext,在这里我可以指定语言提示?您可以创建ImageContext对象并在AnnotateImageRequest中使用以下命令设置它:
// Build ImageContext object
ImageContext imageContext = ImageContext.newBuilder().addLanguageHints("en").build();
// Set it to AnnotateImageRequest
AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).setImageContext(imageContext).build();
我也有同样的问题并解决了。语言提示是列表。您可以添加语言。当然,您也可以添加多种语言
ImageContext imageContext = new ImageContext();
imageContext.LanguageHints.Add("en");
imageContext.LanguageHints.Add("ko");