一、腾讯云文字识别OCR接口:通用票据识别(高级版),识别效果图(转载于腾讯云官网):
二、准备工作
1、安装python,本文用PyCharm演示代码。
2、注册腾讯云(需要实名认证),获取API访问密匙:SecretId和SecretKey:
3、申请腾讯云免费使用额度,每月可免费识别1000张混贴财务发票:
4、阅读api接口参数说明文档:
5、准备文件夹用于存放待识别的混贴发票
三、python代码调试
1、以下代码用于识别发票大类type为3的增值税发票,发票子类型包括增值税纸质专票、增值税纸质普票、增值税电子专票、增值税电子普票、区块链电子发票、增值税电子普通发票(通行费):
import json
import base64
import os
import pandas
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.ocr.v20181119 import ocr_client, models
PNG_path = r'C:\Users\Administrator\Desktop\invoices' # 文件夹路径
list01 = os.listdir(PNG_path)
cred = credential.Credential("SecretId", "SecretKey")
httpProfile = HttpProfile()
httpProfile.endpoint = "ocr.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = ocr_client.OcrClient(cred, "ap-guangzhou", clientProfile)
req = models.RecognizeGeneralInvoiceRequest()
SingleInvoiceInfos = []
SingleInvoiceInfos2 = [