Document Scanner Cordova Plugin

Document Scanner Cordova Plugin

Plugin for live document detection and auto cropping, returns either a URI or a base64 encoded string of the captured image.

Supported platforms
  • Android. Min SDK = 24, Target SDK = 30.

Usage

DocScannerPlugin.scan(successCallback, errorCallback, options)

Parameters

  • {function} success - callback function called when an image has been scanned successfully. Returns image URI or image as base64 depending on the options passed in;
  • {function} error - callback function called when an error occurs. It returns the error message as a string;
  • {object} options - options for document scanner;

Properties

PropDefaultTypeDescription
overlayColorrgba(66,165,245, 0.7)stringColor of the detected rectangle. See supported colors below.
borderColorrgba(66,165,245, 0.7)stringColor color of the borders of detected rectangle. See supported colors below.
detectionCountBeforeCapture15integerNumber of correct rectangle to detect before capture
enableTorchfalseboolAllows to active or deactivate flash during document detection
brightness10floatIncrease or decrease image brightness.Recommended values [0-100]
contrast1floatIncrease or decrease image contrast. Recommended values [1.0-3.0]
useBase64falseboolIf base64 representation should be passed instead of image uri's
captureMultiplefalseboolKeeps the scanner on after a successful capture

Sample options JSON

All properties are optional

{
  "overlayColor": "rgba(66,165,245, 0.7)",
  "borderColor": "rgba(66,165,245, 0.7)",
  "detectionCountBeforeCapture": 15,
  "enableTorch": false,
  "brightness": 10,
  "contrast": 1,
  "useBase64": true,
  "captureMultiple": true
}

Supported overlay colors

#RRGGBB, #AARRGGBB, rgba(RRR, GGG, BBB, A.A)

The following names are also accepted:
red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray, darkgray, grey,
lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy, olive, purple, silver, teal.

Contrast and brightness OpenCV transformation

For contrast and brightness adjustment, plugin use OpenCV Mat.convertTo() function

For additional information, please see the link