/// <summary> /// Convert a collection of MinutiaRecords to the ISO 19794-2 standard template. /// NOTE: ISO template stores data as Int8 (X and angle) and Int16 values (Y) so there may /// be loss of data when casting. /// </summary> /// <param name="minutae">The minutae.</param> /// <returns></returns> public static byte[] ToIsoTemplate(IEnumerable <MinutiaRecord> minutae) { IntegrityCheck.IsNotNull(minutae); // TODO: Better understand what bytes in IsoTemplate are (Header). // ISO 19794-2? List <byte> data = new List <byte>() { }; data.AddRange(ToByteArray(HEADER_TOP)); data.Add((byte)ToHeaderMinutiaCountByte(minutae.Count())); data.AddRange(ToByteArray(HEADER_BOTTOM)); data.Add((byte)(minutae.Count())); foreach (MinutiaRecord minutia in minutae) { data.Add(TypeToByte(minutia.Type)); data.Add((byte)minutia.Position.X); data.AddRange(YToByte(minutia.Position.Y)); data.Add(AngleToByte(minutia.Angle)); data.Add(QUALITY); } data.AddRange(BitConverter.GetBytes(END)); return(data.ToArray()); }
private void CheckSupportedSetting(Setting setting) { IntegrityCheck.IsTrue( SETTINGS_LOOKUP.ContainsKey(setting), "Validator doesn't recognise setting {0}", setting); }
public static IEnumerable <MinutiaRecord> ToMinutae(byte[] isoTemplate) { IntegrityCheck.IsNotNull(isoTemplate); // TODO: IntegrityCheck start is HEADER_TOP // TODO: IntegrityCheck HEADER_BOTTOM int headerTopCount = ToByteArray(HEADER_TOP).Count(); // TODO: Make constant int minutiaCount_1 = ToMinutiaCount(isoTemplate[headerTopCount]); int headerBottomCount = ToByteArray(HEADER_BOTTOM).Count(); // TODO: Make constant int minutiaCount_2 = (UInt16)isoTemplate[headerTopCount + 1 + headerBottomCount]; // TODO: IntegrityCheck minutiaCount_1 == minutiaCount_2 int minutiaCount = minutiaCount_1; int startByte = headerTopCount + 1 + headerBottomCount + 1; // TODO: Make constant int bytesPerMinutia = 6; // TODO: Make constant List <MinutiaRecord> minutae = new List <MinutiaRecord>(minutiaCount); for (int i = 0; i < minutiaCount; i++) { MinutiaType type = TypeToMinutiaType(isoTemplate[startByte]); // TODO: IntegrityCheck type != None // Get Minutia X-Position int x = (UInt16)isoTemplate[startByte + 1]; // Get Minutia Y-Position byte[] yData = new byte[2]; Array.Copy(isoTemplate, startByte + 2, yData, 0, 2); int y = YToInt(yData); // Get Minutia angle from the two angle bytes. double angle = AngleToDouble(isoTemplate[startByte + 4]); // TODO: IntegrityCheck quality // Create minutia from data and add to list. MinutiaRecord minutia = new MinutiaRecord( new System.Windows.Point(x, y), angle, type); minutae.Add(minutia); startByte += bytesPerMinutia; } // TODO: More assertions return(minutae); }
private static byte TypeToByte(MinutiaType type) { byte typeData; switch (type) { case MinutiaType.Termination: typeData = TERMINATION; break; case MinutiaType.Bifurication: typeData = BIFURICATION; break; default: throw IntegrityCheck.FailUnexpectedDefault(type); } return(typeData); }