starbucksdolcelatte

edit

Showing 118 changed files with 57 additions and 23 deletions
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
This diff is collapsed. Click to expand it.
......@@ -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
......@@ -82,8 +82,8 @@ class DetectFace:
'''
# visualize all facial landmarks with a transparent overlay
output = face_utils.visualize_facial_landmarks(self.img, shape)
cv2.imshow("Image", output)
cv2.waitKey(0)
#cv2.imshow("Image", output)
#cv2.waitKey(0)
# set the variables
# Caution: this coordinates fits on the RESIZED image.
......@@ -107,11 +107,11 @@ class DetectFace:
cv2.fillConvexPoly(mask, pts, 1)
mask = mask.astype(np.bool)
print(mask)
#print(mask)
# Mask For background
inversed_mask = np.logical_not(mask)
print(inversed_mask)
#print(inversed_mask)
# Create a blank black image
......@@ -119,7 +119,7 @@ class DetectFace:
# Fill image with blue color(set each pixel to blue)
blue[:] = [255, 0, 0]
# extract background by applying inversed_mask
# extract right eye by applying polygon mask
out2 = np.zeros_like(self.img)
out2[inversed_mask] = blue[inversed_mask]
......@@ -160,4 +160,9 @@ class DetectFace:
cheek[0] = left
cheek[1] = right
# show the particular face part
#cv2.imshow("left", left)
#cv2.imshow("right", right)
#cv2.waitKey(0)
return cheek
......
......@@ -3,6 +3,8 @@ import numpy as np
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from skimage import io
class DominantColors:
......@@ -88,14 +90,19 @@ class DominantColors:
g = colors[i][1]
b = colors[i][2]
print(r,g,b)
#print(r,g,b)
#using cv2.rectangle to plot colors
cv2.rectangle(chart, (int(start), 0), (int(end), 50), (r,g,b), -1)
start = end
#display chart
plt.figure()
plt.axis("off")
plt.imshow(chart)
plt.show()
print(" ")
#plt.figure()
#plt.axis("off")
#plt.imshow(chart)
#plt.show()
for i in range(self.CLUSTERS):
colors[i][0] = int(colors[i][0])
colors[i][1] = int(colors[i][1])
colors[i][2] = int(colors[i][2])
return colors
......
......@@ -25,11 +25,8 @@ class GetJson:
i = 0
j = 0
for season in json_data:
print(season)
for std in json_data[season]:
print(std)
for body_part in json_data[season][std]:
print(body_part)
result_list[i][j].append(json_data[season][std][body_part])
j += 1
i += 1
......
......@@ -16,28 +16,47 @@ for color in lsk_rgb:
lab = convert_color(rgb, LabColor, through_rgb_type=sRGBColor)
lsk_lab.append([lab.lab_l, lab.lab_a, lab.lab_b])
# 봄웜1(res/spring_1_0.png) dominant colors by order of histogram
# skin, hair, eye 순서
sw1_rgb = [[201.58, 158.42, 142.44], [47.38, 37.76, 35.96], [44.92, 39.05, 41.00]]
sw1_lab = []
for color in sw1_rgb:
rgb = sRGBColor(color[0], color[1], color[2], is_upscaled=True)
lab = convert_color(rgb, LabColor, through_rgb_type=sRGBColor)
sw1_lab.append([lab.lab_l, lab.lab_a, lab.lab_b])
# 채연(res/chaeyeon.jpg) dominant colors by order of histogram
# skin, hair, eye 순서
cy_rgb = [[239.74, 211.85, 196.76], [16.02, 23.75, 39.83], [51.38, 35.24, 40.31]]
cy_lab = []
for color in cy_rgb:
rgb = sRGBColor(color[0], color[1], color[2], is_upscaled=True)
lab = convert_color(rgb, LabColor, through_rgb_type=sRGBColor)
cy_lab.append([lab.lab_l, lab.lab_a, lab.lab_b])
getJson = GetJson()
C = getJson.get_standard('res/standard.json')
print(C)
tone_analysis = ToneAnalysis()
print("******************")
a = [30, 20, 10] # 가중치
a = [400, 300, 10] # 가중치
spring = 0
summer = 1
fall = 2
winter = 3
result_prob = []
for season in range(4):
result_prob.append(format(tone_analysis.probability(lsk_lab, season, C, a),".2f"))
print("이성경")
result_prob.append(format(tone_analysis.probability(cy_rgb, season, C, a),".2f"))
print("결과")
print("봄 : ", result_prob[spring], "%")
print("여름 : ", result_prob[summer], "%")
print("가을 : ", result_prob[fall], "%")
print("겨울 : ", result_prob[winter], "%")
print("******************")
if(tone_analysis.is_warm(lsk_lab)):
if(tone_analysis.is_warm(cy_rgb)):
if(result_prob[spring] >= result_prob[fall]):
print("봄 웜톤")
else:
......@@ -50,7 +69,7 @@ else:
'''
# Set paths
image = "res/lees.jpg"
image = "res/chaeyeon.jpg"
predictor = "shape_predictor_68_face_landmarks.dat"
# Create an DetectFace instance
......@@ -97,7 +116,7 @@ dc_re.plotHistogram()
# hair
hair_img = "res/lees_hair.jpg"
hair_img = "res/chaeyeon_hair.jpg"
img = cv2.imread(hair_img)
resized_img = imutils.resize(img, width = 100)
clusters = 6
......
This diff is collapsed. Click to expand it.
This file is too large to display.
This diff is collapsed. Click to expand it.