Getting results

This page covers the description of how to get various kinds of results

Text Results

If you know exactly what text data are needed, the fastest way to get information is to use special functions.

Getting values

Getting values of text fields indicating fieldType:

// Get full name
let surnameAndGivenNames = result.getTextFieldValueByType(fieldType: .ft_Surname_And_Given_Names)
// Get date of birth
let dateOfBirth = result.getTextFieldValueByType(fieldType: .ft_Date_of_Birth)
// Get document number
let documentNumber = result.getTextFieldValueByType(fieldType: .ft_Document_Number)

Getting values of text fields indicating fieldType, lcid:

// Get full name
let surnameAndGivenNames = result.getTextFieldValueByType(fieldType: .ft_Surname_And_Given_Names, lcid: .belarusian)
// Get place of birth
let placeOfBirth = result.getTextFieldValueByType(fieldType: .ft_Place_of_Birth, lcid: .germanGermany)

Getting values of text fields indicating fieldType, lcid, source:

// Get full name
let surnameAndGivenNames = result.getTextFieldValueByType(fieldType: .ft_Surname_And_Given_Names, lcid: .belarusian, source: .visualOCRExtended)
// Get address
let address = result.getTextFieldValueByType(fieldType: .ft_Address, lcid: .latin, source: .barCodesTextData)

Getting values of text fields indicating fieldType, lcid, source, original:

// Get surname
let surname = result.getTextFieldValueByType(fieldType: .ft_Surname, lcid: .belarusian, source: .visualOCRExtended, original: true)
// Get address
let address = result.getTextFieldValueByType(fieldType: .ft_Address, lcid: .latin, source: .barCodesTextData, original: true)

Getting values of text fields indicating fieldType, source:

// Get surname
let surname = result.getTextFieldValueByType(fieldType: .ft_Surname, source: .visualOCRExtended)

Getting values of text fields indicating fieldType, source, original:

// Get surname
let surname = result.getTextFieldValueByType(fieldType: .ft_Surname, source: .visualOCRExtended, original: true)

Getting values of text fields indicating fieldType, original:

// Get surname
let surname = result.getTextFieldValueByType(fieldType: .ft_Surname, original: true)

You can also go through all instances of text fields and obtain the desired information, e.g.:

for textField in result.textResult.fields {
    guard let value = result.getTextFieldValueByType(fieldType: textField.fieldType, lcid: textField.lcid) else { continue }
    print("fieldName: \(textField.fieldName), value: \(value)")
}

Getting instances

Getting instances of text fields indicating fieldType:

// Get a surname instance
let surname = result.getTextFieldByType(fieldType: .ft_Surname)
// Get an address instance
let address = result.getTextFieldByType(fieldType: .ft_Address)

Getting instances of text fields indicating fieldType, lcid:

// Get a surname instance
let surname = result.getTextFieldByType(fieldType: .ft_Surname, lcid: .belarusian)
// Get a placeOfBirth instance
let placeOfBirth = result.getTextFieldByType(fieldType: .ft_Place_of_Birth, lcid: .germanGermany)

Graphic Results

Getting values

Getting values of graphic fields indicating fieldType:

// Get document image
result.getGraphicFieldImageByType(fieldType: .gf_DocumentImage)
// Get portrait image
result.getGraphicFieldImageByType(fieldType: .gf_Portrait)

Getting values of graphic fields indicating fieldType, source:

// Get document image
result.getGraphicFieldImageByType(fieldType: .gf_DocumentImage, source: .rawImage)
// Get document image (uncropped)
result.getGraphicFieldImageByType(fieldType: .gf_DocumentImage, source: .rawUncroppedImage)
// Get portrait image
result.getGraphicFieldImageByType(fieldType: .gf_Portrait, source: .graphics)

Getting values of graphic fields indicating fieldType, source, pageIndex:

// Get document image from the second page
result.getGraphicFieldImageByType(fieldType: .gf_DocumentImage, source: .rawImage, pageIndex: 1)
// Get portrait image from the first page
result.getGraphicFieldImageByType(fieldType: .gf_Portrait, source: .graphics, pageIndex: 0)

Getting values of graphic fields indicating fieldType, source, pageIndex, light:

// Get document image from the first page with white light
result.getGraphicFieldImageByType(fieldType: .gf_DocumentImage, source: .rawImage, pageIndex: 0, light: .white)
// Get document image from the first page with UV light
result.getGraphicFieldImageByType(fieldType: .gf_DocumentImage, source: .rawImage, pageIndex: 0, light: .UV)

Getting instances

Getting instances of graphic fields indicating fieldType:

// Get a documentImage instance
let documentImage = result.getGraphicFieldByType(fieldType: .gf_DocumentImage)
// Get a portrait instance
let portrait = result.getGraphicFieldByType(fieldType: .gf_Portrait)

Getting instances of graphic fields indicating fieldType, source:

// Get a documentImage instance
let documentImage = result.getGraphicFieldByType(fieldType: .gf_DocumentImage, source: .rawImage)
// Get a portrait instance
let portrait = result.getGraphicFieldByType(fieldType: .gf_Portrait, source: .graphics)

Getting instances of graphic fields indicating fieldType, source, pageIndex:

// Get a documentImage instance
let documentImage = result.getGraphicFieldByType(fieldType: .gf_DocumentImage, source: .rawImage, pageIndex: 0)
// Get a portrait instance
let portrait = result.getGraphicFieldByType(fieldType: .gf_Portrait, source: .graphics, pageIndex: 0)

Getting instances of graphic fields indicating fieldType, source, pageIndex, light:

// Get a documentImage instance
let documentImage = result.getGraphicFieldByType(fieldType: .gf_DocumentImage, source: .rawImage, pageIndex: 0, light: .white)
// Get a portrait instance
let portrait = result.getGraphicFieldByType(fieldType: .gf_Portrait, source: .graphics, pageIndex: 0, light: .white)

Last updated

Was this helpful?