GSKDocumentDetector

@interface GSKDocumentDetector : NSObject
  • Performance: A document detector can be expensive to create: it’s recommended to keep a reference to it if it’s needed several times in a row.
  • 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

    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.

  • 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

    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.