It's trainin' time.
This commit is contained in:
parent
12d745d1b0
commit
2db47abee0
@ -8,11 +8,15 @@ namespace JeuHoy_WPF_Natif.Model {
|
|||||||
public GestionFichiersSorties(){}
|
public GestionFichiersSorties(){}
|
||||||
|
|
||||||
public List<Squelette> ChargerCoordonnees(string fichier) {
|
public List<Squelette> ChargerCoordonnees(string fichier) {
|
||||||
StreamReader lecteur = new StreamReader(fichier);
|
|
||||||
List<Squelette> lstSql = new List<Squelette>();
|
List<Squelette> lstSql = new List<Squelette>();
|
||||||
string sLigne = "";
|
string sLigne = "";
|
||||||
string[] sTabElements = null;
|
string[] sTabElements = null;
|
||||||
|
|
||||||
|
if (!File.Exists(fichier))
|
||||||
|
return lstSql;
|
||||||
|
|
||||||
|
StreamReader lecteur = new StreamReader(fichier);
|
||||||
|
|
||||||
if (!lecteur.EndOfStream) {
|
if (!lecteur.EndOfStream) {
|
||||||
sLigne = lecteur.ReadLine();
|
sLigne = lecteur.ReadLine();
|
||||||
int nbElements = Convert.ToInt32(sLigne);
|
int nbElements = Convert.ToInt32(sLigne);
|
||||||
|
@ -4,19 +4,25 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JeuHoy_WPF_Natif.Model;
|
||||||
|
|
||||||
namespace JeuHoy_WPF_Natif.Model {
|
namespace JeuHoy_WPF_Natif.Model {
|
||||||
public class GestionPerceptrons {
|
public class GestionPerceptrons {
|
||||||
private Dictionary<string, Perceptron> _lstPerceptrons = new Dictionary<string, Perceptron>();
|
private Dictionary<string, Perceptron> _lstPerceptrons = new Dictionary<string, Perceptron>();
|
||||||
private Model.IGestionFichiers _gestionSortie = new GestionFichiersSorties();
|
private IGestionFichiers _gestionSortie = new GestionFichiersSorties();
|
||||||
private List<Squelette> _lstData = new List<Squelette>();
|
private List<Squelette> _lstData;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructeur
|
/// Constructeur
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GestionPerceptrons() {
|
public GestionPerceptrons() {
|
||||||
|
_lstData = _gestionSortie.ChargerCoordonnees("train.txt");
|
||||||
|
|
||||||
for (char x = '0'; x <= '9'; ++x)
|
for (char x = '0'; x <= '9'; ++x)
|
||||||
_lstPerceptrons.Add(x.ToString(), new Perceptron(x.ToString()));
|
_lstPerceptrons.Add(x.ToString(), new Perceptron(x.ToString()));
|
||||||
|
|
||||||
|
foreach (Squelette sql in _lstData)
|
||||||
|
Entrainement(sql, sql.Reponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -44,6 +50,7 @@ namespace JeuHoy_WPF_Natif.Model {
|
|||||||
if (reponse != "") {
|
if (reponse != "") {
|
||||||
coordo.Reponse = reponse;
|
coordo.Reponse = reponse;
|
||||||
_lstData.Add(coordo);
|
_lstData.Add(coordo);
|
||||||
|
SauvegarderCoordonnees("train.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lstData is null)
|
if (_lstData is null)
|
||||||
|
@ -30,8 +30,8 @@ namespace JeuHoy_WPF_Natif.Presenter
|
|||||||
private void _vue_EntrainementEvt(object sender, EventArgs e)
|
private void _vue_EntrainementEvt(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Perceptron!!!
|
// Perceptron!!!
|
||||||
string position = _vue.GetPositionEnCour().ToString();
|
string position = (_vue.GetPositionEnCour() - 1).ToString();
|
||||||
Squelette sq = new Squelette(new double[1], position);
|
Squelette sq = new Squelette(_gestionnaireKinect.Body, position);
|
||||||
|
|
||||||
_vue.Console = _gestionnairePerceptron.Entrainement(sq, position);
|
_vue.Console = _gestionnairePerceptron.Entrainement(sq, position);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using JeuHoy_WPF_Natif.View;
|
|||||||
using Microsoft.Kinect;
|
using Microsoft.Kinect;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -42,6 +43,10 @@ namespace JeuHoy_WPF.View
|
|||||||
|
|
||||||
_presentateur = new PresentateurWEntrainement(this);
|
_presentateur = new PresentateurWEntrainement(this);
|
||||||
|
|
||||||
|
for (int x = 1; x <= CstApplication.NBFIGURE; ++x)
|
||||||
|
if (File.Exists("HoyContent/fig" + x.ToString() + ".png"))
|
||||||
|
_dicImgFigure.Add("fig" + x, new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"./HoyContent/fig" + x.ToString() + ".png", UriKind.Absolute)));
|
||||||
|
|
||||||
ChargerFigure();
|
ChargerFigure();
|
||||||
_son.JouerSonAsync(@"./HoyContent/hoy.wav");
|
_son.JouerSonAsync(@"./HoyContent/hoy.wav");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user