【发布时间】:2019-09-20 19:59:11
【问题描述】:
我正在尝试让 Google Vision API 与我的项目一起使用,但遇到了问题。我不断收到以下错误:
Grpc.Core.RpcException: 'Status(StatusCode=PermissionDenied, Detail="此 API 方法需要启用计费
我创建了一个服务帐户,启用了计费功能,并且我拥有 .json 文件。我的 GOOGLE_APPLICATION_CREDENTIALS 帐户的环境变量指向 .json 文件。
我尚未使用 Google 文档或查看 StackOverFlow 找到解决问题的方法。
using Google.Cloud.Vision.V1;
using System;
using System.Collections.Generic;
namespace Vision
{
internal static class GoogleVision
{
public static EntityAnnotation[] GetAnnotations(EventManager em, string filePath, string EventNr)
{
{
ImageAnnotatorClient Client = ImageAnnotatorClient.Create();
Image Image = Google.Cloud.Vision.V1.Image.FromFile(filePath);
IReadOnlyList<EntityAnnotation> Response = Client.DetectLabels(Image);
EntityAnnotation[] annotations = new EntityAnnotation[Response.Count];
for (int i = 0; i < annotations.Length; i++)
{
annotations[i] = Response[i];
}
return annotations;
}
}
}
}
【问题讨论】:
标签: c# windows visual-studio google-api environment-variables