starbucksdolcelatte

Blue background

Showing 77 changed files with 84 additions and 29 deletions
No preview for this file type
......@@ -28,9 +28,9 @@ class DetectFace:
# init face parts
self.mouth = []
self.right_eyebrow = []
self. left_eyebrow = []
self.left_eyebrow = []
self.right_eye = []
self. left_eye = []
self.left_eye = []
self.nose = []
self.jaw = []
self.cheek_img = [[],[]] # index 0 : left, 1 : right
......@@ -107,22 +107,48 @@ class DetectFace:
cv2.fillConvexPoly(mask, pts, 1)
mask = mask.astype(np.bool)
print(mask)
# Mask For background
inversed_mask = np.logical_not(mask)
print(inversed_mask)
# Create a blank black image
blue = np.zeros_like(self.img)
# Fill image with blue color(set each pixel to blue)
blue[:] = [255, 0, 0]
# extract background by applying inversed_mask
print(inversed_mask.shape)
print(blue.shape)
print(type(self.img))
print(type(blue))
print(mask.shape)
print(self.img.shape)
# extract right eye by applying polygon mask
out2 = np.zeros_like(self.img)
out2[inversed_mask] = blue[inversed_mask]
cv2.imshow("out2", out2)
cv2.waitKey(0)
# extract right eye by applying polygon mask
out = np.zeros_like(self.img)
out[mask] = self.img[mask]
'''
cv2.imshow("Image2", out)
#out = out[mask] + blue
cv2.imshow("out", out)
cv2.waitKey(0)
'''
# crop the image
(x, y, w, h) = cv2.boundingRect(pts)
extracted_part = out[y:y + h, x:x + w]
'''
cv2.imshow("Image2", extracted_part)
crop1 = out[y:y + h, x:x + w]
crop2 = out2[y:y + h, x:x + w]
crop = cv2.add(crop1,crop2)
cv2.imshow("Image2", crop)
cv2.waitKey(0)
'''
return extracted_part
return crop
# return type = image
......
......@@ -3,7 +3,7 @@ from detect_face import DetectFace
from dominant_colors import DominantColors
# Set paths
image = "res/lees.jpg"
image = "res/fall_0_0.png"
predictor = "shape_predictor_68_face_landmarks.dat"
# Create an DetectFace instance
......@@ -11,32 +11,30 @@ df = DetectFace(predictor, image)
# Try: Extract mouth part
mouth = df.extract_face_part(df.mouth)
cv2.imshow("Mouth", mouth)
cv2.waitKey(0)
# Try: Extract right eye part
r_eye = df.extract_face_part(df.right_eye)
cv2.imshow("Right eye", r_eye)
cv2.waitKey(0)
# Try: Extract left eye part
l_eye = df.extract_face_part(df.left_eye)
cv2.imshow("Left eye", l_eye)
cv2.waitKey(0)
# Try : Extract cheek part
cv2.imshow("Left cheek", df.cheek_img[0])
cv2.waitKey(0)
cv2.imshow("Right cheek", df.cheek_img[1])
cv2.waitKey(0)
l_cheek = df.cheek_img[0]
r_cheek = df.cheek_img[1]
# Create an DominantColors instance on left cheek image
clusters = 5
dc = DominantColors(df.cheek_img[0], clusters)
colors = dc.dominantColors()
print(colors)
dc.plotHistogram()
lc_dc = DominantColors(l_cheek, clusters)
lc_colors = lc_dc.dominantColors()
print(lc_colors)
lc_dc.plotHistogram()
# Create an DominantColors instance on left cheek image
rc_dc = DominantColors(r_cheek, clusters)
rc_colors = rc_dc.dominantColors()
print(rc_colors)
rc_dc.plotHistogram()
# Try : Dominant color on right_eye
clusters = 6
......
0 공실이
1 리즈리사
2 선아
3 세진
4 윤터터
5 하늘
여름
0 도형
1 연우
2 예스리안
3 쿠키
4 한별
5 햄튜브
가을
0 제나
1 경선
2 조효진
3 지환
겨울
0 김습습
1 도나
2 아붐
3 원딘
from scipy.spatial import distance
import copy
# RGB based standard
from get_std_from_xls import ListFromExcel
converter = ListFromExcel('res/tone_color_standard.xlsx')
# STANDARD(RGB based)
# list[0] = spring, [1] = summer, [2] = fall, [3] = winter
label = ['spring', 'summer', 'fall', 'winter']
skin = [[197, 159, 140], [200, 164, 150], [195, 156, 138], [204, 168, 156]]
pupil = [[157, 92, 18], [145, 112, 28], [134, 96, 3], [136, 101, 10]]
hair = [[152, 103, 47], [95, 82, 81], [121, 87, 66], [85, 64, 67]]
skin_rgb = converter.get_rgb(converter.skin)
pupil_rgb = converter.get_rgb(converter.pupil)
hair_rgb = converter.get_rgb(converter.hair)
# 이성경(res/lees.jpg) dominant colors by order of histogram
skin_lsg = [[222.5, 201.4, 188.9], [227.2, 209.5, 203.3]] # left cheek
......