UNPKG

react-native-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS

334 lines (300 loc) 9.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WordBox = exports.TextPatternScannerResult = exports.TextPatternScannerConfiguration = exports.SymbolBox = exports.PatternGrammarValues = exports.PatternContentValidator = exports.DefaultContentValidator = exports.ContentValidator = void 0; var _JsonSerializationTypes = require("../utils/json/JsonSerializationTypes"); var _utils = require("../utils/utils"); /// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten. /// Generated from core/schemas/TextPatternScannerTypes.yaml /** Grammar of pattern matching. - `WILDCARD`: Simple pattern matching where # stands for any digit and ? stands for any character. All other characters represent themselves. - `REGEX`: Regular expression pattern matching. Uses ECMAScript grammar. */ const PatternGrammarValues = exports.PatternGrammarValues = ['WILDCARD', 'REGEX']; /** Structure containing recognized word text and bounds. */ class WordBox extends _utils.PartiallyConstructible { /** Recognized word text. */ /** Bounding rectangle of the recognized word. */ /** Confidence of the recognition. Default is 0.0 */ recognitionConfidence = 0.0; /** @param source {@displayType `DeepPartial<WordBox>`} */ constructor(source = {}) { super(); if (source.text !== undefined) { this.text = source.text; } else { throw new Error('text must be present in constructor argument'); } if (source.boundingRect !== undefined) { this.boundingRect = { x: source.boundingRect.x, y: source.boundingRect.y, width: source.boundingRect.width, height: source.boundingRect.height }; } else { throw new Error('boundingRect must be present in constructor argument'); } if (source.recognitionConfidence !== undefined) { this.recognitionConfidence = source.recognitionConfidence; } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { text: this.text, boundingRect: this.boundingRect, recognitionConfidence: this.recognitionConfidence }; } } /** Structure containing recognized symbol text and bounds. */ exports.WordBox = WordBox; class SymbolBox extends _utils.PartiallyConstructible { /** Recognized symbol text. */ /** Bounding rectangle of the recognized symbol. */ /** Confidence of the recognition. */ /** @param source {@displayType `DeepPartial<SymbolBox>`} */ constructor(source = {}) { super(); if (source.symbol !== undefined) { this.symbol = source.symbol; } else { throw new Error('symbol must be present in constructor argument'); } if (source.boundingRect !== undefined) { this.boundingRect = { x: source.boundingRect.x, y: source.boundingRect.y, width: source.boundingRect.width, height: source.boundingRect.height }; } else { throw new Error('boundingRect must be present in constructor argument'); } if (source.recognitionConfidence !== undefined) { this.recognitionConfidence = source.recognitionConfidence; } else { throw new Error('recognitionConfidence must be present in constructor argument'); } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { symbol: this.symbol, boundingRect: this.boundingRect, recognitionConfidence: this.recognitionConfidence }; } } /** The result of the text line recognition. */ exports.SymbolBox = SymbolBox; class TextPatternScannerResult extends _utils.PartiallyConstructible { /** Raw recognized string. */ /** Boxes for each recognized word. */ /** Boxes for each recognized symbol. */ /** Confidence of the recognition. Default is 0.0 */ confidence = 0.0; /** Whether the validation was successful. Default is false */ validationSuccessful = false; /** @param source {@displayType `DeepPartial<TextPatternScannerResult>`} */ constructor(source = {}) { super(); if (source.rawText !== undefined) { this.rawText = source.rawText; } else { throw new Error('rawText must be present in constructor argument'); } if (source.wordBoxes !== undefined) { this.wordBoxes = source.wordBoxes.map(it => { return new WordBox(it); }); } else { throw new Error('wordBoxes must be present in constructor argument'); } if (source.symbolBoxes !== undefined) { this.symbolBoxes = source.symbolBoxes.map(it => { return new SymbolBox(it); }); } else { throw new Error('symbolBoxes must be present in constructor argument'); } if (source.confidence !== undefined) { this.confidence = source.confidence; } if (source.validationSuccessful !== undefined) { this.validationSuccessful = source.validationSuccessful; } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { rawText: this.rawText, wordBoxes: this.wordBoxes.map(it => { return it.serialize(config); }), symbolBoxes: this.symbolBoxes.map(it => { return it.serialize(config); }), confidence: this.confidence, validationSuccessful: this.validationSuccessful }; } } /** Base class for content validators. */ exports.TextPatternScannerResult = TextPatternScannerResult; /** @internal */ let ContentValidator = exports.ContentValidator = void 0; (function (_ContentValidator) { function From(source) { const _type = source._type; switch (_type) { case 'DefaultContentValidator': return new DefaultContentValidator(source); case 'PatternContentValidator': return new PatternContentValidator(source); default: throw `Unknown child class name: ${_type}`; } } _ContentValidator.From = From; })(ContentValidator || (exports.ContentValidator = ContentValidator = {})); /** Default content validator. Accepts only non-empty strings. */ class DefaultContentValidator extends _utils.PartiallyConstructible { _type = 'DefaultContentValidator'; /** OCR whitelist. Empty string means no restriction. Default is "" */ allowedCharacters = ''; /** @param source {@displayType `DeepPartial<DefaultContentValidator>`} */ constructor(source = {}) { super(); if (source.allowedCharacters !== undefined) { this.allowedCharacters = source.allowedCharacters; } } } /** Pattern content validator. */ exports.DefaultContentValidator = DefaultContentValidator; class PatternContentValidator extends _utils.PartiallyConstructible { _type = 'PatternContentValidator'; /** OCR whitelist. Empty string means no restriction. Default is "" */ allowedCharacters = ''; /** Pattern to match. It can be a simple pattern or a regular expression. */ /** Whether the pattern should match the whole string or just a substring. Default is false */ matchSubstring = false; /** Grammar of pattern matching. Default is WILDCARD */ patternGrammar = 'WILDCARD'; /** @param source {@displayType `DeepPartial<PatternContentValidator>`} */ constructor(source = {}) { super(); if (source.allowedCharacters !== undefined) { this.allowedCharacters = source.allowedCharacters; } if (source.pattern !== undefined) { this.pattern = source.pattern; } else { throw new Error('pattern must be present in constructor argument'); } if (source.matchSubstring !== undefined) { this.matchSubstring = source.matchSubstring; } if (source.patternGrammar !== undefined) { this.patternGrammar = source.patternGrammar; } } } /** Configuration for the text pattern scanner. */ exports.PatternContentValidator = PatternContentValidator; class TextPatternScannerConfiguration extends _utils.PartiallyConstructible { /** Maximum image size (height or width) for OCR process. 0 - do not rescale. Default is 0 */ ocrResolutionLimit = 0; /** Maximum number of accumulated frames to inspect before actual result is returned. Default is 3 */ maximumNumberOfAccumulatedFrames = 3; /** Minimum number of accumulated frames that have equal result. Default is 2 */ minimumNumberOfRequiredFramesWithEqualScanningResult = 2; /** Content validator. */ validator = new DefaultContentValidator({}); /** @param source {@displayType `DeepPartial<TextPatternScannerConfiguration>`} */ constructor(source = {}) { super(); if (source.ocrResolutionLimit !== undefined) { this.ocrResolutionLimit = source.ocrResolutionLimit; } if (source.maximumNumberOfAccumulatedFrames !== undefined) { this.maximumNumberOfAccumulatedFrames = source.maximumNumberOfAccumulatedFrames; } if (source.minimumNumberOfRequiredFramesWithEqualScanningResult !== undefined) { this.minimumNumberOfRequiredFramesWithEqualScanningResult = source.minimumNumberOfRequiredFramesWithEqualScanningResult; } if (source.validator !== undefined) { this.validator = ContentValidator.From(source.validator); } } } exports.TextPatternScannerConfiguration = TextPatternScannerConfiguration; //# sourceMappingURL=TextPatternScannerTypes.js.map