GSKDocumentProcessor

@interface GSKDocumentProcessor : NSObject

The document processor is the central class of the GSSDK’s image processing algorithms.

With the document processor, you can correct the distortion in your documents, as well as improve their legibility. If you are only interested in the detecting a document in an image, please refer to GSKDocumentDetector.

  • This is the main SDK method and we recommend using this one. By combining multiple operations, it can achieve better performance.

    @returns The result of the processing, nil if there is an error. The results includes the parameters that have been selected for the different processing steps, as well as the temporary path were the output was written. The output is written in a temporary folder. The caller can take ownership of this file. By default, the best output format will be chosen by this method. For instance, if the monochrome enhancement was selected, the output will not be saved as JPEG but as a 1-bit PNG image. The result’s processedImagePath file extension will reflect this.

    Declaration

    Objective-C

    - (GSKProcessingResult *_Nullable)
                              processImage:(UIImage *_Nonnull)image
        perspectiveCorrectionConfiguration:
            (GSKPerspectiveCorrectionConfiguration *_Nonnull)
                perspectiveCorrectionConfiguration
          curvatureCorrectionConfiguration:
              (GSKCurvatureCorrectionConfiguration *_Nonnull)
                  curvatureCorrectionConfiguration
                  enhancementConfiguration:
                      (GSKEnhancementConfiguration *_Nonnull)filterConfiguration
                     rotationConfiguration:
                         (GSKRotationConfiguration *_Nullable)rotationConfiguration
                       outputConfiguration:
                           (nonnull GSKOutputConfiguration *)outputConfiguration
                                     error:(NSError *_Nullable *_Nullable)error;

    Swift

    func processImage(_ image: UIImage, perspectiveCorrectionConfiguration: GSKPerspectiveCorrectionConfiguration, curvatureCorrectionConfiguration: GSKCurvatureCorrectionConfiguration, enhancementConfiguration filterConfiguration: GSKEnhancementConfiguration, rotationConfiguration: GSKRotationConfiguration?, outputConfiguration: GSKOutputConfiguration) throws -> GSKProcessingResult

    Parameters

    perspectiveCorrectionConfiguration

    Specify how to correct perspective distortions present in the scan (such as when the scan was taken with an angle)

    curvatureCorrectionConfiguration

    Specify how to correct curvature distortions present in the scan (such as a bent book)

    filterConfiguration

    The enhancement configuration. This includes the filters enhancing the legibility of the document.

    rotationConfiguration

    The rotation configuration. The rotation will be applied after all the other processing.

    outputConfiguration

    Configures the output format of the processing.

  • Downscale the image at the given path and stores the result in a temporary file.

    Note: this method will never upscale the image. If the image doesn’t need downscaling, it will return a copy of the file.

    Declaration

    Objective-C

    - (GSKResizeResult *_Nullable)
          resizeImageAtPath:(NSString *_Nonnull)imagePath
        resizeConfiguration:(GSKResizeConfiguration *_Nonnull)resizeConfiguration
        outputConfiguration:(GSKOutputConfiguration *_Nonnull)outputConfiguration
                      error:(NSError *_Nullable *_Nullable)error;

    Swift

    func resizeImage(atPath imagePath: String, resizeConfiguration: GSKResizeConfiguration, outputConfiguration: GSKOutputConfiguration) throws -> GSKResizeResult