data augmentated and size/rotate experiment : because output looks folded
Showing
20 changed files
with
515 additions
and
387 deletions
This diff is collapsed. Click to expand it.
1 | +{ | ||
2 | + "cells": [ | ||
3 | + { | ||
4 | + "cell_type": "code", | ||
5 | + "execution_count": 2, | ||
6 | + "metadata": {}, | ||
7 | + "outputs": [], | ||
8 | + "source": [ | ||
9 | + "import cv2\n", | ||
10 | + "from glob import glob\n", | ||
11 | + "import os \n", | ||
12 | + "\n", | ||
13 | + "motionpatch_location = './motionpatch/*.png'\n", | ||
14 | + "output_location = './smallone/'\n", | ||
15 | + "count = 0\n", | ||
16 | + "for f in glob(motionpatch_location):\n", | ||
17 | + " count += 1\n", | ||
18 | + " image = cv2.imread(f)\n", | ||
19 | + " small = cv2.resize(image,dsize=(25,25))\n", | ||
20 | + " dst = os.path.join(output_location +str(count)+\".png\")\n", | ||
21 | + " cv2.imwrite(dst,small)" | ||
22 | + ] | ||
23 | + }, | ||
24 | + { | ||
25 | + "cell_type": "code", | ||
26 | + "execution_count": null, | ||
27 | + "metadata": {}, | ||
28 | + "outputs": [], | ||
29 | + "source": [] | ||
30 | + } | ||
31 | + ], | ||
32 | + "metadata": { | ||
33 | + "kernelspec": { | ||
34 | + "display_name": "Python 3", | ||
35 | + "language": "python", | ||
36 | + "name": "python3" | ||
37 | + }, | ||
38 | + "language_info": { | ||
39 | + "codemirror_mode": { | ||
40 | + "name": "ipython", | ||
41 | + "version": 3 | ||
42 | + }, | ||
43 | + "file_extension": ".py", | ||
44 | + "mimetype": "text/x-python", | ||
45 | + "name": "python", | ||
46 | + "nbconvert_exporter": "python", | ||
47 | + "pygments_lexer": "ipython3", | ||
48 | + "version": "3.5.0" | ||
49 | + } | ||
50 | + }, | ||
51 | + "nbformat": 4, | ||
52 | + "nbformat_minor": 2 | ||
53 | +} |
This diff is collapsed. Click to expand it.
DCGAN/outputs/output_augmentated_0318.tar
0 → 100644
This file is too large to display.
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "cells": [ | 2 | "cells": [ |
3 | { | 3 | { |
4 | "cell_type": "code", | 4 | "cell_type": "code", |
5 | - "execution_count": 3, | 5 | + "execution_count": 2, |
6 | "metadata": {}, | 6 | "metadata": {}, |
7 | "outputs": [], | 7 | "outputs": [], |
8 | "source": [ | 8 | "source": [ |
... | @@ -20,6 +20,49 @@ | ... | @@ -20,6 +20,49 @@ |
20 | " dst = os.path.join(output_location +str(count)+\".png\")\n", | 20 | " dst = os.path.join(output_location +str(count)+\".png\")\n", |
21 | " cv2.imwrite(dst,small)" | 21 | " cv2.imwrite(dst,small)" |
22 | ] | 22 | ] |
23 | + }, | ||
24 | + { | ||
25 | + "cell_type": "code", | ||
26 | + "execution_count": null, | ||
27 | + "metadata": {}, | ||
28 | + "outputs": [], | ||
29 | + "source": [ | ||
30 | + " def __init__(self, data_files):\n", | ||
31 | + " IMAGE_WIDTH = 25\n", | ||
32 | + " IMAGE_HEIGHT = 25\n", | ||
33 | + " self.image_mode = 'RGB'\n", | ||
34 | + " image_channels = 3\n", | ||
35 | + " self.data_files = data_files\n", | ||
36 | + " self.shape = len(data_files), IMAGE_WIDTH, IMAGE_HEIGHT, image_channels\n", | ||
37 | + " \n", | ||
38 | + " def get_image(iself,image_path, width, height, mode):\n", | ||
39 | + " image = Image.open(image_path)\n", | ||
40 | + " image = Image.im2double(image)\n", | ||
41 | + " return np.array(image)" | ||
42 | + ] | ||
43 | + }, | ||
44 | + { | ||
45 | + "cell_type": "code", | ||
46 | + "execution_count": 10, | ||
47 | + "metadata": {}, | ||
48 | + "outputs": [], | ||
49 | + "source": [ | ||
50 | + "from PIL import Image\n", | ||
51 | + "import numpy as np\n", | ||
52 | + "from matplotlib import pyplot\n", | ||
53 | + "\n", | ||
54 | + "imgloc = './smallone/5004.png'\n", | ||
55 | + "image = Image.open(imgloc)\n", | ||
56 | + "dst = os.path.join(\"./samples/5004.png\")\n", | ||
57 | + "pyplot.imsave(dst,image)\n" | ||
58 | + ] | ||
59 | + }, | ||
60 | + { | ||
61 | + "cell_type": "code", | ||
62 | + "execution_count": null, | ||
63 | + "metadata": {}, | ||
64 | + "outputs": [], | ||
65 | + "source": [] | ||
23 | } | 66 | } |
24 | ], | 67 | ], |
25 | "metadata": { | 68 | "metadata": { | ... | ... |
DCGAN/samples/5004.png
0 → 100644
1.4 KB
1 | -S001C002P005R002A008 | ||
2 | -S001C002P006R001A008 | ||
3 | -S001C003P002R001A055 | ||
4 | -S001C003P002R002A012 | ||
5 | -S001C003P005R002A004 | ||
6 | -S001C003P005R002A005 | ||
7 | -S001C003P005R002A006 | ||
8 | -S001C003P006R002A008 | ||
9 | -S002C002P011R002A030 | ||
10 | -S002C003P008R001A020 | ||
11 | -S002C003P010R002A010 | ||
12 | -S002C003P011R002A007 | ||
13 | -S002C003P011R002A011 | ||
14 | -S002C003P014R002A007 | ||
15 | -S003C001P019R001A055 | ||
16 | -S003C002P002R002A055 | ||
17 | -S003C002P018R002A055 | ||
18 | -S003C003P002R001A055 | ||
19 | -S003C003P016R001A055 | ||
20 | -S003C003P018R002A024 | ||
21 | -S004C002P003R001A013 | ||
22 | -S004C002P008R001A009 | ||
23 | -S004C002P020R001A003 | ||
24 | -S004C002P020R001A004 | ||
25 | -S004C002P020R001A012 | ||
26 | -S004C002P020R001A020 | ||
27 | -S004C002P020R001A021 | ||
28 | -S004C002P020R001A036 | ||
29 | -S005C002P004R001A001 | ||
30 | -S005C002P004R001A003 | ||
31 | -S005C002P010R001A016 | ||
32 | -S005C002P010R001A017 | ||
33 | -S005C002P010R001A048 | ||
34 | -S005C002P010R001A049 | ||
35 | -S005C002P016R001A009 | ||
36 | -S005C002P016R001A010 | ||
37 | -S005C002P018R001A003 | ||
38 | -S005C002P018R001A028 | ||
39 | -S005C002P018R001A029 | ||
40 | -S005C003P016R002A009 | ||
41 | -S005C003P018R002A013 | ||
42 | -S005C003P021R002A057 | ||
43 | -S006C001P001R002A055 | ||
44 | -S006C002P007R001A005 | ||
45 | -S006C002P007R001A006 | ||
46 | -S006C002P016R001A043 | ||
47 | -S006C002P016R001A051 | ||
48 | -S006C002P016R001A052 | ||
49 | -S006C002P022R001A012 | ||
50 | -S006C002P023R001A020 | ||
51 | -S006C002P023R001A021 | ||
52 | -S006C002P023R001A022 | ||
53 | -S006C002P023R001A023 | ||
54 | -S006C002P024R001A018 | ||
55 | -S006C002P024R001A019 | ||
56 | -S006C003P001R002A013 | ||
57 | -S006C003P007R002A009 | ||
58 | -S006C003P007R002A010 | ||
59 | -S006C003P007R002A025 | ||
60 | -S006C003P016R001A060 | ||
61 | -S006C003P017R001A055 | ||
62 | -S006C003P017R002A013 | ||
63 | -S006C003P017R002A014 | ||
64 | -S006C003P017R002A015 | ||
65 | -S006C003P022R002A013 | ||
66 | -S007C001P018R002A050 | ||
67 | -S007C001P025R002A051 | ||
68 | -S007C001P028R001A050 | ||
69 | -S007C001P028R001A051 | ||
70 | -S007C001P028R001A052 | ||
71 | -S007C002P008R002A008 | ||
72 | -S007C002P015R002A055 | ||
73 | -S007C002P026R001A008 | ||
74 | -S007C002P026R001A009 | ||
75 | -S007C002P026R001A010 | ||
76 | -S007C002P026R001A011 | ||
77 | -S007C002P026R001A012 | ||
78 | -S007C002P026R001A050 | ||
79 | -S007C002P027R001A011 | ||
80 | -S007C002P027R001A013 | ||
81 | -S007C002P028R002A055 | ||
82 | -S007C003P007R001A002 | ||
83 | -S007C003P007R001A004 | ||
84 | -S007C003P019R001A060 | ||
85 | -S007C003P027R002A001 | ||
86 | -S007C003P027R002A002 | ||
87 | -S007C003P027R002A003 | ||
88 | -S007C003P027R002A004 | ||
89 | -S007C003P027R002A005 | ||
90 | -S007C003P027R002A006 | ||
91 | -S007C003P027R002A007 | ||
92 | -S007C003P027R002A008 | ||
93 | -S007C003P027R002A009 | ||
94 | -S007C003P027R002A010 | ||
95 | -S007C003P027R002A011 | ||
96 | -S007C003P027R002A012 | ||
97 | -S007C003P027R002A013 | ||
98 | -S008C002P001R001A009 | ||
99 | -S008C002P001R001A010 | ||
100 | -S008C002P001R001A014 | ||
101 | -S008C002P001R001A015 | ||
102 | -S008C002P001R001A016 | ||
103 | -S008C002P001R001A018 | ||
104 | -S008C002P001R001A019 | ||
105 | -S008C002P008R002A059 | ||
106 | -S008C002P025R001A060 | ||
107 | -S008C002P029R001A004 | ||
108 | -S008C002P031R001A005 | ||
109 | -S008C002P031R001A006 | ||
110 | -S008C002P032R001A018 | ||
111 | -S008C002P034R001A018 | ||
112 | -S008C002P034R001A019 | ||
113 | -S008C002P035R001A059 | ||
114 | -S008C002P035R002A002 | ||
115 | -S008C002P035R002A005 | ||
116 | -S008C003P007R001A009 | ||
117 | -S008C003P007R001A016 | ||
118 | -S008C003P007R001A017 | ||
119 | -S008C003P007R001A018 | ||
120 | -S008C003P007R001A019 | ||
121 | -S008C003P007R001A020 | ||
122 | -S008C003P007R001A021 | ||
123 | -S008C003P007R001A022 | ||
124 | -S008C003P007R001A023 | ||
125 | -S008C003P007R001A025 | ||
126 | -S008C003P007R001A026 | ||
127 | -S008C003P007R001A028 | ||
128 | -S008C003P007R001A029 | ||
129 | -S008C003P007R002A003 | ||
130 | -S008C003P008R002A050 | ||
131 | -S008C003P025R002A002 | ||
132 | -S008C003P025R002A011 | ||
133 | -S008C003P025R002A012 | ||
134 | -S008C003P025R002A016 | ||
135 | -S008C003P025R002A020 | ||
136 | -S008C003P025R002A022 | ||
137 | -S008C003P025R002A023 | ||
138 | -S008C003P025R002A030 | ||
139 | -S008C003P025R002A031 | ||
140 | -S008C003P025R002A032 | ||
141 | -S008C003P025R002A033 | ||
142 | -S008C003P025R002A049 | ||
143 | -S008C003P025R002A060 | ||
144 | -S008C003P031R001A001 | ||
145 | -S008C003P031R002A004 | ||
146 | -S008C003P031R002A014 | ||
147 | -S008C003P031R002A015 | ||
148 | -S008C003P031R002A016 | ||
149 | -S008C003P031R002A017 | ||
150 | -S008C003P032R002A013 | ||
151 | -S008C003P033R002A001 | ||
152 | -S008C003P033R002A011 | ||
153 | -S008C003P033R002A012 | ||
154 | -S008C003P034R002A001 | ||
155 | -S008C003P034R002A012 | ||
156 | -S008C003P034R002A022 | ||
157 | -S008C003P034R002A023 | ||
158 | -S008C003P034R002A024 | ||
159 | -S008C003P034R002A044 | ||
160 | -S008C003P034R002A045 | ||
161 | -S008C003P035R002A016 | ||
162 | -S008C003P035R002A017 | ||
163 | -S008C003P035R002A018 | ||
164 | -S008C003P035R002A019 | ||
165 | -S008C003P035R002A020 | ||
166 | -S008C003P035R002A021 | ||
167 | -S009C002P007R001A001 | ||
168 | -S009C002P007R001A003 | ||
169 | -S009C002P007R001A014 | ||
170 | -S009C002P008R001A014 | ||
171 | -S009C002P015R002A050 | ||
172 | -S009C002P016R001A002 | ||
173 | -S009C002P017R001A028 | ||
174 | -S009C002P017R001A029 | ||
175 | -S009C003P017R002A030 | ||
176 | -S009C003P025R002A054 | ||
177 | -S010C001P007R002A020 | ||
178 | -S010C002P016R002A055 | ||
179 | -S010C002P017R001A005 | ||
180 | -S010C002P017R001A018 | ||
181 | -S010C002P017R001A019 | ||
182 | -S010C002P019R001A001 | ||
183 | -S010C002P025R001A012 | ||
184 | -S010C003P007R002A043 | ||
185 | -S010C003P008R002A003 | ||
186 | -S010C003P016R001A055 | ||
187 | -S010C003P017R002A055 | ||
188 | -S011C001P002R001A008 | ||
189 | -S011C001P018R002A050 | ||
190 | -S011C002P008R002A059 | ||
191 | -S011C002P016R002A055 | ||
192 | -S011C002P017R001A020 | ||
193 | -S011C002P017R001A021 | ||
194 | -S011C002P018R002A055 | ||
195 | -S011C002P027R001A009 | ||
196 | -S011C002P027R001A010 | ||
197 | -S011C002P027R001A037 | ||
198 | -S011C003P001R001A055 | ||
199 | -S011C003P002R001A055 | ||
200 | -S011C003P008R002A012 | ||
201 | -S011C003P015R001A055 | ||
202 | -S011C003P016R001A055 | ||
203 | -S011C003P019R001A055 | ||
204 | -S011C003P025R001A055 | ||
205 | -S011C003P028R002A055 | ||
206 | -S012C001P019R001A060 | ||
207 | -S012C001P019R002A060 | ||
208 | -S012C002P015R001A055 | ||
209 | -S012C002P017R002A012 | ||
210 | -S012C002P025R001A060 | ||
211 | -S012C003P008R001A057 | ||
212 | -S012C003P015R001A055 | ||
213 | -S012C003P015R002A055 | ||
214 | -S012C003P016R001A055 | ||
215 | -S012C003P017R002A055 | ||
216 | -S012C003P018R001A055 | ||
217 | -S012C003P018R001A057 | ||
218 | -S012C003P019R002A011 | ||
219 | -S012C003P019R002A012 | ||
220 | -S012C003P025R001A055 | ||
221 | -S012C003P027R001A055 | ||
222 | -S012C003P027R002A009 | ||
223 | -S012C003P028R001A035 | ||
224 | -S012C003P028R002A055 | ||
225 | -S013C001P015R001A054 | ||
226 | -S013C001P017R002A054 | ||
227 | -S013C001P018R001A016 | ||
228 | -S013C001P028R001A040 | ||
229 | -S013C002P015R001A054 | ||
230 | -S013C002P017R002A054 | ||
231 | -S013C002P028R001A040 | ||
232 | -S013C003P008R002A059 | ||
233 | -S013C003P015R001A054 | ||
234 | -S013C003P017R002A054 | ||
235 | -S013C003P025R002A022 | ||
236 | -S013C003P027R001A055 | ||
237 | -S013C003P028R001A040 | ||
238 | -S014C001P027R002A040 | ||
239 | -S014C002P015R001A003 | ||
240 | -S014C002P019R001A029 | ||
241 | -S014C002P025R002A059 | ||
242 | -S014C002P027R002A040 | ||
243 | -S014C002P039R001A050 | ||
244 | -S014C003P007R002A059 | ||
245 | -S014C003P015R002A055 | ||
246 | -S014C003P019R002A055 | ||
247 | -S014C003P025R001A048 | ||
248 | -S014C003P027R002A040 | ||
249 | -S015C001P008R002A040 | ||
250 | -S015C001P016R001A055 | ||
251 | -S015C001P017R001A055 | ||
252 | -S015C001P017R002A055 | ||
253 | -S015C002P007R001A059 | ||
254 | -S015C002P008R001A003 | ||
255 | -S015C002P008R001A004 | ||
256 | -S015C002P008R002A040 | ||
257 | -S015C002P015R001A002 | ||
258 | -S015C002P016R001A001 | ||
259 | -S015C002P016R002A055 | ||
260 | -S015C003P008R002A007 | ||
261 | -S015C003P008R002A011 | ||
262 | -S015C003P008R002A012 | ||
263 | -S015C003P008R002A028 | ||
264 | -S015C003P008R002A040 | ||
265 | -S015C003P025R002A012 | ||
266 | -S015C003P025R002A017 | ||
267 | -S015C003P025R002A020 | ||
268 | -S015C003P025R002A021 | ||
269 | -S015C003P025R002A030 | ||
270 | -S015C003P025R002A033 | ||
271 | -S015C003P025R002A034 | ||
272 | -S015C003P025R002A036 | ||
273 | -S015C003P025R002A037 | ||
274 | -S015C003P025R002A044 | ||
275 | -S016C001P019R002A040 | ||
276 | -S016C001P025R001A011 | ||
277 | -S016C001P025R001A012 | ||
278 | -S016C001P025R001A060 | ||
279 | -S016C001P040R001A055 | ||
280 | -S016C001P040R002A055 | ||
281 | -S016C002P008R001A011 | ||
282 | -S016C002P019R002A040 | ||
283 | -S016C002P025R002A012 | ||
284 | -S016C003P008R001A011 | ||
285 | -S016C003P008R002A002 | ||
286 | -S016C003P008R002A003 | ||
287 | -S016C003P008R002A004 | ||
288 | -S016C003P008R002A006 | ||
289 | -S016C003P008R002A009 | ||
290 | -S016C003P019R002A040 | ||
291 | -S016C003P039R002A016 | ||
292 | -S017C001P016R002A031 | ||
293 | -S017C002P007R001A013 | ||
294 | -S017C002P008R001A009 | ||
295 | -S017C002P015R001A042 | ||
296 | -S017C002P016R002A031 | ||
297 | -S017C002P016R002A055 | ||
298 | -S017C003P007R002A013 | ||
299 | -S017C003P008R001A059 | ||
300 | -S017C003P016R002A031 | ||
301 | -S017C003P017R001A055 | ||
302 | -S017C003P020R001A059 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | 1 | ||
2 | %your motion_patch location | 2 | %your motion_patch location |
3 | -ori = imread('/home/rfj/바탕화면/actionGAN/motion_patch/S001C001P001R001A020.png'); | 3 | +ori = imread('/home/rfj/바탕화면/actionGAN/DCGAN/new_motionpatch/sample_111.png'); |
4 | ori = im2double(ori); | 4 | ori = im2double(ori); |
5 | ori = ori(:,:,:); | 5 | ori = ori(:,:,:); |
6 | 6 | ... | ... |
This diff is collapsed. Click to expand it.
data_preprocessing/transform_all_halfsize.m
0 → 100644
1 | +clear; | ||
2 | + | ||
3 | +path_name = '/media/rfj/EEA4441FA443E923/nturgb_skeletones/'; | ||
4 | +fileID = fopen('/home/rfj/바탕화면/actionGAN/skeletone_INDEX/good_stand_2.txt','r'); | ||
5 | +formatSpec = '%s'; | ||
6 | +sizeA = [20 Inf]; | ||
7 | +perfect_list = fscanf(fileID,formatSpec,sizeA); | ||
8 | +perfect_list = perfect_list.'; | ||
9 | +fclose(fileID); | ||
10 | + | ||
11 | +L = length(perfect_list); | ||
12 | + | ||
13 | +for K = 1:L | ||
14 | + | ||
15 | + file_name = char(perfect_list(K,:)); | ||
16 | + name = strcat(path_name,file_name(1:20),'.skeleton'); | ||
17 | + [token,remainder] = strtok(file_name,'A'); | ||
18 | + class = str2num(remainder(2:4)); | ||
19 | + | ||
20 | + bodyinfo = read_skeleton_file(name); | ||
21 | + frame_num = size(bodyinfo,2); | ||
22 | + try | ||
23 | + %initialize | ||
24 | + cur_subject_x = zeros(frame_num, 25); | ||
25 | + cur_subject_y = zeros(frame_num, 25); | ||
26 | + cur_subject_z = zeros(frame_num, 25); | ||
27 | + | ||
28 | + tot_x = zeros(frame_num,25); | ||
29 | + tot_y = zeros(frame_num,25); | ||
30 | + tot_z = zeros(frame_num,25); | ||
31 | + | ||
32 | + joint_5 = zeros(1,3); | ||
33 | + joint_9 = zeros(1,3); | ||
34 | + joint_1 = zeros(1,3); | ||
35 | + joint_3 = zeros(1,3); | ||
36 | + | ||
37 | + %get total joints information | ||
38 | + for FN = 1:frame_num | ||
39 | + cur_body = bodyinfo(FN).bodies(1); | ||
40 | + joints = cur_body.joints; | ||
41 | + | ||
42 | + for JN = 1:25 | ||
43 | + tot_x(FN,JN) = joints(JN).x; | ||
44 | + tot_y(FN,JN) = joints(JN).y; | ||
45 | + tot_z(FN,JN) = joints(JN).z; | ||
46 | + end | ||
47 | + end | ||
48 | + | ||
49 | + %Orientation normalization 1 : in space | ||
50 | + %get median values | ||
51 | + M_x = median(tot_x); | ||
52 | + M_y = median(tot_y); | ||
53 | + M_z = median(tot_z); | ||
54 | + | ||
55 | + %set 3 points for make plane | ||
56 | + joint_5 = [M_x(5) M_y(5) M_z(5)]; | ||
57 | + joint_9 = [M_x(9) M_y(9) M_z(9)]; | ||
58 | + joint_1 = [M_x(1) M_y(1) M_z(1)]; | ||
59 | + joint_3 = [M_x(3) M_y(3) M_z(3)]; | ||
60 | + | ||
61 | + %find RIGID TRNASFORMATION matrix | ||
62 | + d1 = joint_1 - joint_5; | ||
63 | + d2 = joint_1 - joint_9; | ||
64 | + n1 = cross(d1,d2); % because we will parallel transform, don't need to find belly | ||
65 | + u1 = n1/norm(n1); | ||
66 | + u2 = [0 0 1]; | ||
67 | + cs1 = dot(u1,u2)/norm(u1)*norm(u2); | ||
68 | + ss1 = sqrt(1-cs1.^2); | ||
69 | + v1 = cross(u1,u2)/norm(cross(u1,u2)); | ||
70 | + | ||
71 | + R1 = [v1(1)*v1(1)*(1-cs1)+cs1 v1(1)*v1(2)*(1-cs1)-v1(3)*ss1 v1(1)*v1(3)*(1-cs1)+v1(2)*ss1]; | ||
72 | + R1(2,:) = [v1(1)*v1(2)*(1-cs1)+v1(3)*ss1 v1(2)*v1(2)*(1-cs1)+cs1 v1(2)*v1(3)*(1-cs1)-v1(1)*ss1]; | ||
73 | + R1(3,:) = [v1(1)*v1(3)*(1-cs1)-v1(2)*ss1 v1(2)*v1(3)*(1-cs1)+v1(1)*ss1 v1(3)*v1(3)*(1-cs1)+cs1]; | ||
74 | + | ||
75 | + %1-3 number tolls to parallel x axis. Rigid transformation on plane surface | ||
76 | + %Z axis coords oyler angle transform | ||
77 | + | ||
78 | + t = joint_3 - joint_1; | ||
79 | + d3 = R1(1,:) * t.'; | ||
80 | + d3(1,2) = R1(2,:) * t.'; | ||
81 | + d3(1,3) = R1(3,:) * t.'; | ||
82 | + | ||
83 | + u3 = d3(1:2)/norm(d3(1:2)); | ||
84 | + v3 = [u3(1) -u3(2)]; | ||
85 | + v3(2,:) = [u3(2) u3(1)]; | ||
86 | + u4 = [1 0].'; | ||
87 | + | ||
88 | + csss = v3\u4; | ||
89 | + cs2 = csss(1); | ||
90 | + ss2 = csss(2); | ||
91 | + | ||
92 | + R2 = [cs2 -ss2 0]; | ||
93 | + R2(2,:) = [ss2 cs2 0]; | ||
94 | + R2(3,:) = [0 0 1]; | ||
95 | + | ||
96 | + | ||
97 | + %apply rigid transformation | ||
98 | + for FN = 1:frame_num | ||
99 | + cur_body = bodyinfo(FN).bodies(1); | ||
100 | + joints = cur_body.joints; | ||
101 | + | ||
102 | + for JN = 1:25 | ||
103 | + a = R1(1,:) * [joints(JN).x joints(JN).y joints(JN).z].'; | ||
104 | + b = R1(2,:) * [joints(JN).x joints(JN).y joints(JN).z].'; | ||
105 | + c = R1(3,:) * [joints(JN).x joints(JN).y joints(JN).z].'; | ||
106 | + | ||
107 | + cur_subject_x(FN,JN) = R2(1,:) * [a b c].'; | ||
108 | + cur_subject_y(FN,JN) = R2(2,:) * [a b c].'; | ||
109 | + cur_subject_z(FN,JN) = R2(3,:) * [a b c].'; | ||
110 | + | ||
111 | + end | ||
112 | + end | ||
113 | + | ||
114 | + %orientation normalize 2 in plane surface | ||
115 | + if cur_subject_x(1,4) < cur_subject_x(1,1) | ||
116 | + cur_subject_x = 0 - cur_subject_x; | ||
117 | + end | ||
118 | + | ||
119 | + if cur_subject_y(1,9) > cur_subject_y(1,5) | ||
120 | + cur_subject_y = 0 - cur_subject_y; | ||
121 | + end | ||
122 | + | ||
123 | + % for save origin subjects before data augment | ||
124 | + clear_subject_x = cur_subject_x; | ||
125 | + clear_subject_y = cur_subject_y; | ||
126 | + clear_subject_z = cur_subject_z; | ||
127 | + | ||
128 | + % Left <-> Right Change : 2option | ||
129 | + for LR = 1:2 | ||
130 | + if LR == 1 | ||
131 | + augment_y = clear_subject_y; | ||
132 | + else | ||
133 | + augment_y = 0 - clear_subject_y; | ||
134 | + end | ||
135 | + | ||
136 | + %Height change : 3option | ||
137 | + for HE = 1:3 | ||
138 | + if HE == 1 | ||
139 | + augment_x = clear_subject_x.* 1.2; | ||
140 | + elseif HE==2 | ||
141 | + augment_x = clear_subject_x.* 1.0; | ||
142 | + else | ||
143 | + augment_x = clear_subject_x.* 0.8; | ||
144 | + end | ||
145 | + | ||
146 | + %Give Gaussian Random Variable : 0.01 - 6times | ||
147 | + for RV = 1:6 | ||
148 | + %3. Gaussian Random filter 0.1 | ||
149 | + cur_subject_x = augment_x + 0.01.*randn(frame_num,25); | ||
150 | + cur_subject_y = augment_y + 0.01.*randn(frame_num,25); | ||
151 | + cur_subject_z = clear_subject_z + 0.01.*randn(frame_num,25); | ||
152 | + | ||
153 | + % NORMALIZATION | ||
154 | + cur_subject_x = cur_subject_x - min(cur_subject_x(:)); | ||
155 | + max_tall = max(cur_subject_x(:)) .*2; | ||
156 | + cur_subject_x = cur_subject_x ./ max_tall; | ||
157 | + | ||
158 | + cur_subject_y = cur_subject_y - min(cur_subject_y(:)); | ||
159 | + cur_subject_y = cur_subject_y ./ max_tall; | ||
160 | + | ||
161 | + cur_subject_z = cur_subject_z - min(cur_subject_z(:)); | ||
162 | + cur_subject_z = cur_subject_z ./ max_tall; | ||
163 | + | ||
164 | + | ||
165 | + %Write image | ||
166 | + motionpatch = cur_subject_x; | ||
167 | + motionpatch(:,:,2) = cur_subject_y; | ||
168 | + motionpatch(:,:,3) = cur_subject_z; | ||
169 | + | ||
170 | + new_file_name = strcat('/home/rfj/바탕화면/actionGAN/DCGAN/new_motionpatch_halfsize/',file_name(1:20),'_',num2str(LR),num2str(HE),num2str(RV),'.png'); | ||
171 | + imwrite(motionpatch,new_file_name); | ||
172 | + | ||
173 | + end | ||
174 | + end | ||
175 | + end | ||
176 | + | ||
177 | + catch | ||
178 | + name | ||
179 | + end | ||
180 | + | ||
181 | +end |
data_preprocessing/transform_all_rotated90.m
0 → 100644
1 | +clear; | ||
2 | + | ||
3 | +path_name = '/media/rfj/EEA4441FA443E923/nturgb_skeletones/'; | ||
4 | +fileID = fopen('/home/rfj/바탕화면/actionGAN/skeletone_INDEX/good_stand_2.txt','r'); | ||
5 | +formatSpec = '%s'; | ||
6 | +sizeA = [20 Inf]; | ||
7 | +perfect_list = fscanf(fileID,formatSpec,sizeA); | ||
8 | +perfect_list = perfect_list.'; | ||
9 | +fclose(fileID); | ||
10 | + | ||
11 | +L = length(perfect_list); | ||
12 | + | ||
13 | +for K = 1:L | ||
14 | + | ||
15 | + file_name = char(perfect_list(K,:)); | ||
16 | + name = strcat(path_name,file_name(1:20),'.skeleton'); | ||
17 | + [token,remainder] = strtok(file_name,'A'); | ||
18 | + class = str2num(remainder(2:4)); | ||
19 | + | ||
20 | + bodyinfo = read_skeleton_file(name); | ||
21 | + frame_num = size(bodyinfo,2); | ||
22 | + try | ||
23 | + | ||
24 | + %initialize | ||
25 | + cur_subject_x = zeros(frame_num, 25); | ||
26 | + cur_subject_y = zeros(frame_num, 25); | ||
27 | + cur_subject_z = zeros(frame_num, 25); | ||
28 | + | ||
29 | + tot_x = zeros(frame_num,25); | ||
30 | + tot_y = zeros(frame_num,25); | ||
31 | + tot_z = zeros(frame_num,25); | ||
32 | + | ||
33 | + joint_5 = zeros(1,3); | ||
34 | + joint_9 = zeros(1,3); | ||
35 | + joint_1 = zeros(1,3); | ||
36 | + joint_3 = zeros(1,3); | ||
37 | + | ||
38 | + %get total joints information | ||
39 | + for FN = 1:frame_num | ||
40 | + cur_body = bodyinfo(FN).bodies(1); | ||
41 | + joints = cur_body.joints; | ||
42 | + | ||
43 | + for JN = 1:25 | ||
44 | + tot_x(FN,JN) = joints(JN).x; | ||
45 | + tot_y(FN,JN) = joints(JN).y; | ||
46 | + tot_z(FN,JN) = joints(JN).z; | ||
47 | + end | ||
48 | + end | ||
49 | + | ||
50 | + %Orientation normalization 1 : in space | ||
51 | + %get median values | ||
52 | + M_x = median(tot_x); | ||
53 | + M_y = median(tot_y); | ||
54 | + M_z = median(tot_z); | ||
55 | + | ||
56 | + %set 3 points for make plane | ||
57 | + joint_5 = [M_x(5) M_y(5) M_z(5)]; | ||
58 | + joint_9 = [M_x(9) M_y(9) M_z(9)]; | ||
59 | + joint_1 = [M_x(1) M_y(1) M_z(1)]; | ||
60 | + joint_3 = [M_x(3) M_y(3) M_z(3)]; | ||
61 | + | ||
62 | + %find RIGID TRNASFORMATION matrix | ||
63 | + d1 = joint_1 - joint_5; | ||
64 | + d2 = joint_1 - joint_9; | ||
65 | + n1 = cross(d1,d2); % because we will parallel transform, don't need to find belly | ||
66 | + u1 = n1/norm(n1); | ||
67 | + u2 = [0 0 1]; | ||
68 | + cs1 = dot(u1,u2)/norm(u1)*norm(u2); | ||
69 | + ss1 = sqrt(1-cs1.^2); | ||
70 | + v1 = cross(u1,u2)/norm(cross(u1,u2)); | ||
71 | + | ||
72 | + R1 = [v1(1)*v1(1)*(1-cs1)+cs1 v1(1)*v1(2)*(1-cs1)-v1(3)*ss1 v1(1)*v1(3)*(1-cs1)+v1(2)*ss1]; | ||
73 | + R1(2,:) = [v1(1)*v1(2)*(1-cs1)+v1(3)*ss1 v1(2)*v1(2)*(1-cs1)+cs1 v1(2)*v1(3)*(1-cs1)-v1(1)*ss1]; | ||
74 | + R1(3,:) = [v1(1)*v1(3)*(1-cs1)-v1(2)*ss1 v1(2)*v1(3)*(1-cs1)+v1(1)*ss1 v1(3)*v1(3)*(1-cs1)+cs1]; | ||
75 | + | ||
76 | + %1-3 number tolls to parallel x axis. Rigid transformation on plane surface | ||
77 | + %Z axis coords oyler angle transform | ||
78 | + | ||
79 | + t = joint_3 - joint_1; | ||
80 | + d3 = R1(1,:) * t.'; | ||
81 | + d3(1,2) = R1(2,:) * t.'; | ||
82 | + d3(1,3) = R1(3,:) * t.'; | ||
83 | + | ||
84 | + u3 = d3(1:2)/norm(d3(1:2)); | ||
85 | + v3 = [u3(1) -u3(2)]; | ||
86 | + v3(2,:) = [u3(2) u3(1)]; | ||
87 | + u4 = [0 1].'; % decide orientation in plane | ||
88 | + | ||
89 | + csss = v3\u4; | ||
90 | + cs2 = csss(1); | ||
91 | + ss2 = csss(2); | ||
92 | + | ||
93 | + R2 = [cs2 -ss2 0]; | ||
94 | + R2(2,:) = [ss2 cs2 0]; | ||
95 | + R2(3,:) = [0 0 1]; | ||
96 | + | ||
97 | + | ||
98 | + %apply rigid transformation | ||
99 | + for FN = 1:frame_num | ||
100 | + cur_body = bodyinfo(FN).bodies(1); | ||
101 | + joints = cur_body.joints; | ||
102 | + | ||
103 | + for JN = 1:25 | ||
104 | + a = R1(1,:) * [joints(JN).x joints(JN).y joints(JN).z].'; | ||
105 | + b = R1(2,:) * [joints(JN).x joints(JN).y joints(JN).z].'; | ||
106 | + c = R1(3,:) * [joints(JN).x joints(JN).y joints(JN).z].'; | ||
107 | + | ||
108 | + cur_subject_x(FN,JN) = R2(1,:) * [a b c].'; | ||
109 | + cur_subject_y(FN,JN) = R2(2,:) * [a b c].'; | ||
110 | + cur_subject_z(FN,JN) = R2(3,:) * [a b c].'; | ||
111 | + | ||
112 | + end | ||
113 | + end | ||
114 | + | ||
115 | + %orientation normalize 2 (with plane surface) | ||
116 | + if cur_subject_y(1,4) < cur_subject_y(1,1) | ||
117 | + cur_subject_y = 0 - cur_subject_y; | ||
118 | + end | ||
119 | + | ||
120 | + if cur_subject_x(1,9) > cur_subject_x(1,5) | ||
121 | + cur_subject_x = 0 - cur_subject_x; | ||
122 | + end | ||
123 | + | ||
124 | + % for save origin subjects before data augment | ||
125 | + clear_subject_x = cur_subject_x; | ||
126 | + clear_subject_y = cur_subject_y; | ||
127 | + clear_subject_z = cur_subject_z; | ||
128 | + | ||
129 | + % Left <-> Right Change : 2option | ||
130 | + for LR = 1:2 | ||
131 | + if LR == 1 | ||
132 | + augment_x = clear_subject_x; | ||
133 | + else | ||
134 | + augment_x = 0 - clear_subject_x; | ||
135 | + end | ||
136 | + | ||
137 | + %Height change : 3option | ||
138 | + for HE = 1:3 | ||
139 | + if HE == 1 | ||
140 | + augment_y = clear_subject_y.* 1.2; | ||
141 | + elseif HE==2 | ||
142 | + augment_y = clear_subject_y.* 1.0; | ||
143 | + else | ||
144 | + augment_y = clear_subject_y.* 0.8; | ||
145 | + end | ||
146 | + | ||
147 | + %Give Gaussian Random Variable : 0.01 - 6times | ||
148 | + for RV = 1:6 | ||
149 | + %3. Gaussian Random filter 0.1 | ||
150 | + cur_subject_x = augment_x + 0.01.*randn(frame_num,25); | ||
151 | + cur_subject_y = augment_y + 0.01.*randn(frame_num,25); | ||
152 | + cur_subject_z = clear_subject_z + 0.01.*randn(frame_num,25); | ||
153 | + | ||
154 | + % NORMALIZATION | ||
155 | + cur_subject_y = cur_subject_y - min(cur_subject_y(:)); | ||
156 | + max_tall = max(cur_subject_y(:)); | ||
157 | + cur_subject_y = cur_subject_y ./ max_tall; | ||
158 | + | ||
159 | + cur_subject_x = cur_subject_x - min(cur_subject_x(:)); | ||
160 | + cur_subject_x = cur_subject_x ./ max_tall; | ||
161 | + | ||
162 | + cur_subject_z = cur_subject_z - min(cur_subject_z(:)); | ||
163 | + cur_subject_z = cur_subject_z ./ max_tall; | ||
164 | + | ||
165 | + | ||
166 | + %Write image | ||
167 | + motionpatch = cur_subject_x; | ||
168 | + motionpatch(:,:,2) = cur_subject_y; | ||
169 | + motionpatch(:,:,3) = cur_subject_z; | ||
170 | + | ||
171 | + new_file_name = strcat('/home/rfj/바탕화면/actionGAN/DCGAN/new_motionpatch_rotate90/',file_name(1:20),'_',num2str(LR),num2str(HE),num2str(RV),'.png'); | ||
172 | + imwrite(motionpatch,new_file_name); | ||
173 | + | ||
174 | + end | ||
175 | + end | ||
176 | + | ||
177 | + end | ||
178 | + | ||
179 | + catch | ||
180 | + name | ||
181 | + end | ||
182 | + | ||
183 | +end |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | 7 | ||
8 | clear; | 8 | clear; |
9 | 9 | ||
10 | -name = '/home/rfj/바탕화면/skeletones/S001C001P002R002A020.skeleton' | 10 | +name = '/home/rfj/바탕화면/actionGAN/sample_skeletones/S001C001P001R002A020.skeleton' |
11 | bodyinfo = read_skeleton_file(name); | 11 | bodyinfo = read_skeleton_file(name); |
12 | frame_num = size(bodyinfo,2); | 12 | frame_num = size(bodyinfo,2); |
13 | 13 | ||
... | @@ -37,6 +37,7 @@ for FN = 1:frame_num | ... | @@ -37,6 +37,7 @@ for FN = 1:frame_num |
37 | end | 37 | end |
38 | end | 38 | end |
39 | 39 | ||
40 | +%Orientation normalization 1 : in space | ||
40 | %get median values | 41 | %get median values |
41 | M_x = median(tot_x); | 42 | M_x = median(tot_x); |
42 | M_y = median(tot_y); | 43 | M_y = median(tot_y); |
... | @@ -109,89 +110,59 @@ end | ... | @@ -109,89 +110,59 @@ end |
109 | if cur_subject_y(1,9) > cur_subject_y(1,5) | 110 | if cur_subject_y(1,9) > cur_subject_y(1,5) |
110 | cur_subject_y = 0 - cur_subject_y; | 111 | cur_subject_y = 0 - cur_subject_y; |
111 | end | 112 | end |
112 | - | ||
113 | -%get current median | ||
114 | -CM_x=median(cur_subject_x); | ||
115 | -CM_y=median(cur_subject_y); | ||
116 | -CM_z=median(cur_subject_z); | ||
117 | - | ||
118 | -%for transform bellybutton to 0.5,0.5 (Except X) but it doesn't work | ||
119 | -belly_button = 0.5 - CM_y(2); | ||
120 | -belly_button(2) = 0.5 - CM_z(2); | ||
121 | - | ||
122 | -% normalize with x... <- HERE! WANT TO PARALLEL TRANSFORM | ||
123 | -... but if I plus belly_button for x and y axis , it dosn't work | ||
124 | -cur_subject_x = cur_subject_x - min(cur_subject_x(:)); | ||
125 | -max_tall = max(cur_subject_x(:)); | ||
126 | -cur_subject_x = cur_subject_x ./ max_tall; | ||
127 | - | ||
128 | -cur_subject_y = cur_subject_y - min(cur_subject_y(:)); | ||
129 | -cur_subject_y = cur_subject_y ./ max_tall; | ||
130 | - | ||
131 | -cur_subject_z = cur_subject_z - min(cur_subject_z(:)); | ||
132 | -cur_subject_z = cur_subject_z ./ max_tall; | ||
133 | - | ||
134 | - | ||
135 | -% 이미지 저장 | ||
136 | -motionpatch = cur_subject_x; | ||
137 | -motionpatch(:,:,2) = cur_subject_y; | ||
138 | -motionpatch(:,:,3) = cur_subject_z; | ||
139 | - | ||
140 | -new_file_name = strcat('/home/rfj/바탕화면/sample.png'); | ||
141 | -imwrite(motionpatch,new_file_name); | ||
142 | - | ||
143 | - | ||
144 | -% read image after write | ||
145 | - | ||
146 | -ori = imread('/home/rfj/바탕화면/sample.png'); | ||
147 | -ori = im2double(ori); | ||
148 | -ori = ori(:,:,:); | ||
149 | 113 | ||
150 | -dx = []; | 114 | +% for save origin subjects before data augment |
151 | -dy = []; | 115 | +clear_subject_x = cur_subject_x; |
152 | -dz = []; | 116 | +clear_subject_y = cur_subject_y; |
153 | - | 117 | +clear_subject_z = cur_subject_z; |
154 | -for f = 1:numel(ori(:,1,1)) | 118 | + |
155 | - for j = 1:25 | 119 | +% Left <-> Right Change : 2option |
156 | - dx = [dx;ori(f,j,1)]; | 120 | +for LR = 1:2 |
157 | - dy = [dy;ori(f,j,2)]; | 121 | + if LR == 1 |
158 | - dz = [dz;ori(f,j,3)]; | 122 | + augment_y = clear_subject_y; |
123 | + else | ||
124 | + augment_y = 0 - clear_subject_y; | ||
159 | end | 125 | end |
160 | -end | ||
161 | - | ||
162 | -a = [1 0 0]; % Red 척추 1,2,3,4,20 | ||
163 | -b = [0 0 1]; % Blue 오른팔 8,9,10,11,23,24 | ||
164 | -c = [0 1 0]; % Green왼팔 5,6,7,21,22 (여기서 5번이 빠짐. 넣고싶으면 나중에 24 joint가 아니라 25 joint로 추가) | ||
165 | -d = [1 1 0]; % Yellow 오른다리 16,17,18,19 | ||
166 | -e = [0 1 1]; % Skyblue 왼다리 12,13,14,15 | ||
167 | -colors = [a;a;a;a;c;c;c;c;b;b;b;b;e;e;e;e;d;d;d;d;a;c;c;b;b]; | ||
168 | - | ||
169 | -scatter3(dx,dy,dz,100,'filled'); | ||
170 | - | ||
171 | - | ||
172 | -connecting_joints= ... | ||
173 | - [2 1 21 3 21 5 6 7 21 9 10 11 1 13 14 15 1 17 18 19 2 8 8 12 12]; | ||
174 | - | ||
175 | -for jj=1:25:numel(dx)% 1부터 8개씩 numel = 열갯수..? | ||
176 | - current = []; | ||
177 | - current(:,1) = dy(jj:jj+24) ; | ||
178 | - current(:,2) = dz(jj:jj+24) ; | ||
179 | - current(:,3) = dx(jj:jj+24) ; | ||
180 | - | ||
181 | - scatter3(current(:,1),current(:,2),current(:,3),100,colors(:,:),'filled'); | ||
182 | 126 | ||
183 | - for j =1:25 | 127 | + %Height change : 3option |
184 | - k=connecting_joints(j); | 128 | + for HE = 1:3 |
185 | - line([current(j,1) current(k,1)], [current(j,2) current(k,2)] , [current(j,3) current(k,3)]) | 129 | + if HE == 1 |
130 | + augment_x = clear_subject_x.* 1.2; | ||
131 | + elseif HE==2 | ||
132 | + augment_x = clear_subject_x.* 1.0; | ||
133 | + else | ||
134 | + augment_x = clear_subject_x.* 0.8; | ||
135 | + end | ||
136 | + | ||
137 | + %Give Gaussian Random Variable : 0.01 - 6times | ||
138 | + for RV = 1:6 | ||
139 | + %3. Gaussian Random filter 0.1 | ||
140 | + cur_subject_x = augment_x + 0.01.*randn(frame_num,25); | ||
141 | + cur_subject_y = augment_y + 0.01.*randn(frame_num,25); | ||
142 | + cur_subject_z = clear_subject_z + 0.01.*randn(frame_num,25); | ||
143 | + | ||
144 | + % NORMALIZATION | ||
145 | + cur_subject_x = cur_subject_x - min(cur_subject_x(:)); | ||
146 | + max_tall = max(cur_subject_x(:)); | ||
147 | + cur_subject_x = cur_subject_x ./ max_tall; | ||
148 | + | ||
149 | + cur_subject_y = cur_subject_y - min(cur_subject_y(:)); | ||
150 | + cur_subject_y = cur_subject_y ./ max_tall; | ||
151 | + | ||
152 | + cur_subject_z = cur_subject_z - min(cur_subject_z(:)); | ||
153 | + cur_subject_z = cur_subject_z ./ max_tall; | ||
154 | + | ||
155 | + | ||
156 | + %Write image | ||
157 | + motionpatch = cur_subject_x; | ||
158 | + motionpatch(:,:,2) = cur_subject_y; | ||
159 | + motionpatch(:,:,3) = cur_subject_z; | ||
160 | + | ||
161 | + new_file_name = strcat('/home/rfj/바탕화면/actionGAN/DCGAN/new_motionpatch/sample_',num2str(LR),num2str(HE),num2str(RV),'.png'); | ||
162 | + imwrite(motionpatch,new_file_name); | ||
163 | + | ||
164 | + end | ||
186 | end | 165 | end |
187 | 166 | ||
188 | - set(gca,'Xdir','reverse','Ydir','reverse') | ||
189 | - xlim([0 1]); | ||
190 | - xlabel('x') | ||
191 | - ylim([0 1]); | ||
192 | - ylabel('y') | ||
193 | - zlim([0 1]); | ||
194 | - zlabel('z') | ||
195 | - drawnow | ||
196 | - pause(0.01) | ||
197 | -end | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
167 | +end | ||
168 | + | ... | ... |
No preview for this file type
No preview for this file type
No preview for this file type
datas/4_motionpatch_augmented.tar.gz
0 → 100644
This file is too large to display.
datas/5_motionpatch_halfsize.tar
0 → 100644
This file is too large to display.
datas/5_motionpatch_rotate90.tar
0 → 100644
This file is too large to display.
datas/smallone_augmentated.tar
0 → 100644
This file is too large to display.
... | @@ -4,7 +4,6 @@ S001C001P005R002A020 | ... | @@ -4,7 +4,6 @@ S001C001P005R002A020 |
4 | S001C001P007R001A020 | 4 | S001C001P007R001A020 |
5 | S001C001P008R002A020 | 5 | S001C001P008R002A020 |
6 | S001C002P002R002A020 | 6 | S001C002P002R002A020 |
7 | -S001C001P001R001A020 | ||
8 | S001C002P003R002A020 | 7 | S001C002P003R002A020 |
9 | S001C002P005R001A020 | 8 | S001C002P005R001A020 |
10 | S001C002P005R002A020 | 9 | S001C002P005R002A020 | ... | ... |
-
Please register or login to post a comment