Add Python Demo
This commit is contained in:
Binary file not shown.
@@ -34,7 +34,7 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:icon="@mipmap/logo"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
@@ -0,0 +1,40 @@
|
||||
# 导入cv相关库
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PIL import ImageFont
|
||||
from PIL import Image
|
||||
from PIL import ImageDraw
|
||||
# 导入依赖包
|
||||
import hyperlpr3 as lpr3
|
||||
|
||||
|
||||
def draw_plate_on_image(img, box, text, font):
|
||||
x1, y1, x2, y2 = box
|
||||
cv2.rectangle(img, (x1, y1), (x2, y2), (139, 139, 102), 2, cv2.LINE_AA)
|
||||
cv2.rectangle(img, (x1, y1 - 20), (x2, y1), (139, 139, 102), -1)
|
||||
data = Image.fromarray(img)
|
||||
draw = ImageDraw.Draw(data)
|
||||
draw.text((x1 + 1, y1 - 18), text, (255, 255, 255), font=font)
|
||||
res = np.asarray(data)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
# 中文字体加载
|
||||
font_ch = ImageFont.truetype("../resource/font/platech.ttf", 20, 0)
|
||||
|
||||
# 实例化识别对象
|
||||
catcher = lpr3.LicensePlateCatcher(detect_level=lpr3.DETECT_LEVEL_HIGH)
|
||||
# 读取图片
|
||||
image = cv2.imread("/Users/tunm/datasets/boundingbox/[[359, 1292], [487, 1292], [487, 1324], [359, 1324]].jpg")
|
||||
|
||||
# 执行识别算法
|
||||
results = catcher(image)
|
||||
for code, confidence, type_idx, box in results:
|
||||
# 解析数据并绘制
|
||||
text = f"{code} - {confidence:.2f}"
|
||||
image = draw_plate_on_image(image, box, text, font=font_ch)
|
||||
|
||||
# 显示检测结果
|
||||
cv2.imshow("w", image)
|
||||
cv2.waitKey(0)
|
||||
@@ -241,7 +241,7 @@ sh command/build_release_android_share.sh
|
||||
|
||||
### 识别测试APP
|
||||
|
||||
- 体验 Android APP:[APK下载](https://github.com/szad670401/HyperLPR/blob/master/apk/hyperlpr3-demo.apk?raw=true)
|
||||
- 体验 Android APP:[扫码下载](http://fir.tunm.top/hyperlpr)
|
||||
|
||||
#### 获取帮助
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user