Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
liufl666 committed Oct 14, 2022
1 parent b6d3225 commit 3a3fbb6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def loc_run(img):
box = extract_min_rect(cnts, orig, rect)
warped = four_point_transform(img, box)
cv2.imwrite('./QRcode/warped.jpg', warped)
print(10 * '*' + 'Localization Process End' + 10 * '*')
print(10 * '*' + 'Localization Process Finished' + 10 * '*')

return warped

Expand Down
5 changes: 3 additions & 2 deletions Process.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,17 @@ def process_run(img, keyword: str, row: int, colum: int):
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img = cv2.GaussianBlur(img, (5, 5), 0)

divided_grey = divide(img, r, c)
divided_grey = divide(img, row, colum)

# 输出图像块,如果没有blocks目录则创建目录
if os.path.exists('./blocks/'):
del_file('./blocks/')
else:
os.makedirs('./blocks/')
show_blocks(divided_grey)
blocks_grey = process_blocks(divided_grey, k)
blocks_grey = process_blocks(divided_grey, keyword)
assembled = avengers_assemble(blocks_grey)
print(10 * '*' + 'Picture Processing Finished' + 10 * '*')

return assembled

Expand Down
24 changes: 24 additions & 0 deletions Rec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding:utf-8 -*-
"""
作者:机智的枫树
日期:2022年10月14日
"""

import pyzbar.pyzbar as pyz
import cv2


def rec_run(img):
if len(img.shape) == 3:
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
barcode = pyz.decode(img)
for result in barcode:
result = result.data.decode('utf-8')
print('Result:', result)
print(10 * '*' + 'Recognition Success' + 10 * '*')


if __name__ == '__main__':
image = cv2.imread('./QRcode/warped.jpg')
rec_run(image)

27 changes: 27 additions & 0 deletions RunMe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding:utf-8 -*-
"""
作者:机智的枫树
日期:2022年10月14日
"""

import cv2
import Process as Pro
import Loc
import Rec

parser = Pro.get_parser()
args = parser.parse_args()
n = args.number
k = args.keyword
s = args.scale

# 根据输入参数读图
image = cv2.imread('./QRcode/' + str(n) + '.jpg')
warped = Loc.loc_run(image)

r, c = int(s[0]), int(s[1])
output = Pro.process_run(warped, k, r, c)
o = args.output
cv2.imwrite('./QRcode/OUTPUT_EquAf' + str(o) + '_' + str(r) + 'x' + str(c) + '.jpg', output)

Rec.rec_run(output)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
matplotlib
opencv-contrib-python
numpy
numpy
pyzbar

0 comments on commit 3a3fbb6

Please sign in to comment.