From 6482e1b20ec1daf8da5db2875a15ba3981680c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eefik=20Serangil?= Date: Wed, 1 Apr 2020 15:49:29 +0300 Subject: [PATCH] mood box shape --- deepface/commons/functions.py | 2 +- deepface/commons/realtime.py | 40 ++++++++++++++++++++++------------- setup.py | 2 +- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/deepface/commons/functions.py b/deepface/commons/functions.py index bee484e..a4900f5 100644 --- a/deepface/commons/functions.py +++ b/deepface/commons/functions.py @@ -149,7 +149,7 @@ def detectFace(img, target_size=(224, 224), grayscale = False): if exact_image != True: #image path passed as input img = cv2.imread(img) - + img_raw = img.copy() #-------------------------------- diff --git a/deepface/commons/realtime.py b/deepface/commons/realtime.py index 480c7ed..c4e9fcc 100644 --- a/deepface/commons/realtime.py +++ b/deepface/commons/realtime.py @@ -229,8 +229,9 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True): if x+w+pivot_img_size < resolution_x: #right cv2.rectangle(freeze_img - , (x+w,y+20) - , (x+w+pivot_img_size, y+180) + #, (x+w,y+20) + , (x+w,y) + , (x+w+pivot_img_size, y+h) , (64,64,64),cv2.FILLED) cv2.addWeighted(overlay, opacity, freeze_img, 1 - opacity, 0, freeze_img) @@ -238,8 +239,9 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True): elif x-pivot_img_size > 0: #left cv2.rectangle(freeze_img - , (x-pivot_img_size,y+20) - , (x, y+180) + #, (x-pivot_img_size,y+20) + , (x-pivot_img_size,y) + , (x, y+h) , (64,64,64),cv2.FILLED) cv2.addWeighted(overlay, opacity, freeze_img, 1 - opacity, 0, freeze_img) @@ -252,22 +254,30 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True): bar_x = int(bar_x * emotion_score) if x+w+pivot_img_size < resolution_x: - - cv2.putText(freeze_img, emotion_label, (x+w, y + 20 + (index+1) * 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1) - cv2.rectangle(freeze_img - , (x+w+70, y + 13 + (index+1) * 20) - , (x+w+70+bar_x, y + 13 + (index+1) * 20 + 5) - , (255,255,255), cv2.FILLED) + text_location_y = y + 20 + (index+1) * 20 + text_location_x = x+w + + if text_location_y < y + h: + cv2.putText(freeze_img, emotion_label, (text_location_x, text_location_y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1) + + cv2.rectangle(freeze_img + , (x+w+70, y + 13 + (index+1) * 20) + , (x+w+70+bar_x, y + 13 + (index+1) * 20 + 5) + , (255,255,255), cv2.FILLED) elif x-pivot_img_size > 0: - cv2.putText(freeze_img, emotion_label, (x-pivot_img_size, y + 20 + (index+1) * 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1) + text_location_y = y + 20 + (index+1) * 20 + text_location_x = x-pivot_img_size - cv2.rectangle(freeze_img - , (x-pivot_img_size+70, y + 13 + (index+1) * 20) - , (x-pivot_img_size+70+bar_x, y + 13 + (index+1) * 20 + 5) - , (255,255,255), cv2.FILLED) + if text_location_y <= y+h: + cv2.putText(freeze_img, emotion_label, (text_location_x, text_location_y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1) + + cv2.rectangle(freeze_img + , (x-pivot_img_size+70, y + 13 + (index+1) * 20) + , (x-pivot_img_size+70+bar_x, y + 13 + (index+1) * 20 + 5) + , (255,255,255), cv2.FILLED) #------------------------------- diff --git a/setup.py b/setup.py index 8bf9c29..c2eed4d 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setuptools.setup( name="deepface", - version="0.0.11", + version="0.0.12", author="Sefik Ilkin Serengil", author_email="serengil@gmail.com", description="Deep Face Analysis Framework for Face Recognition and Demography",