https://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.Vision.V1/api/Google.Cloud.Vision.V1.ImageAnnotatorClient.html 在
创建(ServiceEndpoint、ImageAnnotatorSetting)
“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());
有什么提示吗?
您可能缺少using指令之一,特别是
using Grpc.Auth;
见 here 定义 ToChannelCredentials 作为一种扩展方法。
ToChannelCredentials
检查你是否包括所有其他的 using 示例中也存在指令。
using