我想使用Google Vision API的DetectText方法运行OCR。我想为我开发的OCR程序在运行中断开连接的情况做准备。所以我想在调用DetectText方法后2秒钟内没有响应时生成错误。 (默认值为10分钟,设置为600000毫秒)。谢谢您的帮助。在示例源中将更加有用。
谢谢。
using Google.Cloud.Vision.V1;
var image = Google.Cloud.Vision.V1.Image.FromFile(sFilename);
var client = ImageAnnotatorClient.Create();
var response = client.DetectText(image);
答案 0 :(得分:0)
DetectText方法调用其他CallSettings参数。
using Google.Cloud.Vision.V1;
using Google.Api.Gax;
using Google.Api.Gax.Grpc;
var timeout = new TimeSpan(0, 0, 2);
CallSettings callSettings = CallSettings.FromCallTiming(CallTiming.FromExpiration(Expiration.FromTimeout(timeout)));
var image = Google.Cloud.Vision.V1.Image.FromFile(sFilename);
var client = ImageAnnotatorClient.Create();
var response = client.DetectText(image, null, 0, callSettings);