API for document enhancement.

Required licence feature(s): DocumentScanner, ImageProcessing.

Methods

  • Frees up any resources associated with this object. No other methods may be called on this object after destroy has been called.

    Returns Promise<void>

  • Straightens the document effectively straightening its edges and text.

    Parameters

    • image: Image

      The image of the document to straighten.

    • Optional parameters: {
          aspectRatios?: ({ readonly width?: number; readonly height?: number; })[];
          straighteningMode?: DocumentStraighteningMode;
      }

      The parameters to use for straightening.

      • Optional aspectRatios?: ({ readonly width?: number; readonly height?: number; })[]

        By default, aspect ratio of the straightened document is automatically determined based on the detected document corners. If the document is significantly deformed, the estimated aspect ratio may be inaccurate. In such cases, providing a list of expected aspect ratios may help improve the accuracy of the straightening. The closest matching aspect ratio from the list will be used. Note, that if for a given paper format you want to support both portrait and landscape orientations, you need to provide both aspect ratios (e.g. 1:√2 and √2:1 for A series papers).

        Default Value

        [];
        
      • Optional straighteningMode?: DocumentStraighteningMode

        Type of document straightening to apply.

        Default Value

        "STRAIGHTEN";
        
    • Optional priorCornersNormalized: Point[]

      If it is known where the document corners (e.g. from a prior detection), those can be provided here. The enhancer may take them into account to locate the document more accurately. As part of the straightening process, it may be necessary to detect the document corners. That's why providing them here can speed up the process (given the corners are already available). Corners must be provided in the clockwise order: top-left, top-right, bottom-right, bottom-left. The coordinates must be normalized to the range [0, 1] relative to the image dimensions. For x coordinates, 0 corresponds to the left edge of the image and 1 to the right edge. For y coordinates, 0 corresponds to the top edge of the image and 1 to the bottom edge. Note, that when a coordinate is normalized, correct formula for x coordinate is: x_normalized = x_pixel / (image_width - 1), and for y coordinate is: y_normalized = y_pixel / (image_height - 1).

    • Optional consumeImage: Config.ConsumeType

      Controls if the image can still be used after calling this method, or if it will be consumed by the method. See ConsumeType for more details.

    Returns Promise<DocumentEnhancerStraightenResponse>

    The detection result.

  • Parameters

    Returns Promise<boolean>

Generated using TypeDoc