starbucksdolcelatte

plot the seasons standards on Lab space

No preview for this file type
No preview for this file type
......@@ -33,13 +33,13 @@ class DetectFace:
self. left_eye = []
self.nose = []
self.jaw = []
self.cheek = [[],[]] # index 0 : left, 1 : right
self.cheek_img = [[],[]] # index 0 : left, 1 : right
# detect the face parts and set the variables
self.detect_face_part()
self.cheek = self.detect_cheek()
self.detect_face_part() # mouth, right_eyebrow, ..., jaw : np.array
self.cheek_img = self.detect_cheek() # image
# return type : np.array
def detect_face_part(self):
# loop over the face detections
# i : name
......@@ -64,8 +64,8 @@ class DetectFace:
# specific face part
for (x, y) in shape[i:j]:
cv2.circle(clone, (x, y), 1, (0, 0, 255), -1)
#print(name)
#print(shape[i:j])
print(name)
print(shape[i:j])
face_parts[idx] = shape[i:j]
idx += 1
......@@ -98,6 +98,7 @@ class DetectFace:
# parameter example : self.right_eye
# return type : image
def extract_face_part(self, part):
pts = part
......@@ -124,17 +125,17 @@ class DetectFace:
return extracted_part
# return type = image
def detect_cheek(self):
cheek = [[],[]]
#rect is the face detected
# rect is the face detected
shape = self.predictor(self.gray, self.rects[0])
shape = face_utils.shape_to_np(shape)
left = self.img[shape[29][1]:shape[33][1],
shape[4][0]:shape[48][0]] #left cheek
right = self.img[shape[29][1]:shape[33][1],
shape[54][0]:shape[12][0]] #right cheek
# Cheeks are detected by relative position to the face landmarks
left = self.img[shape[29][1]:shape[33][1], shape[4][0]:shape[48][0]] #left cheek
right = self.img[shape[29][1]:shape[33][1], shape[54][0]:shape[12][0]] #right cheek
cheek[0] = left
cheek[1] = right
......
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def plotStd(arr):
season_label = ['spring', 'summer', 'fall', 'winter']
season_color = ['green', 'blue', 'red', 'gray']
fig = plt.figure()
ax = Axes3D(fig)
for seasons in arr:
i = 0
for s in seasons:
ax.scatter(s[0], s[1], s[2], label = season_label[i], color = season_color[i])
i += 1
ax.set_xlabel('L value')
ax.set_ylabel('a value')
ax.set_zlabel('b value')
# plt.xlabel('L value')
# plt.ylabel('a value')
# plt.zlabel('b value')
plt.show()
#[봄여름가을겨울]*5개의 기준
skin_lab = [[[87.39, -2.2, 16.21],
[84.48, 0.75, 14.23],
[80.58, -0.1, 25.46],
[91.47, -0.7, 9.96]],
[[84.57, -0.21, 28.38],
[84.81, 6.59, 19.93],
[73.88, 2.55, 20.96],
[89.53, 0.74, 12.14]],
[[79.84, 11.02, 33.65],
[83.7, 5.53, 17.71],
[75.69, 4.55, 27.02],
[81.76, 14.12, 29.2]],
[[81.8, 6, 34.05],
[82.88, 10.99, 26.24],
[72.75, 3.2, 38.52],
[73.82, 8.42, 27.3]],
[[83.4, 3.6575, 28.0725],
[83.9675, 5.965, 19.5275],
[75.725, 2.5575, 27.99],
[84.145, 5.6375, 19.65]]]
plotStd(skin_lab)
......@@ -12,7 +12,8 @@ skin_lsg = [[222.5, 201.4, 188.9], [227.2, 209.5, 203.3]] # left cheek
pupil_lsg = [[159.8, 115.8, 61.7], [186.5, 156.1, 129.0],
[126.0, 77.5, 42.8], [88.1, 41.1, 20.9]] # right eye
skin_lab = [[87.39, -2.18, 16.21],[84.48, 0.75, 14.23],[80.58, -0.07, 25.46],[91.47, -0.73, 9.96]]
skin_lsg_lab = [[73.73, 19.20, 7.79],[70.94, 19.32, 8.28]] #left cheek
'''
for i in range(4):
print(f'skin distance from {label[i]}')
......@@ -25,6 +26,8 @@ for i in range(4):
print('3 : ', distance.euclidean(pupil[i], pupil_lsg[2]))
print('4 : ', distance.euclidean(pupil[i], pupil_lsg[3]))
'''
'''
skin_dist = [[0,0,0,0], [0,0,0,0]]
pupil_dist = [[0,0,0,0] for _ in range(4)]
......@@ -56,6 +59,7 @@ print(sorted_ppdist[0])
# 거리가 짧은 계절 순으로 출력
# skin
for i in range(2):
print('skin - round ', i)
for season in range(4):
......@@ -66,3 +70,36 @@ for i in range(4):
print('pupil - round ', i)
for season in range(4):
print(f'{season+1}위:', label[pupil_dist[i].index(sorted_ppdist[i][season])])
'''
## Lab 색상
skin_dist_lab = [[0,0,0,0], [0,0,0,0]]
pupil_dist_lab = [[0,0,0,0] for _ in range(4)]
# i = seasons
for i in range(4):
# skin
for j in range(2):
# j = 0 피부에서 가장 많은 색상과 각 계절과의 거리
# j = 1 피부에서 두번째로 많은 색상과 각 계절과의 거리
skin_dist_lab[j][i] = distance.euclidean(skin_lab[i], skin_lsg_lab[j])
# 거리가 짧은 순으로 정렬
# skin
sorted_skdist_lab = copy.deepcopy(skin_dist_lab)
for i in range(2):
sorted_skdist_lab[i].sort()
print(skin_dist_lab[0])
print(sorted_skdist_lab[0])
# 거리가 짧은 계절 순으로 출력
# skin
for i in range(2):
print('skin - round ', i)
for season in range(4):
print(f'{season+1}위:', label[skin_dist_lab[i].index(sorted_skdist_lab[i][season])])
print('\n')
......