c# - Google Cloud Vision API - 创建 Grpc.Core.Channel 时出错
问题描述
我正在尝试使用 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”的定义,并且找不到接受“GoogleCredential”类型的第一个参数的扩展方法“ToChannelCredentials”
以下是我的代码:
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());
请问有什么提示吗?
解决方案
推荐阅读
- ios - 集合视图 (UPCarouselFlowLayout) 中的按钮未收到 onclick 事件
- java - TabView:左侧有一些选项卡,右侧有一些选项卡(中间有空格)
- amazon-ecs - AWS ECS 任务无法访问出站
- collections - 在邮递员中导出多个单独的集合
- python - 如何在 OnClick 上发送额外的字符串信息?
- javascript - 将重复的查询参数推送到 Vue 路由器
- c++ - 如何修复矢量不打印文件中的值
- php - Wordpress - post_category 显示没有结果
- django - 如何在 DRF 中使用 django filter_fields 和 ArrayField
- vbscript - 如何使用 VBScript 读取 dt_DBTIME2