/* See LICENSE folder for this sample’s licensing information. Abstract: Utilities for dealing with recognized strings */ import Foundation var captureFirst = "" var captureSecond = "" var captureThird = "" var mrz = "" var temp_mrz = "" extension String { func checkMrz() -> (String)? { let tdOneFirstRegex = "(I|C|A).[A-Z0<]{3}[A-Z0-9]{1,9} bestCount { bestCount = Int64(count) bestString = string } } // Remove old strings. for string in obsoleteStrings { seenStrings.removeValue(forKey: string) } frameIndex += 1 } func getStableString() -> String? { // Require the recognizer to see the same string at least 10 times. if bestCount >= 10 { return bestString } else { return nil } } func reset(string: String) { seenStrings.removeValue(forKey: string) bestCount = 0 bestString = "" captureFirst = "" captureSecond = "" captureThird = "" mrz = "" temp_mrz = "" } }