Skip to content

Commit 87953b5

Browse files
committed
m
1 parent bcf2087 commit 87953b5

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

yeke/py-recogLP/__init__.py

Whitespace-only changes.

yeke/py-recogLP/car.jpeg

46 KB
Loading

yeke/py-recogLP/cars.png

308 KB
Loading

yeke/py-recogLP/recogLP_demo1.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# 识别一个车牌
2+
from aip import AipOcr
3+
4+
APP_ID = '自己的 App ID'
5+
API_KEY = '自己的 Api Key'
6+
SECRET_KEY = '自己的 Secret Key'
7+
# 创建客户端对象
8+
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
9+
# 建立连接的超时时间,单位为毫秒
10+
client.setConnectionTimeoutInMillis(5000)
11+
# 通过打开的连接传输数据的超时时间,单位为毫秒
12+
client.setSocketTimeoutInMillis(5000)
13+
14+
# 读取图片
15+
def get_file_content(filePath):
16+
with open(filePath, 'rb') as fp:
17+
return fp.read()
18+
19+
image = get_file_content('car.jpeg')
20+
res = client.licensePlate(image)
21+
print('车牌号码:' + res['words_result']['number'])
22+
print('车牌颜色:' + res['words_result']['color'])

yeke/py-recogLP/recogLP_demo2.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 识别多个车牌
2+
from aip import AipOcr
3+
4+
APP_ID = '自己的 App ID'
5+
API_KEY = '自己的 Api Key'
6+
SECRET_KEY = '自己的 Secret Key'
7+
# 创建客户端对象
8+
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
9+
# 建立连接的超时时间,单位为毫秒
10+
client.setConnectionTimeoutInMillis(5000)
11+
# 通过打开的连接传输数据的超时时间,单位为毫秒
12+
client.setSocketTimeoutInMillis(5000)
13+
14+
# 读取图片
15+
def get_file_content(filePath):
16+
with open(filePath, 'rb') as fp:
17+
return fp.read()
18+
19+
image = get_file_content('cars.png')
20+
options = {}
21+
# 参数 multi_detect 默认为 false
22+
options['multi_detect'] = 'true'
23+
res = client.licensePlate(image, options)
24+
for wr in res['words_result']:
25+
print('车牌号码:' + wr['number'])
26+
print('车牌颜色:' + wr['color'])

0 commit comments

Comments
 (0)