Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f206245

Browse files
committed
final 2
1 parent 44148c8 commit f206245

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

‎my01-OCR文字识别/使用-模板匹配-识别信用卡号码/matchTemplate_credit_card_num1.py‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
ref = cv2.cvtColor(ref, cv2.COLOR_BGR2GRAY)
5656
ref = cv2.threshold(ref, 10, 255, cv2.THRESH_BINARY_INV)[1]
5757

58-
cv2.imshow('ref',ref)
58+
cv2.imshow('ref',ref)
5959
cv2.waitKey(0)
6060

6161
'''
@@ -88,23 +88,23 @@
8888
print('digits:',digits.keys())
8989
'''
9090

91-
#try1
91+
#try1
9292
digits = {}
93-
rows,cols=ref.shape
94-
per=int(cols/10)
93+
rows,cols=ref.shape
94+
per=int(cols/10)
9595
for x in range(10):
96-
roi = ref[:, x*per:(x+1)*per]
96+
roi = ref[:, x*per:(x+1) *per]
9797
roi = cv2.resize(roi, (57, 88))
9898
cv2.imshow('roi', roi)
9999
cv2.waitKey(500)
100100

101101
# update the digits dictionary, mapping the digit name to the ROI
102102
digits[x] = roi
103103
# 从参考图像中提取数字,并将其与相应的数字名称相关联
104-
print('digits:',digits.keys())
104+
print('digits:',digits.keys())
105105

106106
# 初始化一对结构化的内核:
107-
#您可以将内核看作是一个小矩阵,我们在图像上滑动以进行(卷积)操作,例如模糊,锐化,边缘检测或其他图像处理操作。
107+
#您可以将内核看作是一个小矩阵,我们在图像上滑动以进行(卷积)操作,例如模糊,锐化,边缘检测或其他图像处理操作。
108108
# initialize a rectangular (wider than it is tall) and square
109109
# structuring kernel
110110
rectKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (9, 3))
@@ -184,11 +184,11 @@
184184

185185
# detect the contours of each individual digit in the group,
186186
# then sort the digit contours from left to right
187-
digitCnts = cv2.findContours(group.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
188-
cv2.imshow('digitCnts',digitCnts[0])
187+
digitCnts = cv2.findContours(group.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
188+
cv2.imshow('digitCnts',digitCnts[0])
189189
cv2.waitKey(1000)
190190
# digitCnts = digitCnts[0] if imutils.is_cv2() else digitCnts[1]
191-
digitCnts =digitCnts[1]
191+
digitCnts =digitCnts[1]
192192
# digitCnts = contours.sort_contours(digitCnts,method="left-to-right")[0]
193193

194194
# loop over the digit contours
@@ -224,7 +224,7 @@
224224
output.extend(groupOutput)
225225

226226
# display the output credit card information to the screen
227-
print("Credit Card Type: {}".format(FIRST_NUMBER.get(output[0],'None')))
227+
print("Credit Card Type: {}".format(FIRST_NUMBER.get(output[0],'None')))
228228
print("Credit Card #: {}".format("".join(output)))
229-
cv2.imshow("Image", image)
229+
cv2.imshow("Image", image)# TODO 效果不是很好,需要改进
230230
cv2.waitKey(0)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /