From 820db5ec6806ab026051c71aba577f4523249af6 Mon Sep 17 00:00:00 2001
From: Vaek <timothe.boulet@student-cs.fr>
Date: Wed, 24 Mar 2021 19:44:20 +0100
Subject: [PATCH] add a loading file for a the DS fer2013

---
 .gitignore                                    |   1 +
 .../buildEmotionModel-checkpoint.ipynb        |  32 +++++++++
 __pycache__/faceAnalysis.cpython-38.pyc       | Bin 263 -> 263 bytes
 __pycache__/imageProcess.cpython-38.pyc       | Bin 980 -> 1293 bytes
 loadFer2013ds.py                              |  65 ++++++++++++++++++
 videoCapture.py                               |   2 +-
 6 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 .gitignore
 create mode 100644 .ipynb_checkpoints/buildEmotionModel-checkpoint.ipynb
 create mode 100644 loadFer2013ds.py

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6320cd2
--- /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 0000000..c0ff753
--- /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
GIT binary patch
delta 19
acmZo?YG>jO<>lpKU|?WSpA$Th`wsvjSOi4?

delta 19
acmZo?YG>jO<>lpKU|?XF!yGt~`wsvj5d<Fq

diff --git a/__pycache__/imageProcess.cpython-38.pyc b/__pycache__/imageProcess.cpython-38.pyc
index cc5b011b7be12ef7bdd57b56ca44d49ddc520e5d..0c4e6392fe0c5f003a515ceef07af3a8448a9d21 100644
GIT binary patch
delta 468
zcmcb@-pj=o%FD~ez`(%3Iz2eSkYggB45P|KZ5dvc6xJ4oD3%n)U<OULjXw5_jK3!L
zFj_J`pL~o_n~`<$C&pzQw^%cC6Vp>~O<uqx#dnJ(y(qEr7He8!a%%Cd$tRe+7-c65
zGZ!n!GcYhDGlHyuVos243=9m;3=9m#Squ~N#OqmV7)ltjSQj$YGSx6HV5?zDVM<|M
z$Xv@@!<^2L&0LgL!<@n*$q>U*%Tmi)%T~)?!%)Lo!&<{G&d|zK!&1Xi!v<odF-bDi
za@24HGo&yCGib8<6)`a|FcdL^2o?|la)u^*5eJA3az+uz>qXr4AU+R>-~|zU3=9mK
zoJGPQwg`w21rcH(LIOlcf(R)PAq^tLL4+)vkYiwAxW!eRnv<Gb;+B}4ss{2V$Vdhj
zA!a@%K4uO^0Y(|dA_b5wtYEizMe%@w%`q=Ar?NP+xJUqG7%1Gpii!|sgIQn;IBatB
XQ%ZAE?La;(W@BJr;9%rn;!p$tClpql

delta 193
zcmeC>y28#E%FD~ez`(#D!Wx)xighBN45Q3MZ5dX^U<OT=jUo1oj8&7TFj_LEPd>+}
z&B#3Y7vnO6DAvr}#PrlCp0vc|)cEAY;^f4X)F|%MN(6@`y(qCViWQ`wIBN0*CND;@
z$<oZlei94}44N!OYzzzx5bch6i8+<UnZ-qX3=9lKAn7785DP(wGcYjR;;_lhPbtkw
TwPRvnU?^r`U|`^2<X{2-Jp(Tv

diff --git a/loadFer2013ds.py b/loadFer2013ds.py
new file mode 100644
index 0000000..e7aea37
--- /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 7f1882e..4d71926 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
-- 
GitLab