-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12_resize.py
executable file
·23 lines (21 loc) · 1.04 KB
/
12_resize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import cv2,glob,argparse,os
def parse_args():
parser = argparse.ArgumentParser(description='resize pedestrains to a uniform size.')
parser.add_argument('--root', dest='root',required=True, help='path to root')
parser.add_argument('--id', dest='id', required=True, help='which id to extract')
parser.add_argument('--width', dest='width', type=int, help='desired width of output image',default=64)
parser.add_argument('--height', dest='height', type=int, help='desired height of output image',default=128)
args = parser.parse_args()
return args
if __name__ =='__main__':
args = parse_args()
folders = glob.glob(os.path.join(args.root,'{}*'.format(args.id)))
for folder in folders:
if not os.path.isdir(folder):
continue
ims = glob.glob(folder+'\\*.jpg')
for im in ims:
img = cv2.imread(im)
img = cv2.resize(img, (args.width, args.height))
#im = im.replace(im.split('\\')[-1],'r_'+im.split('\\')[-1])
cv2.imwrite(im, img)