Google Cloud Vision API'请求拒绝被拒绝'

Vai*_*ngh 5 ocr gcloud google-vision google-cloud-vision

我是Google Cloud Vision API的新手.我正在对图像进行OCR,主要用于账单和收据.

对于一些图像,它工作正常,但当我尝试其他一些图像时,它给了我这个错误:

Error:  { [Error: Request Admission Denied.]
  code: 400,
  errors:
   [ { message: 'Request Admission Denied.',
       domain: 'global',
       reason: 'badRequest' } ] }
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

// construct parameters
const req = new vision.Request({
image: new vision.Image('./uploads/reciept.png'),
features: [
new vision.Feature('TEXT_DETECTION', 1)
]
})

vision.annotate(req).then((res) => {
// handling response
//console.log(res.responses[0].textAnnotations);
var desc=res.responses[0].textAnnotations;
var descarr=[];
for (i = 0; i < desc.length; i++) { 
descarr.push(desc[i].description);
}
Run Code Online (Sandbox Code Playgroud)

小智 6

也遇到了这个问题.这是图像尺寸问题.我不知道硬限制是什么.4MB工作,但9MB没有,它介于两者之间.