SmartZone OCR allows you to provide a list of expected data contents. If you know potential actual values, providing that information will make your recognition results more accurate.
To improve recognition using a Data Validation List, set the FieldType property of the Reader class to DataValidationList. To populate the data validation list call the DataValidationListAddEntry method of the Reader class for every valid value.
DataValidationListRemoveEntry will remove an entry from the data validation list.
DataValidationListClear will remove all entries from the data validation list.
To examine the data validation list, call DataValidationListCount to get the number of entries in the data validation list. DataValidationListGetAt will return the entries at that index. So, by calling DataValidationListGetAt with index value of zero to DataValidationListCount, you can get every entry in the data validation list.
Example - Clear a data validation list and add from a checkbox list. | Copy Code |
---|---|
//Clear previous DVL smartZoneOCR1.Reader.DataValidationListClear(); //Add new ones for (int i = 0; i < checkedListBoxDVL.Items.Count; i++) { object curritem = checkedListBoxDVL.Items[i]; if (checkedListBoxDVL.CheckedItems.Contains(curritem)) { smartZoneOCR1.Reader.DataValidationListAddEntry(curritem.ToString()); } } |
Using a Data Validation list provides additional feedback on recognition by way of the returned FieldType value. For example, a regular string will return a FieldType of GeneralText. When a DataValidation list is used, if the recognized value matches a value in the list, the FieldType of DataValidationList is returned. Otherwise, the FieldType of Unknown is returned, indicating that the recognized value was not in the list.
Practical uses of Data Validation lists are:
- Well known values from a static list.
For example, a list of state abbreviations
var stateList = new List<String>() { "AL", "AK", "AZ" ... };
- Dynamically set items based on the value of another field.
For example, if the Area code for a phone number was 703, the corresponding State could be validated against VA and DC; it should be one of those values. - Dynamically set items based on program conditions.
For example, your program could be in a state where the only acceptable values in a field would be "N2101", "N2102" or "N2117."