【发布时间】:2019-02-24 03:22:47
【问题描述】:
我正在尝试使用 Google Cloud Vision V1 Api 的 ImageAnnotatorClient 类。我正在关注https://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.Vision.V1/api/Google.Cloud.Vision.V1.ImageAnnotatorClient.html
下的示例创建(ServiceEndpoint, ImageAnnotatorSettings)
标题。我正在使用 C# 并尝试构建一个经典的控制台应用程序。我正在使用来自 Nuget 的 GRPC.Core 版本 1.15.0 和 Google.Cloud.Vision.V1 版本 1.2.0。我得到一个编译错误
“GoogleCredential”不包含对 'ToChannelCredentials' 并且没有扩展方法 'ToChannelCredentials' 可以找到接受“GoogleCredential”类型的第一个参数
以下是我的代码:
GoogleCredential credential = GoogleCredential
.FromFile(@"C:\Users\...\12345.json")
.CreateScoped(ImageAnnotatorClient.DefaultScopes);
Google.Cloud.Vision.V1.Image image1 = Google.Cloud.Vision.V1.Image.FromFile(@"c:\Users\....\Image14b.png");
Channel channel = new Channel(
ImageAnnotatorClient.DefaultEndpoint.Host, ImageAnnotatorClient.DefaultEndpoint.Port, credential.ToChannelCredentials());
ImageAnnotatorClient client = ImageAnnotatorClient.Create(channel);
IReadOnlyList<EntityAnnotation> textAnnotations = client.DetectText(image1);
我在下面的行中收到错误:
Channel channel = new Channel(
ImageAnnotatorClient.DefaultEndpoint.Host, ImageAnnotatorClient.DefaultEndpoint.Port, credential.ToChannelCredentials());
有什么提示吗?
【问题讨论】:
标签: c# google-cloud-platform google-cloud-vision google-client