capacitor-plugin-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK for Capacitor
306 lines (293 loc) • 11.4 kB
JavaScript
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten.
/// Generated from core/schemas/ParametricFilters.yaml
import { PartiallyConstructible } from '../utils/utils';
export const OutputModeValues = ['BINARY', 'ANTIALIASED'];
export const BinarizationFilterPresetValues = [
'PRESET_1',
'PRESET_2',
'PRESET_3',
'PRESET_4',
'PRESET_5',
];
/** @internal */
export var ParametricFilter;
(function (ParametricFilter) {
/** @internal */
function From(source) {
const _type = source['_type'];
switch (_type) {
case 'ScanbotBinarizationFilter':
return new ScanbotBinarizationFilter(source);
case 'CustomBinarizationFilter':
return new CustomBinarizationFilter(source);
case 'ColorDocumentFilter':
return new ColorDocumentFilter(source);
case 'BrightnessFilter':
return new BrightnessFilter(source);
case 'ContrastFilter':
return new ContrastFilter(source);
case 'GrayscaleFilter':
return new GrayscaleFilter(source);
case 'LegacyFilter':
return new LegacyFilter(source);
case 'WhiteBlackPointFilter':
return new WhiteBlackPointFilter(source);
default:
throw `Unknown child class name: ${_type}`;
}
}
ParametricFilter.From = From;
})(ParametricFilter || (ParametricFilter = {}));
/**
Automatic binarization filter. This filter is a good starting point for most use cases.
*/
export class ScanbotBinarizationFilter extends PartiallyConstructible {
/** @param source {@displayType `DeepPartial<ScanbotBinarizationFilter>`} */
constructor(source = {}) {
super();
this._type = 'ScanbotBinarizationFilter';
/**
Output mode of the filter. BINARY will return a black and white image, GRAYSCALE will return an antialiased grayscale image.
Default is BINARY
*/
this.outputMode = 'BINARY';
if (source.outputMode !== undefined) {
this.outputMode = source.outputMode;
}
}
}
/**
Automatic binarization filter. This filter is a good starting point for most use cases.
*/
export class CustomBinarizationFilter extends PartiallyConstructible {
/** @param source {@displayType `DeepPartial<CustomBinarizationFilter>`} */
constructor(source = {}) {
super();
this._type = 'CustomBinarizationFilter';
/**
Output mode of the filter. BINARY will return a black and white image, GRAYSCALE will return an antialiased grayscale image.
Default is BINARY
*/
this.outputMode = 'BINARY';
/**
Value controlling the amount of noise removal. Value between 0 and 1.
Too little noise removal may result in a very noisy image, worsening readability.
Too much noise removal may result in the degradation of text, again, worsening readability.
Default is 0.5
*/
this.denoise = 0.5;
/**
Filter radius. The bigger the radius, the slower the filter and generally the less noise in the result.
The radius is used for both shadows removal and the calculation of local statistics in the main body of the filter.
Higher radius usually allows to cope better with regions of light text on dark background.
All the values larger than 127 are clamped to 127.
Default is 32
*/
this.radius = 32;
/**
Preset of binarization filter parameters that are found to perform well on different types of documents.
Default is PRESET_4
*/
this.preset = 'PRESET_4';
if (source.outputMode !== undefined) {
this.outputMode = source.outputMode;
}
if (source.denoise !== undefined) {
this.denoise = source.denoise;
}
if (source.radius !== undefined) {
this.radius = source.radius;
}
if (source.preset !== undefined) {
this.preset = source.preset;
}
}
}
/**
Color document filter. This filter is a good starting point for most use cases.
*/
export class ColorDocumentFilter extends PartiallyConstructible {
/** @param source {@displayType `DeepPartial<ColorDocumentFilter>`} */
constructor(source = {}) {
super();
this._type = 'ColorDocumentFilter';
}
}
/**
Brightness adjustment filter.
*/
export class BrightnessFilter extends PartiallyConstructible {
/** @param source {@displayType `DeepPartial<BrightnessFilter>`} */
constructor(source = {}) {
super();
this._type = 'BrightnessFilter';
/**
Brightness adjustment value in the range from -1 to 1. Negative values will make the image darker, positive values will make it brighter.
Default is 0.0
*/
this.brightness = 0.0;
if (source.brightness !== undefined) {
this.brightness = source.brightness;
}
}
}
/**
Contrast adjustment filter.
*/
export class ContrastFilter extends PartiallyConstructible {
/** @param source {@displayType `DeepPartial<ContrastFilter>`} */
constructor(source = {}) {
super();
this._type = 'ContrastFilter';
/**
Contrast adjustment value in the range from -1 to 254 (inclusively). Negative values will decrease the contrast, positive values will increase it.
Default is 0.0
*/
this.contrast = 0.0;
if (source.contrast !== undefined) {
this.contrast = source.contrast;
}
}
}
/**
Converts color images to grayscale and applies autocontrast.
*/
export class GrayscaleFilter extends PartiallyConstructible {
/** @param source {@displayType `DeepPartial<GrayscaleFilter>`} */
constructor(source = {}) {
super();
this._type = 'GrayscaleFilter';
/**
Ignore this fraction of pixels at the edge of the image when calculating statistics.
Pixels at the edge of the image typically have poor statistics. Ignoring them
and using only the inner pixels when calculating certain statistics can
substantially improve the quality of the result.
The value must be less than 0.5 but usually good values are between 0 and 0.15.
Default is 0.06
*/
this.borderWidthFraction = 0.06;
/**
Clip this fraction of the darkest pixels in operations such as autocontrast.
Increasing the range of middle gray levels at the expense of the brightest and darkest levels
may improve the overall contrast and quality of the result.
Sum of blackOutliersFraction and whiteOutliersFraction must be less than 1 but usually
good values for the parameters do not exceed 0.05;.
Default is 0.0
*/
this.blackOutliersFraction = 0.0;
/**
Clip this fraction of the brightest pixels in operations such as autocontrast.
Increasing the range of middle gray levels at the expense of the brightest and darkest levels
may improve the overall contrast and quality of the result.
Sum of blackOutliersFraction and whiteOutliersFraction must be less than 1 but usually
good values for the parameters do not exceed 0.05;.
Default is 0.02
*/
this.whiteOutliersFraction = 0.02;
if (source.borderWidthFraction !== undefined) {
this.borderWidthFraction = source.borderWidthFraction;
}
if (source.blackOutliersFraction !== undefined) {
this.blackOutliersFraction = source.blackOutliersFraction;
}
if (source.whiteOutliersFraction !== undefined) {
this.whiteOutliersFraction = source.whiteOutliersFraction;
}
}
}
/**
Deprecated image filters.
*/
export class LegacyFilter extends PartiallyConstructible {
/** @param source {@displayType `DeepPartial<LegacyFilter>`} */
constructor(source = {}) {
super();
this._type = 'LegacyFilter';
/**
Id of filter to be applied.
Default is 0
*/
this.filterType = 0;
if (source.filterType !== undefined) {
this.filterType = source.filterType;
}
}
static fromImageFilterType(imageFilterType) {
let imageFilterTypeAsNumber;
switch (imageFilterType) {
default:
case 'NONE':
imageFilterTypeAsNumber = 0;
break;
case 'COLOR':
imageFilterTypeAsNumber = 1;
break;
case 'GRAYSCALE':
imageFilterTypeAsNumber = 2;
break;
case 'BINARIZED':
imageFilterTypeAsNumber = 3;
break;
case 'COLOR_DOCUMENT':
imageFilterTypeAsNumber = 4;
break;
case 'PURE_BINARIZED':
imageFilterTypeAsNumber = 11;
break;
case 'BACKGROUND_CLEAN':
imageFilterTypeAsNumber = 13;
break;
case 'BLACK_AND_WHITE':
imageFilterTypeAsNumber = 14;
break;
case 'OTSU_BINARIZATION':
imageFilterTypeAsNumber = 15;
break;
case 'DEEP_BINARIZATION':
imageFilterTypeAsNumber = 16;
break;
case 'EDGE_HIGHLIGHT':
imageFilterTypeAsNumber = 17;
break;
case 'LOW_LIGHT_BINARIZATION':
imageFilterTypeAsNumber = 18;
break;
case 'LOW_LIGHT_BINARIZATION_2':
imageFilterTypeAsNumber = 19;
break;
case 'PURE_GRAY':
imageFilterTypeAsNumber = 21;
break;
}
return new LegacyFilter({ filterType: imageFilterTypeAsNumber });
}
}
/**
Maps image value channel so that all the pixels darker than the black point are set to 0,
all the pixels brighter than the white point are set to 255, and the pixels in between
are linearly scaled.
*/
export class WhiteBlackPointFilter extends PartiallyConstructible {
/** @param source {@displayType `DeepPartial<WhiteBlackPointFilter>`} */
constructor(source = {}) {
super();
this._type = 'WhiteBlackPointFilter';
/**
Fraction of the value channel range that is set to 0. The value should be in the range from 0 to 1.
Default is 0.0
*/
this.blackPoint = 0.0;
/**
Fraction of the value channel range that is not set to 255. The value should be in the range from 0 to 1.
Default is 1.0
*/
this.whitePoint = 1.0;
if (source.blackPoint !== undefined) {
this.blackPoint = source.blackPoint;
}
if (source.whitePoint !== undefined) {
this.whitePoint = source.whitePoint;
}
}
}
//# sourceMappingURL=ParametricFilters.js.map