SBSDKIDCardRecognizer
@interface SBSDKIDCardRecognizer : NSObject
A class to detect and recognize personal ID cards in a UIImage or CMSampleBufferRef. Extracts the data fields, like names, dates, photos, signatures and machine readable zones. Detection is a quick way to check, if there is an ID card present on an image or video frame. Recognition is slower but additionally extracts the data fields from the ID card.
Note: Currently limited to German ID cards.
-
The accepted minimal sharpness score. Images with a score less than that will be rejected with blurry status.
0 - any image will be accepted. 80 - a good compromise; the recommended setting. 100 - only very sharp images will be accepted.
The default value is 80.
Declaration
Objective-C
@property (nonatomic) CGFloat sharpnessAcceptanceFactor;
Swift
var sharpnessAcceptanceFactor: CGFloat { get set }
-
An array of recognizable document types. Pass an empty array or nil to accept all supported document types. The default value is nil, accepting all supported document types.
Declaration
Objective-C
@property (nonatomic, strong, nullable) NSArray<SBSDKIDCardType *> *acceptedDocumentTypes;
Swift
var acceptedDocumentTypes: [SBSDKIDCardType]? { get set }
-
Detects an ID card on a video frame. Does not recognize and extract field data.
Declaration
Objective-C
- (nullable SBSDKIDCardRecognizerResult *) detectIDCardOnBuffer:(nonnull CMSampleBufferRef)sampleBufferRef orientation:(AVCaptureVideoOrientation)videoOrientation;
Swift
func detectIDCard(on sampleBufferRef: CMSampleBuffer, orientation videoOrientation: AVCaptureVideoOrientation) -> SBSDKIDCardRecognizerResult?
Parameters
sampleBufferRef
The CMSampleBuffer instance to detect an ID card on.
videoOrientation
The orientation of the sample buffer.
Return Value
The detection result or nil if an error occurred.
-
Detects an ID card on an UIImage instance. Does not recognize and extract field data.
Declaration
Objective-C
- (nullable SBSDKIDCardRecognizerResult *)detectIDCardOnImage: (nonnull UIImage *)image;
Swift
func detectIDCard(on image: UIImage) -> SBSDKIDCardRecognizerResult?
Parameters
image
The UIImage instance to detect an ID card on.
Return Value
The detection result or nil if an error occurred.
-
Recognizes an ID card on a video frame. Recognizes and extracts field data.
Declaration
Objective-C
- (nullable SBSDKIDCardRecognizerResult *) recognizeIDCardOnBuffer:(nonnull CMSampleBufferRef)sampleBufferRef orientation:(AVCaptureVideoOrientation)videoOrientation;
Swift
func recognizeIDCard(on sampleBufferRef: CMSampleBuffer, orientation videoOrientation: AVCaptureVideoOrientation) -> SBSDKIDCardRecognizerResult?
Parameters
sampleBufferRef
The CMSampleBuffer instance to recognize an ID card on.
videoOrientation
The orientation of the sample buffer.
Return Value
The recognition result or nil if an error occurred.
-
Recognizes an ID card on an UIImage instance. Recognizes and extracts field data.
Declaration
Objective-C
- (nullable SBSDKIDCardRecognizerResult *)recognizeIDCardOnImage: (nonnull UIImage *)image;
Swift
func recognizeIDCard(on image: UIImage) -> SBSDKIDCardRecognizerResult?
Parameters
image
The UIImage instance to recognize an ID card on.
Return Value
The recognition result or nil if an error occurred.