wei*_*193 10 google-cloud-platform google-cloud-vision
当我们返回"我们目前无法访问该URL"时,我会调用google api.但资源必须存在且可以访问.
https://vision.googleapis.com/v1/images:annotate
请求内容:
{
"requests": [
{
"image": {
"source": {
"imageUri": "http://yun.jybdfx.com/static/img/homebg.jpg"
}
},
"features": [
{
"type": "TEXT_DETECTION"
}
],
"imageContext": {
"languageHints": [
"zh"
]
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
回复内容:
{
"responses": [
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
截至 2017 年 8 月,这是 Google Cloud Vision API 的一个已知问题(来源)。它似乎对某些用户进行了重现,但不是确定性的,而且我自己也遇到过很多图像。
当前的解决方法包括将您的内容上传到 Google Cloud Storage 并传递其 gs:// uri(注意它不必在 GCS 上公开可读)或在本地下载图像并将其以 base64 格式传递给视觉 API。
下面是后一种方法的 Node.js 示例:
const request = require('request-promise-native').defaults({
encoding: 'base64'
})
const data = await request(image)
const response = await client.annotateImage({
image: {
content: data
},
features: [
{ type: vision.v1.types.Feature.Type.LABEL_DETECTION },
{ type: vision.v1.types.Feature.Type.CROP_HINTS }
]
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2066 次 |
| 最近记录: |