跳到主要内容

OCR文字识别

调用说明

还有一个功能名 /pic/ocr 增强版ocr识别更精准,但占资源

  • 请求参数
参数类型说明备注
fun字符串/pic/ocr请求功能名
id字符串设备id不允许多个
target_img字符串目标大图一般不用填写,默认使用我们内部的屏幕图像就行了
rect整数数组查找区域左x,上y,右x,下y
  • httpGet请求示例
curl --request GET \
--url 'http://192.168.9.9:9911/api/pic/ocr?id=6C:8D:C1:67:04:29'
  • httpPost请求示例
curl --request POST \
--url http://192.168.9.9:9911/api \
--header "content-type: multipart/form-data" \
--form "fun=/pic/ocr" \
--form "id=6C:8D:C1:67:04:29"
  • httpPost json请求示例【websocket也可发送同样json请求】
curl --request POST \
--url http://192.168.9.9:9911/api \
--header 'Content-Type: application/json' \
--data '{
"fun": "/pic/ocr",
"data": {
"id": "6C:8D:C1:67:04:29"
}
}'

响应结果

{
"data": {
"code": 0,
"id": "6C:8D:C1:67:04:29",
"list": [
{
"text": "幕镜像输出",
"centre": [
374,
475
],
"rect": [
270,
457,
478,
494
],
"similarity": 0.82
}
],
"message": "成功"
},
"status": 200,
"message": "成功",
"msgid": 0,
"fun": "/pic/ocr"
}
  • 响应data数据字段说明
    list返回了所有找到的文字列表
字段说明备注
text识别到的文字
centre文字的中心点x和y
rect文字的矩形区域左x,上y,右x,下y
similarity相似度