Skip to content

Commit 2353110

Browse files
committed
Update
1 parent ab4ba13 commit 2353110

File tree

2 files changed

+70
-71
lines changed

2 files changed

+70
-71
lines changed

src/docscanner.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,3 @@ PyMODINIT_FUNC PyInit_docscanner(void)
101101
PyModule_AddStringConstant(module, "version", DDN_GetVersion());
102102
return module;
103103
}
104-

test.py

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ def showNormalizedImage(name, normalized_image):
1818
return mat
1919

2020
# decodeFile()
21-
# print('')
22-
# print('Test decodeFile()')
23-
# results = scanner.decodeFile("images/1.png")
24-
# image = cv2.imread("images/1.png")
25-
# for result in results:
26-
# x1 = result.x1
27-
# y1 = result.y1
28-
# x2 = result.x2
29-
# y2 = result.y2
30-
# x3 = result.x3
31-
# y3 = result.y3
32-
# x4 = result.x4
33-
# y4 = result.y4
21+
print('')
22+
print('Test decodeFile()')
23+
results = scanner.decodeFile("images/1.png")
24+
image = cv2.imread("images/1.png")
25+
for result in results:
26+
x1 = result.x1
27+
y1 = result.y1
28+
x2 = result.x2
29+
y2 = result.y2
30+
x3 = result.x3
31+
y3 = result.y3
32+
x4 = result.x4
33+
y4 = result.y4
3434

35-
# normalized_image = scanner.normalizeFile("images/1.png", x1, y1, x2, y2, x3, y3, x4, y4)
36-
# showNormalizedImage("Normalized Image", normalized_image)
37-
# cv2.drawContours(image, [np.int0([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
35+
normalized_image = scanner.normalizeFile("images/1.png", x1, y1, x2, y2, x3, y3, x4, y4)
36+
showNormalizedImage("Normalized Image", normalized_image)
37+
cv2.drawContours(image, [np.int0([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
3838

39-
# cv2.imshow("image", image)
40-
# cv2.waitKey(0)
39+
cv2.imshow('Document Image', image)
40+
cv2.waitKey(0)
4141

4242

4343
# decodeMat()
@@ -60,7 +60,7 @@ def showNormalizedImage(name, normalized_image):
6060
# showNormalizedImage("Normalized Image", normalized_image)
6161
# cv2.drawContours(image, [np.int0([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
6262

63-
# cv2.imshow("image", image)
63+
# cv2.imshow('Document Image', image)
6464
# cv2.waitKey(0)
6565

6666
# decodeMatAsync()
@@ -79,7 +79,7 @@ def showNormalizedImage(name, normalized_image):
7979

8080
# cv2.drawContours(image, [np.int0([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
8181

82-
# cv2.imshow("image", image)
82+
# cv2.imshow('Document Image', image)
8383
# cv2.waitKey(0)
8484

8585
# import cv2
@@ -88,63 +88,63 @@ def showNormalizedImage(name, normalized_image):
8888
# scanner.decodeMatAsync(image)
8989
# sleep(5)
9090

91-
g_results = None
92-
g_normalized_images = []
91+
# g_results = None
92+
# g_normalized_images = []
9393

94-
def callback(results):
95-
global g_results
96-
g_results = results
94+
# def callback(results):
95+
# global g_results
96+
# g_results = results
9797

98-
scanner.addAsyncListener(callback)
98+
# scanner.addAsyncListener(callback)
9999

100-
cap = cv2.VideoCapture(0)
101-
while True:
102-
ret, image = cap.read()
100+
# cap = cv2.VideoCapture(0)
101+
# while True:
102+
# ret, image = cap.read()
103103

104-
ch = cv2.waitKey(1)
105-
if ch == 27:
106-
break
107-
elif ch == ord('n'): # normalize image
108-
if g_results != None:
109-
g_normalized_images = []
110-
index = 0
111-
for result in g_results:
112-
x1 = result.x1
113-
y1 = result.y1
114-
x2 = result.x2
115-
y2 = result.y2
116-
x3 = result.x3
117-
y3 = result.y3
118-
x4 = result.x4
119-
y4 = result.y4
104+
# ch = cv2.waitKey(1)
105+
# if ch == 27:
106+
# break
107+
# elif ch == ord('n'): # normalize image
108+
# if g_results != None:
109+
# g_normalized_images = []
110+
# index = 0
111+
# for result in g_results:
112+
# x1 = result.x1
113+
# y1 = result.y1
114+
# x2 = result.x2
115+
# y2 = result.y2
116+
# x3 = result.x3
117+
# y3 = result.y3
118+
# x4 = result.x4
119+
# y4 = result.y4
120120

121-
normalized_image = scanner.normalizeBuffer(image, x1, y1, x2, y2, x3, y3, x4, y4)
122-
g_normalized_images.append((str(index), normalized_image))
123-
mat = showNormalizedImage(str(index), normalized_image)
124-
index += 1
125-
elif ch == ord('s'): # save image
126-
for data in g_normalized_images:
127-
# cv2.imwrite('images/' + str(time.time()) + '.png', image)
128-
cv2.destroyWindow(data[0])
129-
data[1].save(str(time.time()) + '.png')
130-
print('Image saved')
121+
# normalized_image = scanner.normalizeBuffer(image, x1, y1, x2, y2, x3, y3, x4, y4)
122+
# g_normalized_images.append((str(index), normalized_image))
123+
# mat = showNormalizedImage(str(index), normalized_image)
124+
# index += 1
125+
# elif ch == ord('s'): # save image
126+
# for data in g_normalized_images:
127+
# # cv2.imwrite('images/' + str(time.time()) + '.png', image)
128+
# cv2.destroyWindow(data[0])
129+
# data[1].save(str(time.time()) + '.png')
130+
# print('Image saved')
131131

132-
g_normalized_images = []
132+
# g_normalized_images = []
133133

134-
if image is not None:
135-
scanner.decodeMatAsync(image)
134+
# if image is not None:
135+
# scanner.decodeMatAsync(image)
136136

137-
if g_results != None:
138-
for result in g_results:
139-
x1 = result.x1
140-
y1 = result.y1
141-
x2 = result.x2
142-
y2 = result.y2
143-
x3 = result.x3
144-
y3 = result.y3
145-
x4 = result.x4
146-
y4 = result.y4
137+
# if g_results != None:
138+
# for result in g_results:
139+
# x1 = result.x1
140+
# y1 = result.y1
141+
# x2 = result.x2
142+
# y2 = result.y2
143+
# x3 = result.x3
144+
# y3 = result.y3
145+
# x4 = result.x4
146+
# y4 = result.y4
147147

148-
cv2.drawContours(image, [np.int0([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
148+
# cv2.drawContours(image, [np.int0([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
149149

150-
cv2.imshow('Document Scanner', image)
150+
# cv2.imshow('Document Scanner', image)

0 commit comments

Comments
 (0)