Scanning a generic document from an image
If you want to perform detection on a single still image. You can use SBSDKGenericDocumentRecognizer
's recognizeDocument(on:)
method, which takes an image as input, performs detection on the image, and returns the result.
Example for detecting Generic Document on the Image
- Swift
- Objective-C
import Foundation
import ScanbotSDK
func detectGenericDocumentOnImage() {
// Image containing generic document.
guard let image = UIImage(named: "genericDocumentImage") else { return }
// Types of generic documents you want to detect.
let typesToDetect = SBSDKGenericDocumentRootType.allDocumentTypes
// Creates an instance of `SBSDKGenericDocumentRecognizer`.
let detector = SBSDKGenericDocumentRecognizer(acceptedDocumentTypes: typesToDetect)
// Returns the result after running detector on the image.
let result = detector.recognize(on: image)
}
#import "GenericDocumentDetectionOnImage.h"
@import ScanbotSDK;
@implementation GenericDocumentDetectionOnImage
- (void) detectGenericDocumentOnImage {
// Image containing generic document.
UIImage *image = [UIImage imageNamed:@"genericDocumentImage"];
// Types of generic documents you want to detect.
NSArray<SBSDKGenericDocumentRootType *> *typesToDetect = [SBSDKGenericDocumentRootType allDocumentTypes];
// Creates an instance of `SBSDKGenericDocumentRecognizer`.
SBSDKGenericDocumentRecognizer *detector = [[SBSDKGenericDocumentRecognizer alloc] initWithAcceptedDocumentTypes:typesToDetect];
// Returns the result after running detector on the image.
SBSDKGenericDocumentRecognitionResult *result = [detector recognizeDocumentOnImage:image];
}
@end
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get your free Trial LicenseWhat do you think of this documentation?
What can we do to improve it? Please be as detailed as you like.