-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataProcessing.py
More file actions
77 lines (53 loc) · 1.69 KB
/
Copy pathdataProcessing.py
File metadata and controls
77 lines (53 loc) · 1.69 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import numpy as np
import cv2
def dataExtract(i, data_dir):
data = []
for i in range(i):
im = cv2.imread(data_dir.format(i + 1)+ '.png')
b, g, r = cv2.split(im)
b = b.reshape(1,-1)
g = g.reshape(1,-1)
r = r.reshape(1,-1)
x = np.hstack((b,g))
x = np.hstack((x,r))
x = np.append(x,1)
data.append(im)
data = np.array(data)
return(data)
training_nonface_data = []
for i in range(1000):
im = cv2.imread('./data/training/non-face/non-face{:0>2}'.format(i + 1) + '.png')
b, g, r = cv2.split(im)
b = b.reshape(1, -1)
g = g.reshape(1, -1)
r = r.reshape(1, -1)
x = np.hstack((b, g))
x = np.hstack((x, r))
x = np.append(x, 0)
training_nonface_data.append(im)
training_nonface_data = np.array(training_nonface_data)
test_face_data = []
for i in range(100):
im = cv2.imread('./data/test/face/face{:0>2}'.format(i + 1)+ '.png')
b, g, r = cv2.split(im)
b = b.reshape(1,-1)
g = g.reshape(1,-1)
r = r.reshape(1,-1)
x = np.hstack((b,g))
x = np.hstack((x,r))
x = np.append(x,1)
test_face_data.append(x)
test_nonface_data = []
for i in range(100):
im = cv2.imread('./data/test/non-face/non-face{:0>2}'.format(i + 1) + '.png')
b, g, r = cv2.split(im)
b = b.reshape(1, -1)
g = g.reshape(1, -1)
r = r.reshape(1, -1)
x = np.hstack((b, g))
x = np.hstack((x, r))
x = np.append(x, 0)
test_nonface_data.append(x)
test_face_data = np.array(test_face_data)
test_nonface_data = np.array(test_nonface_data)
test_data = np.vstack((test_face_data,test_nonface_data))