GSK
@interface GSK : NSObject
The SDK class is your entry point to the low-level SDK features.
-
Must be called first with a valide license key to enable the SDK.
Warning
Important This method must be called before any use of the SDK methods.All the SDK errors return proper errors in that case and you can handle them to ensure you provide a good
degraded
experience. For instance, you can prompt the user to update the application to use the scanning feature in case they use a version of the application with an expired license key.Declaration
Objective-C
+ (BOOL)initWithLicenseKey:(nonnull NSString *)licenseKey error:(NSError *_Nullable *_Nullable)error;
Swift
class func initWithLicenseKey(_ licenseKey: String) throws
Parameters
licenseKey
The license key
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value
YES if the SDK was initialized successfully, NO if an error occured.
-
Detects the quadrangle corresponding to the edges of a document in a photo
Declaration
Objective-C
+ (GSKQuadrangleDetectionResult *_Nullable) detectQuadrangleFromImage:(nonnull UIImage *)image options:(GSKDetectQuadrangleOptions)options error:(NSError *_Nullable *_Nullable)error;
Swift
class func detectQuadrangle(from image: UIImage, options: GSKDetectQuadrangleOptions = []) throws -> GSKQuadrangleDetectionResult
Parameters
image
The photo to detect a document in
options
See GSKDetectQuadrangleOptions
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value
The detected quadrangle or nil if an error occured.
-
Detects the quadrangle corresponding to the edges of a document in video frame
Declaration
Objective-C
+ (GSKQuadrangleDetectionResult *_Nullable) detectQuadrangleFromSampleBuffer:(nonnull CMSampleBufferRef)sampleBuffer error:(NSError *_Nullable *_Nullable)error;
Swift
class func detectQuadrangle(from sampleBuffer: CMSampleBuffer) throws -> GSKQuadrangleDetectionResult
Parameters
sampleBuffer
a YCbCr sample buffer of a video frame. Make sure the video output generating these frames is configured with the pixel format kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value
The detected quadrangle or nil if an error occured.
-
Extracts the document from the given photo and corrects its perspective
Declaration
Objective-C
+ (UIImage *_Nullable)warpImage:(nonnull UIImage *)image withQuadrangle:(GSKQuadrangle *_Nullable)quadrangle error:(NSError *_Nullable *_Nullable)error;
Swift
class func warpImage(_ image: UIImage, with quadrangle: GSKQuadrangle?) throws -> UIImage
Parameters
image
The original photo
quadrangle
The quadrangle representing the edges of the document. If nil, the entire image is returned.
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value
the cropped and perspective-corrected document or nil if an error occured. Errors include: - non-convex quadrangle - failure to warp
-
Determines the best image processing type for a document
Declaration
Objective-C
+ (GSKBestFilterResult *_Nullable) bestFilterForImage:(nonnull UIImage *)image error:(NSError *_Nullable *_Nullable)error;
Swift
class func bestFilter(for image: UIImage) throws -> GSKBestFilterResult
Parameters
image
The cropped and perspective-corrected document
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value
The best enhancement for this document or nil if an error occured.
-
Enhances a document image with the selected post processing type
Declaration
Objective-C
+ (UIImage *_Nullable)enhanceImage:(nonnull UIImage *)image withFilter:(GSKFilterType)filter error:(NSError *_Nullable *_Nullable)error;
Swift
class func enhanceImage(_ image: UIImage, with filter: GSKFilterType) throws -> UIImage
Parameters
image
the warped, perspective-corrected document
filter
the enhancement filter to apply to the image. - see: GSKFilterType
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value
the enhanced image or nil if an error occured.
-
Corrects curvature distortion in the given image. This typically corrects curvature seen when scanning a book or when a receipt is folded.
This method is meant to be applied on a warped image.
Declaration
Objective-C
+ (UIImage *_Nullable)correctImageDistortion:(nonnull UIImage *)image error: (NSError *_Nullable *_Nullable)error;
Swift
class func correctImageDistortion(_ image: UIImage) throws -> UIImage
Parameters
image
the input image.
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value
the corrected image or nil if an error occured.