Results obtained from IDCardReader
IDCardResults contains the following members (each member is of type FieldResult that contains the field data as text as well as the confidence value:
Member | Description |
---|---|
BirthDate |
Birth date of the card holder |
IssueDate |
Card issue date |
ExpireDate |
Card expiry date |
IDNumber |
Card ID number |
Country |
Country or state name that issued the card |
Any of the field values will be left as null if the reader cannot find the corresponding date in the card.
The date values of BirthDate, IssueDate and ExpireDate are returned in mm/dd/yyyy or dd/mm/yyyy format. It is up to the calling software to further process this value. The date formatting defer between USA and EU cards, for example if the date is "June 1st, 1971" then the card might have any of the following:
<ol>
US cards have the date in the MM/DD/YYYY format such as "6/1/1971" or "06/01/1971"
EU cards have the date in the DD.MM.YYYY format such as "1.6.1971" or "01.06.1971"
</ol>
Use the platform Date support to further parse the raw date if needed. For instance, in the .NET platform the DateTime class contains everything needed to parse dates from strings. Combine the DateTime methods along with the card region value of IDCardRegion set in IDCardReader.Region to extract the result. Here is an example:
// Initialize the card reader
IDCardReader cardReader = ... // initialization code omitted
// Set the region, in this case, USA
cardReader.Region = IDCardRegion.USA; // Or .EU
// To parse dates, we need to setup a .NET System.Globalization.CultureInfo to handle this
CultureInfo cultureInfo;
if(cardReader.Region == IDCardRegion.USA)
{
// US region, create a .NET System.Globalization.CultureInfo class that can handle this
cultureInfo = new CultureInfo("en-us");
}
else
{
// EU region, create a .NET System.Globalization.CultureInfo class that can handle this
// Here, we will use German culture, we could have used UK or France, all will work.
cultureInfo = new CultureInfo("de");
}
// Calls .ProcessFrame and assume it succeeds
//PerformRecogniton(cardReader);
// We are interested in the expiry date
string expireDateAsString = cardReader.Results.ExpireDate.Text;
if(string.IsNullOrEmpty(expireDateAsString))
{
// The engine could not read the card expire date
throw new Exception("Could not parse expire date. Manual verification is required");
}
// Parse it
DateTime expireDate;
if(!DateTime.TryParse(expireDateAsString, cultureInfo, DateTimeStyles.None, out expireDate))
{
throw new Exception("Error parsing expire date. Manual verification is required");
}
// And show it
Console.WriteLine("Expire at " + expireDate.ToLongDateString());
For an example, refer to IDCardReader.