UNPKG

react-native-scanbot-sdk

Version:

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

563 lines (504 loc) 16.7 kB
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten. /// Generated from core/schemas/ImageRefTypes.yaml import { ImageRotation } from '../imageRef/ImageTypes'; import { RefCountedObjectProfile } from '../imageRef/ObjectPoolTypes'; import { ToJsonConfiguration } from '../utils/json/JsonSerializationTypes'; import { DeepPartial, PartiallyConstructible, Rectangle } from '../utils/utils'; /** Image Info. */ export class ImageInfo extends PartiallyConstructible { /** Image height in pixels. */ public height: number; /** Image width in pixels. */ public width: number; /** Byte size of the non-hibernating image. */ public maxByteSize: number; /** @param source {@displayType `DeepPartial<ImageInfo>`} */ public constructor(source: DeepPartial<ImageInfo> = {}) { super(); if (source.height !== undefined) { this.height = source.height; } else { throw new Error('height must be present in constructor argument'); } if (source.width !== undefined) { this.width = source.width; } else { throw new Error('width must be present in constructor argument'); } if (source.maxByteSize !== undefined) { this.maxByteSize = source.maxByteSize; } else { throw new Error('maxByteSize must be present in constructor argument'); } } public serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): DeepPartial<ImageInfo> { return { height: this.height, width: this.width, maxByteSize: this.maxByteSize, }; } } /** Image Ref Path Load Mode. - `EAGER`: Image is immediately loaded into memory. - `LAZY`: Image is loaded into memory the first time it's requested. Specified path must exist at the time of loading. - `LAZY_WITH_COPY`: Image is loaded into memory the first time it's requested. Specified path is copied into internal directory and so isn't required to exist at the time of loading. */ export type PathLoadMode = 'EAGER' | 'LAZY' | 'LAZY_WITH_COPY'; export const PathLoadModeValues: PathLoadMode[] = ['EAGER', 'LAZY', 'LAZY_WITH_COPY']; /** Image Ref Buffer Load Mode. - `EAGER`: Image is immediately decoded. - `LAZY`: Image is decoded the first time it's requested. */ export type BufferLoadMode = 'EAGER' | 'LAZY'; export const BufferLoadModeValues: BufferLoadMode[] = ['EAGER', 'LAZY']; /** Image Encoding Format. - `JPEG`: JPEG encoding. - `PNG`: PNG encoding. */ export type EncodingFormat = 'JPEG' | 'PNG'; export const EncodingFormatValues: EncodingFormat[] = ['JPEG', 'PNG']; /** Encryption/Decryption mode to be used when an image is loaded/saved. - `REQUIRED`: Encryption/Decryption is used when loading/saving an image. A crypting provider must first be set using `ImageRef.setStorageCryptingProvider`. If no provider is set, the loading/saving operation will fail. - `DISABLED`: Encryption/Decryption is not used when loading/saving an image. - `IF_AVAILABLE`: Encryption/Decryption is used when loading/saving an image if a crypting provider is set using `ImageRef.setStorageCryptingProvider`. */ export type EncryptionMode = 'REQUIRED' | 'DISABLED' | 'IF_AVAILABLE'; export const EncryptionModeValues: EncryptionMode[] = ['REQUIRED', 'DISABLED', 'IF_AVAILABLE']; /** Basic options for loading image. */ export class BasicImageLoadOptions extends PartiallyConstructible { /** Region of interest. */ public roi: Rectangle = { x: 0, y: 0, width: 0, height: 0 }; /** @param source {@displayType `DeepPartial<BasicImageLoadOptions>`} */ public constructor(source: DeepPartial<BasicImageLoadOptions> = {}) { super(); if (source.roi !== undefined) { this.roi = { x: source.roi.x, y: source.roi.y, width: source.roi.width, height: source.roi.height, }; } } } /** Options for loading images that come from sensor. */ export class RawImageLoadOptions extends PartiallyConstructible { /** Region of interest. */ public roi: Rectangle = { x: 0, y: 0, width: 0, height: 0 }; /** Rotation that should be applied to the image to recover correct orientation. Default is NONE */ public orientation: ImageRotation = 'NONE'; /** @param source {@displayType `DeepPartial<RawImageLoadOptions>`} */ public constructor(source: DeepPartial<RawImageLoadOptions> = {}) { super(); if (source.roi !== undefined) { this.roi = { x: source.roi.x, y: source.roi.y, width: source.roi.width, height: source.roi.height, }; } if (source.orientation !== undefined) { this.orientation = source.orientation; } } } /** Options for loading image from path. */ export class PathImageLoadOptions extends PartiallyConstructible { /** Region of interest. */ public roi: Rectangle = { x: 0, y: 0, width: 0, height: 0 }; /** Load mode. Default is EAGER */ public loadMode: PathLoadMode = 'EAGER'; /** Encryption mode. Default is IF_AVAILABLE */ public encryptionMode: EncryptionMode = 'IF_AVAILABLE'; /** @param source {@displayType `DeepPartial<PathImageLoadOptions>`} */ public constructor(source: DeepPartial<PathImageLoadOptions> = {}) { super(); if (source.roi !== undefined) { this.roi = { x: source.roi.x, y: source.roi.y, width: source.roi.width, height: source.roi.height, }; } if (source.loadMode !== undefined) { this.loadMode = source.loadMode; } if (source.encryptionMode !== undefined) { this.encryptionMode = source.encryptionMode; } } } /** Options for loading image from buffer. */ export class BufferImageLoadOptions extends PartiallyConstructible { /** Region of interest. */ public roi: Rectangle = { x: 0, y: 0, width: 0, height: 0 }; /** Load mode. Default is EAGER */ public loadMode: BufferLoadMode = 'EAGER'; /** @param source {@displayType `DeepPartial<BufferImageLoadOptions>`} */ public constructor(source: DeepPartial<BufferImageLoadOptions> = {}) { super(); if (source.roi !== undefined) { this.roi = { x: source.roi.x, y: source.roi.y, width: source.roi.width, height: source.roi.height, }; } if (source.loadMode !== undefined) { this.loadMode = source.loadMode; } } } /** Options for saving image to a path. */ export class SaveImageOptions extends PartiallyConstructible { /** Quality parameter is for jpeg only and is in range 0 to 100. If -1, then settings from hibernation are used. In case when the Image Ref was created with a lazy load mode and originally has the same format as the requested to save, then setting quality to -1 leads to simply copying from source to destination, which is time efficient and prevents quality loss caused by jpeg encoding/decoding. Default is -1 */ public quality: number = -1; /** Encryption mode. Default is IF_AVAILABLE */ public encryptionMode: EncryptionMode = 'IF_AVAILABLE'; /** @param source {@displayType `DeepPartial<SaveImageOptions>`} */ public constructor(source: DeepPartial<SaveImageOptions> = {}) { super(); if (source.quality !== undefined) { this.quality = source.quality; } if (source.encryptionMode !== undefined) { this.encryptionMode = source.encryptionMode; } } } /** Options for encoding image. */ export class EncodeImageOptions extends PartiallyConstructible { /** Quality parameter is for jpeg only and is in range 0 to 100. If -1, then settings from hibernation are used. In case when the Image Ref was created with a lazy load mode and originally has the same format as the requested to save, then setting quality to -1 leads to simply copying from source to destination, which is time efficient and prevents quality loss caused by jpeg encoding/decoding. Default is -1 */ public quality: number = -1; /** Image format. Default is JPEG */ public format: EncodingFormat = 'JPEG'; /** @param source {@displayType `DeepPartial<EncodeImageOptions>`} */ public constructor(source: DeepPartial<EncodeImageOptions> = {}) { super(); if (source.quality !== undefined) { this.quality = source.quality; } if (source.format !== undefined) { this.format = source.format; } } } /** The type of source which originated the underlying image. - `API`: ImageRef was created by a call to an SDK feature, such as a scanner, image processor, etc. - `PLATFORM_IMAGE`: ImageRef was created from a platform image, e.g. Bitmap on Android, UIImage on iOS. - `CAMERA`: ImageRef was created from data from the camera. - `FILE`: ImageRef was created from a file. - `BUFFER`: ImageRef was created from an encoded buffer. - `OTHER`: ImageRef was created from another type, e.g. from custom loader. */ export type ImageSourceType = 'API' | 'PLATFORM_IMAGE' | 'CAMERA' | 'FILE' | 'BUFFER' | 'OTHER'; export const ImageSourceTypeValues: ImageSourceType[] = [ 'API', 'PLATFORM_IMAGE', 'CAMERA', 'FILE', 'BUFFER', 'OTHER', ]; /** Description of source from which the ImageRef was created. */ export class ImageSource extends PartiallyConstructible { /** Source type from which the ImageRef was created. */ public type: ImageSourceType; /** File from which the ImageRef was created. Non-null only if the image ref was created from file. */ public filePath: string | null; /** @param source {@displayType `DeepPartial<ImageSource>`} */ public constructor(source: DeepPartial<ImageSource> = {}) { super(); if (source.type !== undefined) { this.type = source.type; } else { throw new Error('type must be present in constructor argument'); } if (source.filePath !== undefined) { this.filePath = source.filePath != null ? source.filePath : null; } else { throw new Error('filePath must be present in constructor argument'); } } public serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): DeepPartial<ImageSource> { return { type: this.type, filePath: this.filePath != null ? this.filePath : null, }; } } /** ImageRef profile part specific to image information. */ export class ImageProfile extends PartiallyConstructible { /** Memory consumption of a memory-backed bitmap. Zero, if the image is hibernating. Default is 0 */ public bitmapMemoryConsumption: number = 0; /** Memory consumption of the hibernation buffer. Zero, if the image is not hibernating, or is hibernated to a file. Default is 0 */ public hibernationMemoryConsumption: number = 0; /** @param source {@displayType `DeepPartial<ImageProfile>`} */ public constructor(source: DeepPartial<ImageProfile> = {}) { super(); if (source.bitmapMemoryConsumption !== undefined) { this.bitmapMemoryConsumption = source.bitmapMemoryConsumption; } if (source.hibernationMemoryConsumption !== undefined) { this.hibernationMemoryConsumption = source.hibernationMemoryConsumption; } } public serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): DeepPartial<ImageProfile> { return { bitmapMemoryConsumption: this.bitmapMemoryConsumption, hibernationMemoryConsumption: this.hibernationMemoryConsumption, }; } } /** ImageRef profile which provides detailed information about stored object. */ export class ImageRefProfile extends PartiallyConstructible { /** Information about the strong and serialized references to the image. */ public refInfo: RefCountedObjectProfile; /** Image-specific information, e.g. memory consumption. */ public imageInfo: ImageProfile; /** Description of source from which the ImageRef was created. Non-null only if detailed profiling has been previously enabled by a call to enableDetailedProfiling. */ public imageSource: ImageSource | null; /** @param source {@displayType `DeepPartial<ImageRefProfile>`} */ public constructor(source: DeepPartial<ImageRefProfile> = {}) { super(); if (source.refInfo !== undefined) { this.refInfo = new RefCountedObjectProfile(source.refInfo); } else { throw new Error('refInfo must be present in constructor argument'); } if (source.imageInfo !== undefined) { this.imageInfo = new ImageProfile(source.imageInfo); } else { throw new Error('imageInfo must be present in constructor argument'); } if (source.imageSource !== undefined) { this.imageSource = source.imageSource != null ? new ImageSource(source.imageSource) : null; } else { throw new Error('imageSource must be present in constructor argument'); } } public serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): DeepPartial<ImageRefProfile> { return { refInfo: this.refInfo.serialize(config), imageInfo: this.imageInfo.serialize(config), imageSource: this.imageSource != null ? this.imageSource.serialize(config) : null, }; } } /** Snapshot of all alive ImageRefs. */ export class ImageRefPoolSnapshot extends PartiallyConstructible { /** Detailed profiles of all alive ImageRefs. */ public imageRefProfiles: ImageRefProfile[]; /** Estimation of total memory consumption of ImageRefs. Default is 0 */ public totalMemoryConsumption: number = 0; /** @param source {@displayType `DeepPartial<ImageRefPoolSnapshot>`} */ public constructor(source: DeepPartial<ImageRefPoolSnapshot> = {}) { super(); if (source.imageRefProfiles !== undefined) { this.imageRefProfiles = source.imageRefProfiles.map((it: any) => { return new ImageRefProfile(it); }); } else { throw new Error('imageRefProfiles must be present in constructor argument'); } if (source.totalMemoryConsumption !== undefined) { this.totalMemoryConsumption = source.totalMemoryConsumption; } } public serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): DeepPartial<ImageRefPoolSnapshot> { return { imageRefProfiles: this.imageRefProfiles.map((it: any) => { return it.serialize(config); }), totalMemoryConsumption: this.totalMemoryConsumption, }; } } /** difference between two snapshots. */ export class ImageRefPoolSnapshotsDiff extends PartiallyConstructible { /** Difference between total memory consumption in two snapshots. Default is 0 */ public totalMemoryConsumptionDiff: number = 0; /** Unique ids of ImageRefs that are not present in the second snapshot and present in the first snapshot. */ public removed: string[]; /** Profiles of ImageRefs that are present in the second snapshot, but not in the first snapshot. */ public added: string[]; /** Profiles of ImageRefs that are present in both snapshots but are different. Profile is considered modified if number of references or memory consumption is different. */ public modified: string[]; /** @param source {@displayType `DeepPartial<ImageRefPoolSnapshotsDiff>`} */ public constructor(source: DeepPartial<ImageRefPoolSnapshotsDiff> = {}) { super(); if (source.totalMemoryConsumptionDiff !== undefined) { this.totalMemoryConsumptionDiff = source.totalMemoryConsumptionDiff; } if (source.removed !== undefined) { this.removed = source.removed.map((it: any) => { return it; }); } else { throw new Error('removed must be present in constructor argument'); } if (source.added !== undefined) { this.added = source.added.map((it: any) => { return it; }); } else { throw new Error('added must be present in constructor argument'); } if (source.modified !== undefined) { this.modified = source.modified.map((it: any) => { return it; }); } else { throw new Error('modified must be present in constructor argument'); } } public serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): DeepPartial<ImageRefPoolSnapshotsDiff> { return { totalMemoryConsumptionDiff: this.totalMemoryConsumptionDiff, removed: this.removed.map((it: any) => { return it; }), added: this.added.map((it: any) => { return it; }), modified: this.modified.map((it: any) => { return it; }), }; } }