You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.4 KiB
48 lines
1.4 KiB
# encoding=utf8
|
|
|
|
import cv2
|
|
import sys
|
|
import os
|
|
|
|
|
|
# province
|
|
for i in range(0,31):
|
|
dir = './province/%s/' % i
|
|
for rt, dirs, files in os.walk(dir):
|
|
for filename in files:
|
|
filename1 = dir + filename
|
|
img = cv2.imread(filename1)
|
|
img = cv2.resize(img, (20, 20))
|
|
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
|
filename = dir + filename.split(".")[0]+".jpg"
|
|
os.remove(filename1)
|
|
cv2.imwrite(filename, img)
|
|
|
|
|
|
# area
|
|
for i in range(0, 26):
|
|
dir = './area/%s/' % i
|
|
for rt, dirs, files in os.walk(dir):
|
|
for filename in files:
|
|
filename1 = dir + filename
|
|
img = cv2.imread(filename1)
|
|
img = cv2.resize(img, (20, 20))
|
|
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
|
filename = dir + filename.split(".")[0]+".jpg"
|
|
os.remove(filename1)
|
|
cv2.imwrite(filename, img)
|
|
|
|
# letter
|
|
for i in range(0, 34):
|
|
dir = './letter/%s/' % i
|
|
for rt, dirs, files in os.walk(dir):
|
|
for filename in files:
|
|
filename1 = dir + filename
|
|
img = cv2.imread(filename1)
|
|
img = cv2.resize(img, (20, 20))
|
|
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
|
filename = dir + filename.split(".")[0]+".jpg"
|
|
os.remove(filename1)
|
|
cv2.imwrite(filename, img)
|
|
|