Skip to content
This repository was archived by the owner on Jul 3, 2023. It is now read-only.

Commit 58d11ab

Browse files
author
gwind
committed
调整接口
1 parent 2f6808c commit 58d11ab

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

src/codebase/controllers/npr.py src/codebase/controllers/lpr.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from codebase.web import APIRequestHandler
99

1010

11-
class NPRHandler(APIRequestHandler):
11+
class LPRHandler(APIRequestHandler):
1212

1313
def post(self):
1414
"""识别车牌
@@ -18,5 +18,11 @@ def post(self):
1818

1919
image = io.imread(url)
2020
info = HyperLPR_PlateRecogntion(image)
21-
logging.info("识别车牌:%s", info)
22-
self.success(data=info)
21+
if info:
22+
item = info[0]
23+
logging.info("识别车牌:%s", info)
24+
self.success(data={"lp": item[0], "precision": item[1], "pos": item[2]})
25+
return
26+
27+
logging.info("识别失败:%s", url)
28+
self.success(status="unknown", message="车牌识别失败")

src/codebase/schema.yml

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: '3.0.2'
22
info:
3-
title: 工作人员小程序端 API
3+
title: LPR (车牌识别)服务 API
44
version: '1.0.0'
55
description: |
66
注意
@@ -10,7 +10,7 @@ servers:
1010
- url: https://localhost:3000
1111
description: 本地开发环境
1212
tags:
13-
- name: npr
13+
- name: lpr
1414
description: 车牌识别
1515

1616

@@ -24,11 +24,11 @@ paths:
2424
description: OK
2525

2626

27-
"/npr":
27+
"/lpr":
2828

2929
post:
3030
tags:
31-
- npr
31+
- lpr
3232
summary: 识别车牌
3333
requestBody:
3434
required: true
@@ -50,16 +50,35 @@ paths:
5050
application/json:
5151
schema:
5252
type: object
53+
required:
54+
- status
5355
properties:
5456
status:
5557
type: string
56-
description: success
58+
description: |
59+
识别成功返回 `success` ,识别失败返回 `unknown`
60+
enum:
61+
- success
62+
- unknown
5763
data:
5864
type: object
65+
required:
66+
- lp
67+
- precision
68+
description: |
69+
如果识别成功,则返回该数值
5970
properties:
60-
np:
71+
lp:
6172
type: string
6273
description: 车牌
74+
precision:
75+
type: number
76+
description: 精准度
77+
pos:
78+
type: array
79+
description: 坐标
80+
items:
81+
type: number
6382

6483

6584
components:

src/codebase/urls.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from codebase.controllers import (
44
default,
5-
npr
5+
lpr
66
)
77

88

@@ -15,7 +15,7 @@
1515

1616
# NPR
1717

18-
url(r"/npr",
19-
npr.NPRHandler),
18+
url(r"/lpr",
19+
lpr.LPRHandler),
2020

2121
]

0 commit comments

Comments
 (0)