public double[][] LoadTaughtPeople(SOMParams somParams) { double[][] features; var fileName = GetTaughtFeaturesFilenameByParams(somParams); People = new List<Person>(); using (var sr = new StreamReader(fileName)) { var lineCount = File.ReadAllLines(fileName).Count(); features = new double[lineCount - 1][]; var count = 0; var line = sr.ReadLine(); var splitStringArray = new string[1] {";"}; line = sr.ReadLine(); var members = line.Split(splitStringArray, StringSplitOptions.None); var person = new Person(members[0]); var finger = new Fingerprint(int.Parse(members[1])); var scan = new Scan(int.Parse(members[2])); var feature = new Minutia((short)double.Parse(members[3]), (short)double.Parse(members[4]), double.Parse(members[5])) { MinutiaType = (MinutiaType)double.Parse(members[6]) }; scan.Features.Add(feature); features[count] = new double[5]; features[count][2] = double.Parse(members[3]); features[count][3] = double.Parse(members[4]); features[count][0] = double.Parse(members[5]); features[count][1] = double.Parse(members[6]); features[count][4] = double.Parse(members[7]); count++; // Read lines from the file until the end of the file is reached. while ((line = sr.ReadLine()) != null) { members = line.Split(splitStringArray, StringSplitOptions.None); features[count] = new double[5]; features[count][2] = double.Parse(members[3]); features[count][3] = double.Parse(members[4]); features[count][0] = double.Parse(members[5]); features[count][1] = double.Parse(members[6]); features[count][4] = double.Parse(members[7]); count++; feature = new Minutia((short)double.Parse(members[3]), (short)double.Parse(members[4]), double.Parse(members[5])) { MinutiaType = (MinutiaType)double.Parse(members[6]) }; scan.Features.Add(feature); var scanId = int.Parse(members[2]); if (scan.Id != scanId) { finger.Scans.Add(scan); scan = new Scan(scanId); } var fingerId = int.Parse(members[1]); if (finger.Id != fingerId) { person.Fingerprints.Add(finger); finger = new Fingerprint(fingerId); } if (person.Id != members[0]) { People.Add(person); person = new Person(members[0]); } } finger.Scans.Add(scan); person.Fingerprints.Add(finger); People.Add(person); sr.Close(); } return features; }
private void ExtractFeatures() { var featExtractor = new Ratha1995MinutiaeExtractor(); foreach (var person in existingPeople) { var fingerprintOwner = new Person(person); foreach (var finger in wantedFingers) { var fingerprintFinger = new Fingerprint(int.Parse(finger)); foreach (var scan in wantedScans) { var fingerprintImg = ImageLoader.LoadImage(string.Format(@"{0}{1}_{2}_{3}.tif", Folder, person, finger, scan)); var features = featExtractor.ExtractFeatures(fingerprintImg); var fingerprintScan = new Scan(int.Parse(scan), features); fingerprintFinger.Scans.Add(fingerprintScan); } fingerprintOwner.Fingerprints.Add(fingerprintFinger); } People.Add(fingerprintOwner); } }
private void LoadPeople() { var fileName = string.Format(@"{0}{1}", Folder, FeaturesDatabase); using (var sr = new StreamReader(fileName)) { var line = sr.ReadLine(); var splitStringArray = new string[1] {";"}; line = sr.ReadLine(); var members = line.Split(splitStringArray, StringSplitOptions.None); var person = new Person(members[0]); var finger = new Fingerprint(int.Parse(members[1])); var scan = new Scan(int.Parse(members[2])); var feature = new Minutia(short.Parse(members[3]), short.Parse(members[4]), double.Parse(members[5])) { MinutiaType = (MinutiaType) int.Parse(members[6]) }; scan.Features.Add(feature); // Read lines from the file until the end of the file is reached. while ((line = sr.ReadLine()) != null) { members = line.Split(splitStringArray, StringSplitOptions.None); feature = new Minutia(short.Parse(members[3]), short.Parse(members[4]), double.Parse(members[5])) { MinutiaType = (MinutiaType) int.Parse(members[6]) }; scan.Features.Add(feature); var scanId = int.Parse(members[2]); if (scan.Id != scanId) { finger.Scans.Add(scan); scan = new Scan(scanId); } var fingerId = int.Parse(members[1]); if (finger.Id != fingerId) { person.Fingerprints.Add(finger); finger = new Fingerprint(fingerId); } if (person.Id != members[0]) { People.Add(person); person = new Person(members[0]); } } finger.Scans.Add(scan); person.Fingerprints.Add(finger); People.Add(person); sr.Close(); } }