Skip to content
Snippets Groups Projects
Commit f30ababb authored by Timothé Boulet's avatar Timothé Boulet :alien:
Browse files

maj game.py

parent d298877c
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -7,7 +7,6 @@ from config import emotions ...@@ -7,7 +7,6 @@ from config import emotions
cap = cv2.VideoCapture(0) #0 means we capture the first camera, your webcam probably cap = cv2.VideoCapture(0) #0 means we capture the first camera, your webcam probably
score = 0 score = 0
t = 0
N = 15 N = 15
def smileyRandom(emotionToDodge): def smileyRandom(emotionToDodge):
...@@ -25,8 +24,8 @@ while cap.isOpened(): #or while 1. cap.isOpened() is false if there is a probl ...@@ -25,8 +24,8 @@ while cap.isOpened(): #or while 1. cap.isOpened() is false if there is a probl
if not ret: break if not ret: break
emotionsList = ip.imageProcess(frame, returnEmotion=True) emotionsList = ip.imageProcess(frame, returnEmotion=True)
if len(emotionsList)==1:
if emotionsList[0] == emotion: #If emotion recognized, increase score, reset smiley to mimick and write "GG!" if emotion in emotionsList: #If emotion recognized, increase score, reset smiley to mimick and write "GG!"
score += 1 score += 1
cv2.putText(smiley, "Emotion reconnue !", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,255,0), 2) cv2.putText(smiley, "Emotion reconnue !", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,255,0), 2)
cv2.imshow("Smiley", smiley) cv2.imshow("Smiley", smiley)
...@@ -34,13 +33,13 @@ while cap.isOpened(): #or while 1. cap.isOpened() is false if there is a probl ...@@ -34,13 +33,13 @@ while cap.isOpened(): #or while 1. cap.isOpened() is false if there is a probl
cv2.imshow("Caméra", frame) #Show you making emotional faces cv2.imshow("Caméra", frame) #Show you making emotional faces
cv2.putText(smiley, "Score: "+str(score), (20,20), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255), 2) cv2.putText(smiley, "Score: "+str(score), (40,40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255), 2)
cv2.imshow("Smiley", smiley) #Show the smiley to mimic cv2.imshow("Smiley", smiley) #Show the smiley to mimic
if cv2.waitKey(1) & 0xFF == ord('q'): #If you press Q, stop the while and so the capture if cv2.waitKey(1) & 0xFF == ord('q'): #If you press Q, stop the while and so the capture
break break
if cv2.waitKey(1) & 0xFF == ord('p'): #If you press P, pass the smiley but lower your score elif cv2.waitKey(1) & 0xFF == ord('p'): #If you press P, pass the smiley but lower your score
score -= 1 score -= 1
smiley, emotion = smileyRandom(emotion) smiley, emotion = smileyRandom(emotion)
......
This diff is collapsed.
File added
File added
File added
import numpy as np
A = np.array([ [[1,2],[3,4]] , [[5,6],[7,8]] , [[1,2],[3,4]]]) import cv2
B = np.array([ [[1,2],[3,4]] , [[5,6],[7,8]] ]) while 1:
A = A.tolist() if cv2.waitKey(0) & 0xFF== ord('q'): #If you press Q, stop the while and so the capture
B = B.tolist() break
C = np.stack(A+B, axis = 0)
print(C.shape) if cv2.waitKey(1) & 0xFF == ord('p'): #If you press P, pass the smiley but lower your score
\ No newline at end of file score -= 1
smiley, emotion = smileyRandom(emotion)
print(1)
cv2.waitKey(2)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment