Skip to main content

Page Processing | Android Document Scanner

Scanbot SDK provides a set of processing operations which can be performed directly on io.scanbot.sdk.persistence.Page objects. All these operations are collected in io.scanbot.sdk.docprocessing.PageProcessor class.

val pageProcessor = ScanbotSDK(context).createPageProcessor()

Operations overview#

  • applyFilter(page: Page, filter: ImageFilterType): Page - Applies an image filter on the provided page based on the existing unfiltered document image. The filtered image result will be stored as a document image of the page. The current document image of the page will be overwritten. The original image of the page will not be modified. More info about ImageFilterType can be found here.

Example:

val pageProcessor = ScanbotSDK(context).createPageProcessor()
val binarizedPage: Page = pageProcessor.applyFilter(yourPage, ImageFilterType.DEEP_BINARIZATION)
  • applyFilterTunes(page: Page, filter: ImageFilterType, tunes: List<TuneOperation>, filterOrder: Int): Page - a more advanced version of applyFilter method. It performs the same filtering process, but additionally applies a list of TuneOperation. filterOrder - the position of the tune after which the filter should be applied. More info about TuneOperation can be found here.

  • generateFilteredPreview(page: Page, filter: ImageFilterType): Bitmap - generates a filtered preview image based on the unfiltered document preview image and caches it in the file system.

  • generateFilteredPreview(page: Page, filter: ImageFilterType, tunes: List<TuneOperation>, filterOrder: Int): Bitmap - generates a filtered and tuned preview image based on the unfiltered document preview image and caches it in the file system.

  • detectDocument(page: Page): Page - performs document detection on the original image of the provided page. The page must contain the original image. Creates and stores the document (cropped) image file based on the document detection result (polygon) and optionally defined filter in the page object. If the source Page contains some filter (page.filter) or tunes (page.tunes) options they will be applied. page - existing page with the original image. Returns a new Page instance with updated fields Page.polygon and Page.detectionStatus. More info about Document Detection can be found here

  • rotate(page: Page, times: Int): Page - rotates all images (and previews) of the given Page X times. The original image is required, other images (document, unfiltered document) are optional. The direction of rotation is counterclockwise if the times value is positive and clockwise if times value is negative (e.g. -2 = rotates 2 times to the right).

  • cropAndRotate(page: Page, times: Int, polygon: List<PointF>): Page - crops the polygon from the original image and rotates all images (and previews) of the given Page X times. The original image is required, other images (document, unfiltered document) are optional. If the source Page contains some filter (page.filter) or tunes (page.tunes) options they will be applied. The direction of rotation is counterclockwise if the times value is positive and clockwise if times value is negative (e.g. -2 = rotates 2 times to the right).