Loading Data, load only the name in the XML file I did the save.
This is the
XML
file : // The trainingfaces file
<?xml version="1.0" encoding="utf-8"?>
<Faces_For_Training>
<FACE>
<NAME>john</NAME>
<Age>25</Age>
<informations>Student in MS university</informations>
<FILE>face_john 25Student in MS university_905807542.jpg</FILE>
</FACE>
<FACE>
<NAME>mark</NAME>
<Age>40</Age>
<informations>engineer ....</informations>
<FILE>face_mark 40engineer ....._390671740.jpg</FILE>
</FACE>
</Faces_For_Training>
The problem that I can load only the name .how I can load age and extra information with the name . I load the name and put it in List <string> and make it equal to face label. I want it load Age , and the other information's .
private bool LoadTrainingData(string Folder_location)
{
if (File.Exists(Folder_location +"\\TrainedLabels.xml"))
{
try
{
//message_bar.Text = "";
Names_List.Clear();
Names_List_ID.Clear();
trainingImages.Clear();
FileStream filestream = File.OpenRead(Folder_location + "\\TrainedLabels.xml");
long filelength = filestream.Length;
byte[] xmlBytes = new byte[filelength];
filestream.Read(xmlBytes, 0, (int)filelength);
filestream.Close();
MemoryStream xmlStream = new MemoryStream(xmlBytes);
using (XmlReader xmlreader = XmlTextReader.Create(xmlStream))
{
while (xmlreader.Read())
{
if (xmlreader.IsStartElement())
{
switch (xmlreader.Name)
{
case "NAME":
if (xmlreader.Read())
{
Names_List_ID.Add(Names_List.Count); //0, 1, 2, 3....
Names_List.Add(xmlreader.Value.Trim());
NumLabels += 3;
}
break;
case "FILE":
if (xmlreader.Read())
{
//PROBLEM HERE IF TRAININGG MOVED
trainingImages.Add(new Image<Gray, byte>(Application.StartupPath + "\\TrainedFaces\\" + xmlreader.Value.Trim()));
}
break;
// case "Age":
// if (xmlreader.Read())
//{
// Age_List.Add(xmlreader.Value.Trim());
// }
// break;
}
}
}
}
ContTrain = NumLabels;