【乘风新基建】【百度大脑新品体验】仪器仪表盘读数
才能我浪费99 发布于2020-09 浏览:3269 回复:0
0
收藏

1.功能描述:

仪器仪表盘读数识别适用于不同品牌、不同型号的仪器仪表盘读数识别,广泛适用于各类血糖仪、血压仪、燃气表、电表等,可识别表盘上的数字、英文、符号,支持液晶屏、字轮表等表型

2.平台接入

具体接入方式比较简单,可以参考我的另一个帖子,这里就不重复了:
http://ai.baidu.com/forum/topic/show/943327

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

3.1首先认证授权:

在开始调用任何API之前需要先进行认证授权,具体的说明请参考:

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

具体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()
#print (token_content)
if token_content:
token_info = json.loads(token_content)
token_key = token_info['access_token']
return token_key

3.2百度仪器仪表盘读数识别分析接口调用:

详细说明请参考: https://ai.baidu.com/ai-doc/OCR/Jkafike0v

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

大家需要注意的是:
API访问URL:https://aip.baidubce.com/rest/2.0/ocr/v1/meter

输入图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px。支持jpg/jpeg/png/bmp格式.注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,)

Python3调用代码如下:

#调用百度仪器仪表盘接口

def meter(filename):
    request_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/meter"
    
    # 二进制方式打开图片文件
    f = open(filename, 'rb')
    img = base64.b64encode(f.read())
    
    params = dict()
    params['image'] = img
    params = urllib.parse.urlencode(params).encode("utf-8")
    
    access_token = get_token()
    
    begin = time.perf_counter()
    
    request_url = request_url + "?access_token=" + access_token
    request = urllib.request.Request(url=request_url, data=params)
    request.add_header('Content-Type', 'application/x-www-form-urlencoded')
    response = urllib.request.urlopen(request)
    content = response.read()
    
    end = time.perf_counter()
    print('处理时长:'+'%.2f'%(end-begin)+'秒')
    
    if content:
        #print(content)
        content=content.decode('utf-8')
        #print(content)
        data = json.loads(content)
        print(data)

4.功能评测:

具体效果如下:

处理时长:1.95秒
{'words_result': [{'words': '119', 'location': {'top': 144, 'left': 348, 'width': 104, 'height': 64}}, {'words': '81', 'location': {'top': 217, 'left': 364, 'width': 82, 'height': 59}}, {'words': '70', 'location': {'top': 287, 'left': 378, 'width': 65, 'height': 51}}, {'words': '83', 'location': {'top': 299, 'left': 284, 'width': 52, 'height': 37}}, {'words': 'mmHg', 'location': {'top': 277, 'left': 408, 'width': 34, 'height': 12}}, {'words': 'AVG', 'location': {'top': 208, 'left': 301, 'width': 25, 'height': 9}}, {'words': 'mmHg', 'location': {'top': 210, 'left': 417, 'width': 25, 'height': 8}}, {'words': 'M', 'location': {'top': 123, 'left': 327, 'width': 18, 'height': 16}}], 'log_id': 1307877851684405248, 'words_result_num': 8}
读书都十分准确。

5.测试结论和建议

测试下来,整体识别效果不错。百度仪器仪表盘读数识别的很准确,速度也很快,用起来非常的方便。对于对仪器仪表盘需要快速识别的场景会非常的有帮助。比如可以用于:
健康管理仪器读数识别:可配合各类血糖仪、血压仪等健康管理仪器使用,智能识别仪器读数,实现数据自动录入
生活电气仪表读数识别:快速识别燃气表、电表上的读数,提升工作人员抄录效率,实现仪表数据录入的自动化

收藏
点赞
0
个赞
TOP
切换版块