-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaugment_shirt.py
47 lines (35 loc) · 1.2 KB
/
augment_shirt.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import cv2
import pose_model_class
import resize_image
def augment(person_image , pose , t_shirt):
# Scale image according to pose
t_shirt = resize_image.scaleImg(t_shirt, pose)
# print(t_shirt.shape)
start_y = pose.shoulder[0][1] - 30
start_x = pose.shoulder[0][0] - 40
# result_image = person_image.copy()
shape = t_shirt.shape
# print(shape)
# return person_image
h = shape[0]
w = shape[1]
input_shape = person_image.shape
input_height = input_shape[0]
input_width = input_shape[1]
if(h <= input_height and w <= input_width):
for i in range(0, h):
for j in range(0, w):
r,g,b,a = t_shirt[i][j]
if(a != 0):
x = (i + start_y)
y = (j + start_x)
if (x >= input_height):
x = input_height - 1
if(y > input_width):
y = input_width - 1
person_image[x][y][0] = r
person_image[x][y][1] = g
person_image[x][y][2] = b
return person_image
else :
return person_image