forked from MrEliptik/HandPose
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnormalize.py
More file actions
44 lines (40 loc) · 1.56 KB
/
normalize.py
File metadata and controls
44 lines (40 loc) · 1.56 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import cv2
import os
from os.path import isfile, join
os.system("rm Poses/.DS*")
os.system("rm Poses/*/.DS*")
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:
print(subdir)
files = os.listdir('Poses/' + pose + '/' + subdir + '/')
print(">> Working on examples : " + subdir)
# for file in files:
# if (file.endswith(".mp4")):
# print(file)
# cap = cv2.VideoCapture('Poses/' + pose + '/' + subdir + '/'+file)
# count = 0
# while cap.isOpened():
# ret,frame = cap.read()
# cv2.imshow('window-name',frame)
# cv2.imwrite("frame%d.jpg" % count, frame)
# count = count + 1
# if cv2.waitKey(10) & 0xFF == ord('q'):
# break
# cap.release()
# cv2.destroyAllWindows()
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)
print("wrote an image")