基于chineseocr_lite的golang实现的ocr。
具体来说使用chineseocr_lite的OcrLiteOnnx 项目,参考xmcy001122 增加ocr.h和ocr.cpp,导出c风格函数,提供给ocr_wrapper.go使用cgo进行调用
docker run --name ocr --rm -d -p 8080:8080 xsdhy/go-ocr:1.0
参数 | 类型 | 是否必填 | 说明 |
---|---|---|---|
image_url | string | 图片地址和base64二选一 | |
image_base_64 | string | 图片地址和base64二选一 | |
need_block | bool | 否,默认为false |
curl --location 'http://127.0.0.1:8080/api/ocr' \
--header 'Content-Type: application/json' \
--data '{
"image_url":"图片地址"
}'
{
"code": 200,
"msg": "ok",
"data": {
"texts": [
"第一行识别结果",
"第二行识别结果",
"第三行识别结果",
]
}
}
支持图片上传文件,接口地址为/api/ocr_file,文件key为file,其余的和识别接口相同