mirror of
https://github.com/sml2h3/ddddocr.git
synced 2025-05-04 09:30:40 +08:00
45 lines
865 B
Python
45 lines
865 B
Python
import ddddocr
|
|
|
|
# # 识别
|
|
# ocr = ddddocr.DdddOcr(old=True)
|
|
#
|
|
# with open('test.jpg', 'rb') as f:
|
|
# img_bytes = f.read()
|
|
#
|
|
# res = ocr.classification(img_bytes)
|
|
# print(res)
|
|
|
|
# 目标检测
|
|
det = ddddocr.DdddOcr(det=True)
|
|
|
|
with open('微信图片_20220123122537.jpg', 'rb') as f:
|
|
img_bytes = f.read()
|
|
|
|
res = det.detection(img_bytes)
|
|
print(res)
|
|
|
|
# 滑块模板匹配方式
|
|
|
|
det = ddddocr.DdddOcr(det=False, ocr=False)
|
|
|
|
with open('b.png', 'rb') as f:
|
|
target_bytes = f.read()
|
|
|
|
with open('a.png', 'rb') as f:
|
|
background_bytes = f.read()
|
|
|
|
res = det.slide_match(target_bytes, background_bytes)
|
|
print(res)
|
|
|
|
det = ddddocr.DdddOcr(det=False, ocr=False)
|
|
|
|
with open('bg.jpg', 'rb') as f:
|
|
target_bytes = f.read()
|
|
|
|
with open('fullpage.jpg', 'rb') as f:
|
|
background_bytes = f.read()
|
|
|
|
|
|
res = det.slide_comparison(target_bytes, background_bytes)
|
|
|
|
print(res) |