SBSDKGenericDocumentRecognizer
@interface SBSDKGenericDocumentRecognizer : NSObject
A class to recognize and detect the data fields from specific documents, e.g. German passports, ID cards and driver’s licenses in a UIImage or CMSampleBufferRef. In case of success, returns an instance of SBSDKGenericDocumentRecognitionResult holding the generic document with all recognized fields, including their names, values and image excerpts, along with their OCR confidence values.
-
Not available.
Declaration
Objective-C
- (nonnull instancetype)init;
-
Not available.
Declaration
Objective-C
+ (nonnull instancetype)new;
-
Designated initializer. Creates an instance of the recognizer which recognizes any of the given accepted document types.
Declaration
Objective-C
- (nonnull instancetype)initWithAcceptedDocumentTypes: (nonnull NSArray<SBSDKGenericDocumentRootType *> *)acceptedDocumentTypes;
Swift
init(acceptedDocumentTypes: [SBSDKGenericDocumentRootType])
Parameters
acceptedDocumentTypes
An array of document types that should be recognized. Must not be nil or empty.
-
Convenient initializer. Creates an instance of the recognizer which recognizes any of the given accepted document types excluding certain fields.
Declaration
Objective-C
- (nonnull instancetype) initWithAcceptedDocumentTypes: (nonnull NSArray<SBSDKGenericDocumentRootType *> *)acceptedDocumentTypes excludedFieldTypes: (nullable NSArray<NSString *> *)excludedFieldTypes;
Swift
init(acceptedDocumentTypes: [SBSDKGenericDocumentRootType], excludedFieldTypes: [String]?)
Parameters
acceptedDocumentTypes
An array of document types that should be recognized. Must not be nil or empty.
excludedFieldTypes
An array of normalized names for the document field types that should not be recognized. If nil all the fields are going to be recognized.
-
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 }
-
Set to NO, if recognition should happen on a single image. Set to YES, if consecutive frames should be used to refine the recognized documents. If set to YES, you need to call
resetAccumulation
before trying to recognize a different document. Default value is NO.Declaration
Objective-C
@property (nonatomic) BOOL accumulatesDocuments;
Swift
var accumulatesDocuments: Bool { get set }
-
An array of recognizable document types. Please specify at least one document type you want to scan for.
Declaration
Objective-C
@property (nonatomic, copy, nonnull) NSArray<SBSDKGenericDocumentRootType *> *acceptedDocumentTypes;
Swift
var acceptedDocumentTypes: [SBSDKGenericDocumentRootType] { get set }
-
An array of normalized names for the document field types that should not be recognized. If nil all the fields are going to be recognized.
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSArray<NSString *> *excludedFieldTypes;
Swift
var excludedFieldTypes: [String]? { get set }
-
Recognizes a document on a video frame and extracts the documents fields.
Declaration
Objective-C
- (nullable SBSDKGenericDocumentRecognitionResult *) recognizeDocumentOnBuffer:(nonnull CMSampleBufferRef)sampleBufferRef orientation:(AVCaptureVideoOrientation)videoOrientation;
Swift
func recognizeDocument(on sampleBufferRef: CMSampleBuffer, orientation videoOrientation: AVCaptureVideoOrientation) -> SBSDKGenericDocumentRecognitionResult?
Parameters
sampleBufferRef
The CMSampleBuffer instance to recognize a document on.
videoOrientation
The orientation of the sample buffer.
Return Value
The recognition result or nil if no document has been recognized.
-
Recognizes a document on an UIImage instance and extracts the documents fields.
Declaration
Objective-C
- (nullable SBSDKGenericDocumentRecognitionResult *)recognizeDocumentOnImage: (nonnull UIImage *)image;
Swift
func recognizeDocument(on image: UIImage) -> SBSDKGenericDocumentRecognitionResult?
Parameters
image
The UIImage instance to recognize a document on.
Return Value
The recognition result or nil if no document has been recognized.
-
Resets the recognized-documents-accumulator.
Declaration
Objective-C
- (void)resetDocumentAccumulation;
Swift
func resetDocumentAccumulation()