iOCR财会票据识别 请求报错
136******02 发布于2019-06 浏览:1966 回复:6
0
收藏

请求财会票据识别接口 https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise/finance
按文档说明,其中有三个非必填参数:

templateSign 模板id     

detectorId 检测器id ,可选值仅有0。detectorId = 0时,启用票据分类检测功能,可对发票粘贴单上的多张不同种类票据进行分类检测和识别

classifierId 分类器Id 分类器Id,用于指定使用哪个分类器。templateSign、classifierId与detectorId需保证至少存在一个,优先使用templateSign:存在templateSign时,表示使用指定模板;如果没有                    templateSign而detectorId = 0,则使用票据检测分类功能;仅有classifierId,则使用指定分类器去判断使用哪个模板

如果给定 templateSign 属性,则返回正常
如果只传:detectorId 属性(值为0),就报错,报错内容:{"error_msg":"invalid param, modelId is not number,please check your param","data":{"isStructured":false,"logId":"156146146659325"},"error_code":282004}。

但想要 启用票据分类检测功能,对发票粘贴单上的多张不同种类票据进行分类检测和识别。不知如何实现

请教如何实现

收藏
点赞
0
个赞
共6条回复 最后由用户已被禁言回复于2022-04
#7懒懒懒癌患者7回复于2020-01

通过HttpResponseMessage reponse = client.PostAsync(authHost, new FormUrlEncodedContent(paraList)).Result没有正确获取的access_token,报错信息如下:{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent。

这个应该怎么解决呢?

 

0
#6wangwei8638回复于2019-06
#5 know_heartme回复
[代码] 参考一下python的demo哈

实现了吗?

0
#5know_heartme回复于2019-06
# encoding=utf-8

import requests,json,base64
from urllib import quote
import os
headers = {
        'Content-Type': "application/x-www-form-urlencoded",
        'cache-control': "no-cache"
    };
def test_detect_image_vaild(image_path, url):

    image = open(save_image_path, 'rb');
    imageBase64str = base64.b64encode(image.read()).replace("\r", "");
    payload = {"detectorId":"0", "image":imageBase64str}
    response = requests.post(url, data=payload, headers=headers);
    print(response.text);

if __name__ == '__main__':
    
    save_image_path = ${image_path};
    url = "https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise/finance"
    token = ${access_token}
    test_detect_image_vaild(save_image_path, url + "?access_token=" + token)

参考一下python的demo哈

0
#4know_heartme回复于2019-06

# encoding=utf-8

import requests,json,base64
from urllib import quote
import os
headers = {
'Content-Type': "application/x-www-form-urlencoded",
'cache-control': "no-cache"
};
def test_detect_image_vaild(image_path, url):

image = open(save_image_path, 'rb');
imageBase64str = base64.b64encode(image.read()).replace("\r", "");
payload = {"detectorId":"0", "image":imageBase64str}
response = requests.post(url, data=payload, headers=headers);
print(response.text);

if __name__ == '__main__':

save_image_path = ${image_path};
url = "https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise/finance"
token = ${access_token}
test_detect_image_vaild(save_image_path, url + "?access_token=" + token)

0
#3know_heartme回复于2019-06

是否只传了detectorId这个参数,

0
#2know_heartme回复于2019-06

你的detectorId这个参数名 传对了嘛?

access_token 正确嘛

0
TOP
切换版块