forked from Priyanka-M96/Hand_pose_DKE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
normalize.py
26 lines (22 loc) · 855 Bytes
/
normalize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import cv2
import os
from os.path import isfile, join
print(os.listdir("Poses/"))
poses = os.listdir('Poses/')
for pose in poses:
print(">> Working on pose : " + pose)
subdirs = os.listdir('Poses/' + pose + '/')
for subdir in subdirs:
files = os.listdir('Poses/' + pose + '/' + subdir + '/')
print(">> Working on examples : " + subdir)
for file in files:
if(file.endswith(".png")):
path = 'Poses/' + pose + '/' + subdir + '/' + file
# Read image
im = cv2.imread(path)
height, width, channels = im.shape
if not height == width == 28:
# Resize image
im = cv2.resize(im, (28, 28), interpolation=cv2.INTER_AREA)
# Write image
cv2.imwrite(path, im)