【问题标题】:Google Cloud Vision annotateImage feature types don't existGoogle Cloud Vision annotateImage 特征类型不存在
【发布时间】:2019-09-09 11:56:57
【问题描述】:

我正在尝试使用 Node.js 在 GC Vision 中获得超过 10 个结果。 由于我无法将自定义请求直接传递给webDetection(),因此我尝试使用annotateImage()

const vision = require('@google-cloud/vision');
const client = new vision.ImageAnnotatorClient();

const webSearchRequest = {
  image: {
    source: {
      imageUri: `gs://${bucket.name}/${filePath}`
    }
  },
  features: [{
    maxResults: 50,
    type: vision.types.Feature.Type.WEB_DETECTION
  }]
};

return client.annotateImage(webSearchRequest).then(webResults => {
  console.log(webResults);
}

输出是Cannot read property 'Feature' of undefined

【问题讨论】:

  • 在这里尝试工作示例 --> cloud.google.com/vision/docs/…
  • @Christopher 正如我所说,该方法仅返回 10 个结果,并且您无法通过特征来获得更多结果。文档说您可以在这些情况下使用 annotateImage 代替,但这对我也不起作用。
  • 我一直在做一些研究并使用this测试工具,我看到type属性应该如下:type: WEB_DETECTION
  • 你在学习任何教程吗?如果是这样,您能否在您的问题中分享它?
  • @Miguel 可以,谢谢。我在关注这个 api:googleapis.dev/nodejs/vision/latest/…

标签: node.js google-cloud-platform google-cloud-functions google-vision


【解决方案1】:

出于可见性目的,我发布my solution from the comments 作为答案。

在使用this 工具进行一些研究和测试后,我发现type 属性应该如下:type: WEB_DETECTION 而不是type: vision.types.Feature.Type.WEB_DETECTION

【讨论】:

    猜你喜欢
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-22
    • 2020-05-08
    • 2017-07-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多