百度AI攻略:出租车票识别

1.功能描述:python

支持识别全国各大城市出租车票的6个关键字段,包括发票号码、代码、车号、日期、时间、金额。使用出租车票识别技术,实现对发票号码、日期、时间、金额等信息的自动识别和录入,应用于企业税务核算及内部报销等场景,可以有效减小人工核算工做量,下降人力成本,实现财税报销的自动化json

2.平台接入app

出租车票识别接入网址:https://console.bce.baidu.com/ai/#/ai/imageprocess/overview/index测试

具体接入方式比较简单,能够参考个人另外一个帖子,这里就不重复了:编码

http://ai.baidu.com/forum/topic/show/943327url

3.调用攻略(Python3)及评测rest

3.1首先认证受权:code

在开始调用任何API以前须要先进行认证受权,具体的说明请参考:blog

http://ai.baidu.com/docs#/Auth/toptoken

具体Python3代码以下:

# -*- coding: utf-8 -*-

#!/usr/bin/env python

import urllib

import base64

import json

#client_id 为官网获取的AK, client_secret 为官网获取的SK

client_id =【百度云应用的AK】

client_secret =【百度云应用的SK】

#获取token

def get_token():

    host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=' + client_id + '&client_secret=' + client_secret

    request = urllib.request.Request(host)

    request.add_header('Content-Type', 'application/json; charset=UTF-8')

    response = urllib.request.urlopen(request)

    token_content = response.read()

    if token_content:

        token_info = json.loads(token_content)

        token_key = token_info['access_token']

    return token_key

3.2出租车票识别分析接口调用:

详细说明请参考: https://ai.baidu.com/docs#/OCR-API/e376af19

说明的比较清晰,这里就不重复了。

你们须要注意的是:

API访问URL:https://aip.baidubce.com/rest/2.0/ocr/v1/taxi_receipt

图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式

Python3调用代码以下:

# -*- coding: utf-8 -*-

#!/usr/bin/env python

import urllib

import base64

import json

#client_id 为官网获取的AK, client_secret 为官网获取的SK

client_id =【百度云应用的AK】

client_secret =【百度云应用的SK】

#获取token

def get_token():

    host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=' + client_id + '&client_secret=' + client_secret

    request = urllib.request.Request(host)

    request.add_header('Content-Type', 'application/json; charset=UTF-8')

    response = urllib.request.urlopen(request)

    token_content = response.read()

    if token_content:

        token_info = json.loads(token_content)

        token_key = token_info['access_token']

    return token_key

4.功能评测:

选用不一样的数据对效果进行测试,具体效果以下(如下发票例子均来自网上):

发票代号: 15101143A005

发票号码: 33602136

车牌号: 33602136

日期:

上下车时间: 23:33-23:59

金额: ¥01..8

燃油附加费: ¥0.00

叫车服务费: ¥0.00

发票代号:

发票号码: 20170101

车牌号: 2017-01-01

日期: 2017-01-01

上下车时间: 20:16-20:27

金额: ¥15.00

燃油附加费: ¥0.00

叫车服务费: ¥0.00

测试下来,总体感受处理的很不错,此功能会大大的发票处理的工做量。

相关文章
相关标签/搜索