easyocr插件使用
1、上传签字图片(图片背景颜色,和图片的大小会影响文字识别准确率)
2、服务端代码如下
from flask import Flask, request, Response
import easyocr
import json
from hanziconv import HanziConv
reader = easyocr.Reader(['ch_sim', 'en'], model_storage_directory='.EasyOCR/model', download_enabled=False)
app = Flask(__name__)
@app.route('/ocr', methods=['POST'])
def ocr():
image = request.files['image']
image.save('temp.png')
result = reader.readtext('temp.png', detail=0, paragraph=True)
chinese_text = ''
for item in result:
chinese_text += HanziConv.toSimplified(item)
text = chinese_text.replace(" ", "")
data = {
"code": 0,
"data": text
}
print(data)
json_data = json.dumps(data)
return Response(json_data, content_type='application/json;charset=utf-8')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8084)
3、客户端安卓调用示例项目地址https://gitee.com/firefix-m/aidl-sign-pdf