/* public void AddStoredData(String reference, String username, String password) { UserInfoTuple[] newStoredData = new UserInfoTuple[StoredData.Length + 1]; newStoredData[0] = new UserInfoTuple(reference, username, password); for (int i = 0; i < StoredData.Length; i++) { newStoredData[i + 1] = StoredData[i]; } StoredData = newStoredData; }*/ public void SetStoredData(int idx, String reference, String username, String password) { if (idx < StoredData.Length) { UserInfoTuple newdata = new UserInfoTuple(reference, username, password); StoredData[idx] = newdata; } }
public User(String nm, String iPath, List<Point2d> psw, List<Point2d> scan, UserInfoTuple[] storedData) { name = nm; imgPath = iPath; password = psw; faceParams = scan; StoredData = storedData != null ? storedData : new UserInfoTuple[5]; }
/* * public void AddStoredData(String reference, String username, String password) * { * UserInfoTuple[] newStoredData = new UserInfoTuple[StoredData.Length + 1]; * newStoredData[0] = new UserInfoTuple(reference, username, password); * for (int i = 0; i < StoredData.Length; i++) * { * newStoredData[i + 1] = StoredData[i]; * } * StoredData = newStoredData; * * }*/ public void SetStoredData(int idx, String reference, String username, String password) { if (idx < StoredData.Length) { UserInfoTuple newdata = new UserInfoTuple(reference, username, password); StoredData[idx] = newdata; } }
private User LoadUser(String username) { XmlDocument data = new XmlDocument(); try { data.Load("users.xml"); } catch (Exception) { Console.WriteLine("file not found"); } SortedDictionary<String, double> matches = new SortedDictionary<String, double>(); XmlNodeList users = data.GetElementsByTagName("user"); foreach (XmlNode user in users) { if (user["name"].InnerText == username) { List<Point2d> tempPts = new List<Point2d>(); XmlNode points = user["points"]; for (int i = 0; i < points.ChildNodes.Count; i++) { XmlNode point = points.ChildNodes[i]; double x = Convert.ToDouble(point["x"].InnerText); double y = Convert.ToDouble(point["y"].InnerText); Point2d tmp = new Point2d(x, y); tempPts.Add(tmp); } XmlNode storedDataXml = user["stored-data"]; UserInfoTuple[] storedData = new UserInfoTuple[Util.NUM_STORED_DATA]; for (int i = 0; i < storedDataXml.ChildNodes.Count; i++) { XmlNode storedDataTuple = storedDataXml.ChildNodes[i]; string reference = Convert.ToString(storedDataTuple["reference"].InnerText); string uname = Convert.ToString(storedDataTuple["username"].InnerText); string password = Convert.ToString(storedDataTuple["password"].InnerText); storedData[i] = new UserInfoTuple(reference, uname, password); } return new User(user["name"].InnerText, user["user-image"].InnerText, tempPts, null, storedData); } } return null; }
public void verifyUser(double[] vals) { try { data.Load("users.xml"); } catch (Exception) { Console.WriteLine("file not found"); } SortedDictionary<String, double> matches = new SortedDictionary<String, double>(); XmlNodeList users = data.GetElementsByTagName("user"); foreach (XmlNode user in users) { double total = 0; //Console.WriteLine(user["name"].InnerText); XmlNode mets = user["face-params"]; for (int i = 0; i < mets.ChildNodes.Count; i++) { XmlNode met = mets.ChildNodes[i]; double mean = Convert.ToDouble(met["mean"].InnerText); double stdev = Convert.ToDouble(met["stdev"].InnerText); double score = getZScore(vals[i], mean, stdev); //Console.WriteLine("Score---------> " + score); if(score >= 1) { total += score; } } //Console.WriteLine(""); try { matches.Add(user["name"].InnerText, total); } catch (Exception e) { } } String bestMatchName = "New User"; double bestMatchVal = 100; foreach (KeyValuePair<String, double> kvp in matches) { Console.WriteLine(kvp.Key + "----------------" + kvp.Value); if (kvp.Value < bestMatchVal) { bestMatchVal = kvp.Value; bestMatchName = kvp.Key; } } if (bestMatchVal <= MAX_DIFF) { Console.WriteLine(bestMatchName); foreach (XmlNode user in users) { if (user["name"].InnerText == bestMatchName) { List<Point2d> tempPts = new List<Point2d>(); XmlNode points = user["points"]; for (int i = 0; i < points.ChildNodes.Count; i++) { XmlNode point = points.ChildNodes[i]; double x = Convert.ToDouble(point["x"].InnerText); double y = Convert.ToDouble(point["y"].InnerText); Point2d tmp = new Point2d(x, y); tempPts.Add(tmp); } XmlNode storedDataXml = user["stored-data"]; UserInfoTuple[] storedData = new UserInfoTuple[Util.NUM_STORED_DATA]; for (int i = 0; i < storedDataXml.ChildNodes.Count; i++) { XmlNode storedDataTuple = storedDataXml.ChildNodes[i]; string reference = Convert.ToString(storedDataTuple["reference"].InnerText); string username = Convert.ToString(storedDataTuple["username"].InnerText); string password = Convert.ToString(storedDataTuple["password"].InnerText); storedData[i] = new UserInfoTuple(reference, username, password); } User current = new User(user["name"].InnerText, user["user-image"].InnerText, tempPts, null, storedData); Console.WriteLine(user["name"].InnerText); Notify(current); return; } } } else { Console.WriteLine("New User"); User cur = new User("", "", null, null, null); Notify(cur); } }
public void verifyUser(double[] vals) { try { data.Load("users.xml"); } catch (Exception) { Console.WriteLine("file not found"); } SortedDictionary <String, double> matches = new SortedDictionary <String, double>(); XmlNodeList users = data.GetElementsByTagName("user"); foreach (XmlNode user in users) { double total = 0; //Console.WriteLine(user["name"].InnerText); XmlNode mets = user["face-params"]; for (int i = 0; i < mets.ChildNodes.Count; i++) { XmlNode met = mets.ChildNodes[i]; double mean = Convert.ToDouble(met["mean"].InnerText); double stdev = Convert.ToDouble(met["stdev"].InnerText); double score = getZScore(vals[i], mean, stdev); //Console.WriteLine("Score---------> " + score); if (score >= 1) { total += score; } } //Console.WriteLine(""); try { matches.Add(user["name"].InnerText, total); } catch (Exception e) { } } String bestMatchName = "New User"; double bestMatchVal = 100; foreach (KeyValuePair <String, double> kvp in matches) { Console.WriteLine(kvp.Key + "----------------" + kvp.Value); if (kvp.Value < bestMatchVal) { bestMatchVal = kvp.Value; bestMatchName = kvp.Key; } } if (bestMatchVal <= MAX_DIFF) { Console.WriteLine(bestMatchName); foreach (XmlNode user in users) { if (user["name"].InnerText == bestMatchName) { List <Point2d> tempPts = new List <Point2d>(); XmlNode points = user["points"]; for (int i = 0; i < points.ChildNodes.Count; i++) { XmlNode point = points.ChildNodes[i]; double x = Convert.ToDouble(point["x"].InnerText); double y = Convert.ToDouble(point["y"].InnerText); Point2d tmp = new Point2d(x, y); tempPts.Add(tmp); } XmlNode storedDataXml = user["stored-data"]; UserInfoTuple[] storedData = new UserInfoTuple[Util.NUM_STORED_DATA]; for (int i = 0; i < storedDataXml.ChildNodes.Count; i++) { XmlNode storedDataTuple = storedDataXml.ChildNodes[i]; string reference = Convert.ToString(storedDataTuple["reference"].InnerText); string username = Convert.ToString(storedDataTuple["username"].InnerText); string password = Convert.ToString(storedDataTuple["password"].InnerText); storedData[i] = new UserInfoTuple(reference, username, password); } User current = new User(user["name"].InnerText, user["user-image"].InnerText, tempPts, null, storedData); Console.WriteLine(user["name"].InnerText); Notify(current); return; } } } else { Console.WriteLine("New User"); User cur = new User("", "", null, null, null); Notify(cur); } }