diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6320cd248dd8aeaab759d5871f8781b5c0505172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +data \ No newline at end of file diff --git a/.ipynb_checkpoints/buildEmotionModel-checkpoint.ipynb b/.ipynb_checkpoints/buildEmotionModel-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..c0ff75317f4305ac84b063517b0cfc1b14345978 --- /dev/null +++ b/.ipynb_checkpoints/buildEmotionModel-checkpoint.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/__pycache__/faceAnalysis.cpython-38.pyc b/__pycache__/faceAnalysis.cpython-38.pyc index d14458dbb8cdd0914e8ef56715e13b2c9c5f2ed7..be9d98db7d3ca728b47a04dfbe0e50c2cc4334fd 100644 Binary files a/__pycache__/faceAnalysis.cpython-38.pyc and b/__pycache__/faceAnalysis.cpython-38.pyc differ diff --git a/__pycache__/imageProcess.cpython-38.pyc b/__pycache__/imageProcess.cpython-38.pyc index cc5b011b7be12ef7bdd57b56ca44d49ddc520e5d..0c4e6392fe0c5f003a515ceef07af3a8448a9d21 100644 Binary files a/__pycache__/imageProcess.cpython-38.pyc and b/__pycache__/imageProcess.cpython-38.pyc differ diff --git a/loadFer2013ds.py b/loadFer2013ds.py new file mode 100644 index 0000000000000000000000000000000000000000..e7aea3716f1cb76b52608b1c0546fb3d84d5a1a8 --- /dev/null +++ b/loadFer2013ds.py @@ -0,0 +1,65 @@ +#This file load the dataset fer2013 as arrays. +import csv +import numpy as np +import cv2 +import matplotlib.pyplot as plt + +maxNbrImages = 484845 +emotions = ["Angry", "Disgust", "Fear", "Happy", "Sad", "Suprise", "Neutral"] + +def traitement(a,b,c): #For testing + arr = strToArray(b) + print(a) + plt.imshow(arr) + plt.show() + pass + +def strToArray(string): #Fer2013 provides images as string so it needs to be transformed + A = [] + lenght = len(string) + i=0 + nbr = "" + + while i<lenght: + car = string[i] + + if car != " ": + nbr += car + else: + A.append(int(nbr)) + nbr = "" + i+=1 + A.append(int(nbr)) + + A = np.array(A) + A = np.reshape(A, (48, 48)) + + return A + + + +#LOAD DATA AS ARRAY +X = [] +Y = [] + +filename = "data/fer2013.csv" + +with open(filename,'r',encoding='utf-8') as file: + + csv_reader = csv.reader(file, delimiter=",") + next(csv_reader) #Passe la ligne de titre + + i=0 + for row in csv_reader: + + i+=1 + if i>maxNbrImages: break + + emotionNbr, stringImage, typeImage = row + traitement(emotionNbr, stringImage, typeImage) + + X.append(strToArray(stringImage)) + Y.append(emotionNbr) + +X = np.array(X) +Y = np.array(Y) \ No newline at end of file diff --git a/videoCapture.py b/videoCapture.py index 7f1882ec0ada39d3ef6c9b02688d96b0274e38a9..4d719260ae439a022d69c025c4923578992f79c4 100644 --- a/videoCapture.py +++ b/videoCapture.py @@ -2,7 +2,7 @@ import cv2 import imageProcess as ip -cap = cv2.VideoCapture(0) #0 means we capture the first camera, your webcam probably +cap = cv2.VideoCapture(-1) #0 means we capture the first camera, your webcam probably while cap.isOpened(): ret, frame = cap.read() #Read next video frame, stop if frame not well read