SBSDKMachineReadableZoneRecognizer

@interface SBSDKMachineReadableZoneRecognizer : NSObject

A class to recognize machine-readable zones in a UIImage or SampleBufferRef. Result is encapsulated in SBSDKMRZRecognizerResult instance. NOTE: In order to operate, this class requires tesseract languages and trained data to be present in application bundle

  • The maximum number of results to be accumulated when live-recognizing machine readable zones on sample buffers. This sets the second part of a requiredNumberOfEqualAccumulatedResults-of-maxNumberOfAccumulatedResults selector, e.g. 2 of 4 results must be equal. To make the selector less strict, select a higher value, e.g. 2 of 5 or even 2 of 6. Setting a value lower than requiredNumberOfEqualAccumulatedResults will throw an exception. Values less-than-or-equal to 0, will effectively turn off the result accumulation. The default value is 4.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger maxNumberOfAccumulatedResults;

    Swift

    var maxNumberOfAccumulatedResults: UInt { get set }
  • The minimum number of equal results in the accumulator when live-recognizing machine readable zones on sample buffers. This sets the first part of a requiredNumberOfEqualAccumulatedResults-of-maxNumberOfAccumulatedResults selector, e.g. 2 of 4 results must be equal. To get less false positive results make the selector more strict by selecting a higher value, e.g. 3 of 4 or even 4 of 4. Setting a value higher than maxNumberOfAccumulatedResults will throw an exception. Values less-than-or-equal to 0, will effectively turn off the result accumulation. The default value is 2.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger requiredNumberOfEqualAccumulatedResults;

    Swift

    var requiredNumberOfEqualAccumulatedResults: UInt { get set }
  • Acquire all available information from UIImage instance containing machine-readable zone.

    Declaration

    Objective-C

    - (nullable SBSDKMachineReadableZoneRecognizerResult *)
        recognizePersonalIdentityFromImage:(nonnull UIImage *)image;

    Swift

    func recognizePersonalIdentity(from image: UIImage) -> SBSDKMachineReadableZoneRecognizerResult?

    Parameters

    image

    The image where machine-readable zone is to be detected.

    Return Value

    Recognizer result or nil.

  • Acquire all available information from previously extracted MRZ text.

    Declaration

    Objective-C

    - (nullable SBSDKMachineReadableZoneRecognizerResult *)
        recognizePersonalIdentityFromText:(nonnull NSString *)text;

    Swift

    func recognizePersonalIdentity(fromText text: String) -> SBSDKMachineReadableZoneRecognizerResult?

    Parameters

    text

    Text with extracted MRZ data.

    Return Value

    Recognizer result or nil.

  • Acquire all available information from sample buffer reference containing machine-readable zone.

    Declaration

    Objective-C

    - (nullable SBSDKMachineReadableZoneRecognizerResult *)
        recognizePersonalIdentityFromSampleBuffer:
            (nonnull CMSampleBufferRef)sampleBufferRef
                                      orientation:(AVCaptureVideoOrientation)
                                                      videoOrientation
                          machineReadableZoneRect:(CGRect)machineReadableZoneRect;

    Swift

    func recognizePersonalIdentity(from sampleBufferRef: CMSampleBuffer, orientation videoOrientation: AVCaptureVideoOrientation, machineReadableZoneRect: CGRect) -> SBSDKMachineReadableZoneRecognizerResult?

    Parameters

    sampleBufferRef

    The sample buffer reference containing machine-readable zone.

    videoOrientation

    Video frame orientation.

    machineReadableZoneRect

    Rectangle in frame containing machine-readable zone. Pass an empty rectangle if no frame is used.

    Return Value

    Recognizer result or nil.