Google Vision API文本检测异常行为-Javascript [英] Google Vision API text detection strange behaviour - Javascript

查看:87
本文介绍了Google Vision API文本检测异常行为-Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近有关Google Vision API的某些内容发生了变化.我用它来识别收据上的文字.到目前为止一切都很好.突然,API开始对我的请求做出不同的响应.

Recently something about the Google Vision API changed. I am using it to recognize text on receipts. All good until now. Suddenly, the API started to respond differently to my requests.

我今天向API发送了相同的图片,并且得到了与以往不同的响应.我确保代码没有任何变化,所以这不是罪魁祸首.

I sent the same picture to the API today, and I got a different response (from the past). I ensured nothing was changed in my code, so this is not the culprit.

另一个奇怪的事情是,当我将图像上传到 https://cloud.google.com/响应中的vision/,在textAnnotations下,我得到了183个条目的数组.但是,当我从我的应用发布时,我得到了113个条目的数组.您可以在下面看到我的代码.

Another strange thing is that, when I upload the image to https://cloud.google.com/vision/ in the response, under textAnnotations, I get an array of 183 entries. However when I post from my app I get an array of 113 entries. Below you can see my code.

function googleScan(imageData) {
    var deferred = $q.defer();
    var url = "https://vision.googleapis.com/v1/images:annotate?key=<myAPIKey>";
    var payload = {
        requests: {
            image: {
                content: imageData.split(',')[1]
            },
            features: [{
                type: 'TEXT_DETECTION',
                maxResults:50
            }]
        }
    };
    $http.post(url, payload, { headers: { "NoAuthToken": true } }).then(function (response) {
        deferred.resolve(parseAnalyzedResult(response.data.responses[0].textAnnotations));
        console.log(response);
    }, function (error) {
        console.log(error);
    });
    return deferred.promise;

我想知道我的免费订阅是否有所改变,这就是为什么我收到不同的答复.那有可能吗?以前有没有人偶然发现这种问题?

I am wondering if somehow my free subscription got altered and that's why I receive a different response. Is that even possible? Has anyone stumbled upon this kind of issue before?

推荐答案

我遇到了同样的问题.对我来说,(我不知道为什么,但是...)从TEXT_DETECTION更改为DOCUMENT_TEXT_DETECTION解决了该问题.现在,当我将图像上传到Google Vision页面上时,从API接收到的结果是相同的.

I had the same issue. For me, (I don't know why, but...) changing from TEXT_DETECTION to DOCUMENT_TEXT_DETECTION solved the issue. Now the results received from the API are the same seen when I upload the image on Google Vision page.

这篇关于Google Vision API文本检测异常行为-Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆