Skip to content

Commit 787ca0c

Browse files
authored
Create ddddocr_test.py
1 parent df91c62 commit 787ca0c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

moumoubaimifan/ddddocr_test.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import ddddocr
2+
import cv2
3+
4+
5+
def hk():
6+
det = ddddocr.DdddOcr(det=False, ocr=False)
7+
8+
with open('hycdn.png', 'rb') as f:
9+
target_bytes = f.read()
10+
11+
with open('background.jpg', 'rb') as f:
12+
background_bytes = f.read()
13+
14+
res = det.slide_match(target_bytes, background_bytes, simple_target=True)
15+
16+
print(res)
17+
18+
19+
20+
def dx():
21+
det = ddddocr.DdddOcr(det=True)
22+
23+
with open("eb.jpg", 'rb') as f:
24+
image = f.read()
25+
26+
poses = det.detection(image)
27+
print(poses)
28+
29+
im = cv2.imread("eb.jpg")
30+
31+
for box in poses:
32+
x1, y1, x2, y2 = box
33+
im = cv2.rectangle(im, (x1, y1), (x2, y2), color=(0, 0, 255), thickness=2)
34+
35+
cv2.imwrite("result.jpg", im)
36+
37+
def zm():
38+
39+
ocr = ddddocr.DdddOcr(old=True)
40+
for i in ['z1.jpg', 'z2.jpg']:
41+
with open(i, 'rb') as f:
42+
image = f.read()
43+
44+
res = ocr.classification(image)
45+
print(res)

0 commit comments

Comments
 (0)