UNPKG

react-native-scanbot-sdk

Version:

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

171 lines (166 loc) 6.65 kB
import { AspectRatio } from '../common/Common'; import { CameraModule } from '../common/CameraConfiguration'; import { CameraPreviewMode } from '../common/Common'; import { DeepPartial, PartiallyConstructible } from '../../utils'; /** Determines the prioritization of still image quality and capturing speed. - `SPEED`: Captures a still image at the highest possible speed. The quality of the image may be degraded. - `BALANCED`: Balances capturing speed and image quality equally. This is the default value. - `QUALITY`: Captures a still image with the best possible quality in terms of noise, frozen motion and detail in low light. The speed of the capturing might be reduced. */ export type CapturePhotoQualityPrioritization = 'SPEED' | 'BALANCED' | 'QUALITY'; /** Configuration of the camera behavior. */ export class DocumentScannerCameraConfiguration extends PartiallyConstructible { /** Determines which camera module to use on start-up. Default is BACK */ public cameraModule: CameraModule = 'BACK'; /** The default zoom factor on start-up. Default is 1.0 */ public defaultZoomFactor: number = 1.0; /** Determines whether the document should be cropped automatically after a manual snap or not. Default is true */ public autoCropOnManualSnap: boolean = true; /** Determines whether the flashlight is enabled or not on start-up. Default is false */ public flashEnabled: boolean = false; /** Determines whether locking the focus at the minimum possible distance is enabled or not (device-specific). Default is false */ public minFocusDistanceLock: boolean = false; /** Determines whether touch-to-focus is enabled or not. Android only. Default is false */ public touchToFocusEnabled: boolean = false; /** Determines whether pinch-to-zoom is enabled or not. Default is true */ public pinchToZoomEnabled: boolean = true; /** Determines which camera preview mode to use. Default is FILL_IN */ public cameraPreviewMode: CameraPreviewMode = 'FILL_IN'; /** Determines the prioritization of still image quality and capturing speed. Default is BALANCED */ public captureQualityPrioritization: CapturePhotoQualityPrioritization = 'BALANCED'; /** The minimum pitch/skew angle of the document to be accepted. The value must be between 0.0 and 1.0. Default is 0.75 */ public acceptedAngleScore: number = 0.75; /** The minimum size of the document in relation to the screen preview to be accepted. The value must be between 0.0 and 1.0. Default is 0.75 */ public acceptedSizeScore: number = 0.75; /** Controls the auto snapping speed. The sensitivity must be between 0.0 and 1.0. A value of 1.0 triggers auto snapping immediately, while a value of 0.0 delays the auto snapping by 3 seconds. The default value is 0.66 (1 second). Default is 0.66 */ public autoSnappingSensitivity: number = 0.66; /** After a page has been snapped, the delay in milliseconds before auto snapping resumes for the next page. Default is 200 */ public autoSnappingDelay: number = 200; /** The minimum brightness value to accept a detected document. Default is 50 */ public acceptedBrightnessThreshold: number = 50; /** Determines if auto snapping is enabled or not. Default is true */ public autoSnappingEnabled: boolean = true; /** The required aspect ratios for the document to be accepted. */ public requiredAspectRatios: AspectRatio[] = []; /** Determines whether a landscape document will be detected when the camera is in portrait mode (and vice versa) or not. This parameter will be ignored if required aspect ratios have been explicitly defined. Default is true */ public ignoreBadAspectRatio: boolean = true; /** When enabled the hardware volume up/down buttons can be used to capture an image if manual snapping is enabled. For iOS version 17.2 or later is required. On iPhones with camera control (iPhone 16 series) this also enables zooming and capturing with the camera control. Default is true */ public captureWithHardwareButtonsEnabled: boolean = true; /** @param source {@displayType `DeepPartial<DocumentScannerCameraConfiguration>`} */ public constructor(source: DeepPartial<DocumentScannerCameraConfiguration> = {}) { super(); if (source.cameraModule !== undefined) { this.cameraModule = source.cameraModule; } if (source.defaultZoomFactor !== undefined) { this.defaultZoomFactor = source.defaultZoomFactor; } if (source.autoCropOnManualSnap !== undefined) { this.autoCropOnManualSnap = source.autoCropOnManualSnap; } if (source.flashEnabled !== undefined) { this.flashEnabled = source.flashEnabled; } if (source.minFocusDistanceLock !== undefined) { this.minFocusDistanceLock = source.minFocusDistanceLock; } if (source.touchToFocusEnabled !== undefined) { this.touchToFocusEnabled = source.touchToFocusEnabled; } if (source.pinchToZoomEnabled !== undefined) { this.pinchToZoomEnabled = source.pinchToZoomEnabled; } if (source.cameraPreviewMode !== undefined) { this.cameraPreviewMode = source.cameraPreviewMode; } if (source.captureQualityPrioritization !== undefined) { this.captureQualityPrioritization = source.captureQualityPrioritization; } if (source.acceptedAngleScore !== undefined) { this.acceptedAngleScore = source.acceptedAngleScore; } if (source.acceptedSizeScore !== undefined) { this.acceptedSizeScore = source.acceptedSizeScore; } if (source.autoSnappingSensitivity !== undefined) { this.autoSnappingSensitivity = source.autoSnappingSensitivity; } if (source.autoSnappingDelay !== undefined) { this.autoSnappingDelay = source.autoSnappingDelay; } if (source.acceptedBrightnessThreshold !== undefined) { this.acceptedBrightnessThreshold = source.acceptedBrightnessThreshold; } if (source.autoSnappingEnabled !== undefined) { this.autoSnappingEnabled = source.autoSnappingEnabled; } if (source.requiredAspectRatios !== undefined) { this.requiredAspectRatios = source.requiredAspectRatios.map((it) => new AspectRatio(it)); } if (source.ignoreBadAspectRatio !== undefined) { this.ignoreBadAspectRatio = source.ignoreBadAspectRatio; } if (source.captureWithHardwareButtonsEnabled !== undefined) { this.captureWithHardwareButtonsEnabled = source.captureWithHardwareButtonsEnabled; } } }