dynamsoft-barcode-reader-bundle 11.0.3000 → 11.0.6000

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -134,6 +134,7 @@ declare enum EnumErrorCode {
134
134
  EC_PDF_LICENSE_NOT_FOUND = -10079,
135
135
  /**The rectangle is invalid.*/
136
136
  EC_RECT_INVALID = -10080,
137
+ EC_TEMPLATE_VERSION_INCOMPATIBLE = -10081,
137
138
  /** Indicates no license is available or the license is not set. */
138
139
  EC_NO_LICENSE = -20000,
139
140
  /** Encountered failures while attempting to read or write to the license buffer. */
@@ -148,6 +149,13 @@ declare enum EnumErrorCode {
148
149
  EC_INSTANCE_COUNT_OVER_LIMIT = -20008,
149
150
  /** Indicates the license in use is a trial version with limited functionality or usage time. */
150
151
  EC_TRIAL_LICENSE = -20010,
152
+ /**The license is not valid for current version*/
153
+ EC_LICENSE_VERSION_NOT_MATCH = -20011,
154
+ /**Online license validation failed due to network issues.Using cached license information for validation.*/
155
+ EC_LICENSE_CACHE_USED = -20012,
156
+ EC_LICENSE_AUTH_QUOTA_EXCEEDED = -20013,
157
+ /**License restriction: the number of results has exceeded the allowed limit.*/
158
+ EC_LICENSE_RESULTS_LIMIT_EXCEEDED = -20014,
151
159
  /** The specified barcode format is invalid or unsupported. */
152
160
  EC_BARCODE_FORMAT_INVALID = -30009,
153
161
  /** The specified custom module size for barcode generation is invalid or outside acceptable limits. */
@@ -987,6 +995,11 @@ interface CapturedResultBase {
987
995
  readonly originalImageTag: ImageTag;
988
996
  }
989
997
 
998
+ interface ErrorInfo {
999
+ errorCode: EnumErrorCode;
1000
+ errorString: string;
1001
+ }
1002
+
990
1003
  declare abstract class ImageSourceAdapter {
991
1004
  #private;
992
1005
  /**
@@ -1215,7 +1228,9 @@ declare const productNameMap: {
1215
1228
  readonly dcvBundle: "dynamsoft-capture-vision-bundle";
1216
1229
  };
1217
1230
 
1218
- export { Arc, BinaryImageUnit, CapturedResultBase, CapturedResultItem, ColourImageUnit, Contour, ContoursUnit, CoreModule, Corner, DSFile, DSImageData, DSRect, DwtInfo, Edge, EngineResourcePaths, EnhancedGrayscaleImageUnit, EnumBufferOverflowProtectionMode, EnumCapturedResultItemType, EnumColourChannelUsageType, EnumCornerType, EnumCrossVerificationStatus, EnumErrorCode, EnumGrayscaleEnhancementMode, EnumGrayscaleTransformationMode, EnumImageCaptureDistanceMode, EnumImageFileFormat, EnumImagePixelFormat, EnumImageTagType, EnumIntermediateResultUnitType, EnumModuleName, EnumPDFReadingMode, EnumRasterDataSource, EnumRegionObjectElementType, EnumSectionType, EnumTransformMatrixType, FileImageTag, GrayscaleImageUnit, ImageSourceAdapter, ImageSourceErrorListener, ImageTag, InnerVersions, IntermediateResult, IntermediateResultExtraInfo, IntermediateResultUnit, LineSegment, LineSegmentsUnit, MapController, MimeType, ObservationParameters, OriginalImageResultItem, PDFReadingParameter, PathInfo, Point, Polygon, PostMessageBody, PredetectedRegionElement, PredetectedRegionsUnit, Quadrilateral, Rect, RegionObjectElement, ScaledColourImageUnit, ShortLinesUnit, TextRemovedBinaryImageUnit, TextZone, TextZonesUnit, TextureDetectionResultUnit, TextureRemovedBinaryImageUnit, TextureRemovedGrayscaleImageUnit, TransformedGrayscaleImageUnit, Warning, WasmVersions, WorkerAutoResources, _getNorImageData, _saveToFile, _toBlob, _toCanvas, _toImage, bDebug, checkIsLink, compareVersion, doOrWaitAsyncDependency, getNextTaskID, handleEngineResourcePaths, innerVersions, isArc, isContour, isDSImageData, isDSRect, isImageTag, isLineSegment, isObject, isOriginalDsImageData, isPoint, isPolygon, isQuad, isRect, isSimdSupported, mapAsyncDependency, mapPackageRegister, mapTaskCallBack, onLog, productNameMap, requestResource, setBDebug, setOnLog, waitAsyncDependency, worker, workerAutoResources };
1231
+ export { Arc, BinaryImageUnit, CapturedResultBase, CapturedResultItem, ColourImageUnit, Contour, ContoursUnit, CoreModule, Corner, DSFile, DSImageData, DSRect, DwtInfo, Edge, EngineResourcePaths, EnhancedGrayscaleImageUnit, EnumBufferOverflowProtectionMode, EnumCapturedResultItemType, EnumColourChannelUsageType, EnumCornerType, EnumCrossVerificationStatus, EnumErrorCode, EnumGrayscaleEnhancementMode, EnumGrayscaleTransformationMode, EnumImageCaptureDistanceMode, EnumImageFileFormat, EnumImagePixelFormat, EnumImageTagType, EnumIntermediateResultUnitType, EnumModuleName, EnumPDFReadingMode, EnumRasterDataSource, EnumRegionObjectElementType, EnumSectionType, EnumTransformMatrixType, ErrorInfo, FileImageTag, GrayscaleImageUnit, ImageSourceAdapter, ImageSourceErrorListener, ImageTag, InnerVersions, IntermediateResult, IntermediateResultExtraInfo, IntermediateResultUnit, LineSegment, LineSegmentsUnit, MapController, MimeType, ObservationParameters, OriginalImageResultItem, PDFReadingParameter, PathInfo, Point, Polygon, PostMessageBody, PredetectedRegionElement, PredetectedRegionsUnit, Quadrilateral, Rect, RegionObjectElement, ScaledColourImageUnit, ShortLinesUnit, TextRemovedBinaryImageUnit, TextZone, TextZonesUnit, TextureDetectionResultUnit, TextureRemovedBinaryImageUnit, TextureRemovedGrayscaleImageUnit, TransformedGrayscaleImageUnit, Warning, WasmVersions, WorkerAutoResources, _getNorImageData, _saveToFile, _toBlob, _toCanvas, _toImage, bDebug, checkIsLink, compareVersion, doOrWaitAsyncDependency, getNextTaskID, handleEngineResourcePaths, innerVersions, isArc, isContour, isDSImageData, isDSRect, isImageTag, isLineSegment, isObject, isOriginalDsImageData, isPoint, isPolygon, isQuad, isRect, isSimdSupported, mapAsyncDependency, mapPackageRegister, mapTaskCallBack, onLog, productNameMap, requestResource, setBDebug, setOnLog, waitAsyncDependency, worker, workerAutoResources };
1232
+
1233
+
1219
1234
 
1220
1235
 
1221
1236
 
@@ -1226,7 +1241,9 @@ interface CapturedResult extends CapturedResultBase {
1226
1241
  /** The decoded barcode results within the original image. */
1227
1242
  decodedBarcodesResult?: DecodedBarcodesResult;
1228
1243
  /** The recognized textLine results within the original image. */
1244
+ // recognizedTextLinesResult?: RecognizedTextLinesResult;
1229
1245
  /** The processed document results within the original image. */
1246
+ // processedDocumentResult?: ProcessedDocumentResult;
1230
1247
  /** The parsed results within the original image. */
1231
1248
  parsedResult?: ParsedResult;
1232
1249
  }
@@ -1247,6 +1264,26 @@ declare class CapturedResultReceiver {
1247
1264
  [key: string]: any;
1248
1265
  }
1249
1266
 
1267
+ declare class BufferedItemsManager {
1268
+ private _cvr;
1269
+ constructor(cvr: any);
1270
+ /**
1271
+ * Gets the maximum number of buffered items.
1272
+ * @returns Returns the maximum number of buffered items.
1273
+ */
1274
+ getMaxBufferedItems(): Promise<number>;
1275
+ /**
1276
+ * Sets the maximum number of buffered items.
1277
+ * @param count the maximum number of buffered items
1278
+ */
1279
+ setMaxBufferedItems(count: number): Promise<void>;
1280
+ /**
1281
+ * Gets the buffered character items.
1282
+ * @return the buffered character items
1283
+ */
1284
+ getBufferedCharacterItemSet(): Promise<Array<any>>;
1285
+ }
1286
+
1250
1287
  declare class IntermediateResultReceiver {
1251
1288
  private _observedResultUnitTypes;
1252
1289
  private _observedTaskMap;
@@ -1401,7 +1438,7 @@ declare class CaptureVisionRouter {
1401
1438
  *
1402
1439
  * @returns A promise that resolves once the recognition data file is successfully loaded. It does not provide any value upon resolution.
1403
1440
  */
1404
- static appendModelBuffer(modelName: string, dataPath?: string): Promise<unknown>;
1441
+ static appendModelBuffer(modelName: string, dataPath?: string): Promise<ErrorInfo>;
1405
1442
  /**
1406
1443
  * An event that fires during the loading of a recognition data file (.data).
1407
1444
  * @param filePath The path of the recognition data file.
@@ -1496,7 +1533,7 @@ declare class CaptureVisionRouter {
1496
1533
  *
1497
1534
  * @returns A promise that resolves when the operation has completed. It provides an object that describes the result.
1498
1535
  */
1499
- initSettings(settings: string | object): Promise<any>;
1536
+ initSettings(settings: string | object): Promise<ErrorInfo>;
1500
1537
  /**
1501
1538
  * Returns an object that contains settings for the specified `CaptureVisionTemplate`.
1502
1539
  * @param templateName Specifies a `CaptureVisionTemplate` by its name. If passed "*", the returned object will contain all templates.
@@ -1533,17 +1570,18 @@ declare class CaptureVisionRouter {
1533
1570
  *
1534
1571
  * @returns A promise that resolves when the operation has completed. It provides an object that describes the result.
1535
1572
  */
1536
- updateSettings(templateName: string, settings: SimplifiedCaptureVisionSettings): Promise<any>;
1573
+ updateSettings(templateName: string, settings: SimplifiedCaptureVisionSettings): Promise<ErrorInfo>;
1537
1574
  /**
1538
1575
  * Restores all runtime settings to their original default values.
1539
1576
  *
1540
1577
  * @returns A promise that resolves when the operation has completed. It provides an object that describes the result.
1541
1578
  */
1542
- resetSettings(): Promise<any>;
1579
+ resetSettings(): Promise<ErrorInfo>;
1543
1580
  /**
1544
1581
  * Returns an object, of type `BufferedItemsManager`, that manages buffered items.
1545
1582
  * @returns The `BufferedItemsManager` object.
1546
1583
  */
1584
+ getBufferedItemsManager(): BufferedItemsManager;
1547
1585
  /**
1548
1586
  * Returns an object, of type `IntermediateResultManager`, that manages intermediate results.
1549
1587
  *
@@ -3149,115 +3187,466 @@ declare class EventHandler {
3149
3187
  dispose(): void;
3150
3188
  }
3151
3189
 
3152
- declare class CameraEnhancer extends ImageSourceAdapter {
3190
+ declare class ImageDataGetter {
3153
3191
  #private;
3154
- /** @ignore */
3155
- static _debug: boolean;
3156
- private static _isRTU;
3157
- static set _onLog(value: (message: any) => void);
3158
- static get _onLog(): (message: any) => void;
3192
+ static _onLog: (message: any) => void;
3193
+ static get version(): string;
3194
+ static _webGLSupported: boolean;
3195
+ static get webGLSupported(): boolean;
3196
+ useWebGLByDefault: boolean;
3197
+ _reusedCvs: HTMLCanvasElement;
3198
+ _reusedWebGLCvs?: HTMLCanvasElement;
3199
+ get disposed(): boolean;
3200
+ constructor();
3201
+ private sourceIsReady;
3159
3202
  /**
3160
- * @ignore
3203
+ * Draw a image to canvas.
3204
+ * TODO: fix image is flipped when drawing in 'WebGL'.
3205
+ * @param canvas
3206
+ * @param source
3207
+ * @param sourceWidth
3208
+ * @param sourceHeight
3209
+ * @param position
3210
+ * @param options
3211
+ * @param options.bufferContainer if it is set and WebGL is used, the image data will be put into this variable.
3212
+ * @returns
3161
3213
  */
3162
- static browserInfo: {
3163
- browser: string;
3164
- version: number;
3165
- OS: string;
3214
+ drawImage(canvas: HTMLCanvasElement, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, sourceWidth: number, sourceHeight: number, position?: {
3215
+ sx?: number;
3216
+ sy?: number;
3217
+ sWidth?: number;
3218
+ sHeight?: number;
3219
+ dx?: number;
3220
+ dy?: number;
3221
+ dWidth?: number;
3222
+ dHeight?: number;
3223
+ }, options?: {
3224
+ pixelFormat?: EnumPixelFormat;
3225
+ bUseWebGL?: boolean;
3226
+ bufferContainer?: Uint8Array;
3227
+ isEnableMirroring?: boolean;
3228
+ }): {
3229
+ context: CanvasRenderingContext2D | WebGLRenderingContext;
3230
+ pixelFormat: EnumPixelFormat;
3231
+ bUseWebGL: boolean;
3166
3232
  };
3167
3233
  /**
3168
- * Event triggered when the running environment is not ideal.
3169
- * @param warning The warning message.
3234
+ * Read 'Unit8Array' from context of canvas.
3235
+ * @param context
3236
+ * @param position
3237
+ * @param bufferContainer If set, the data will be put into this variable, which will be useful when you want to reuse container.
3238
+ * @returns
3170
3239
  */
3171
- static onWarning: (warning: Warning) => void;
3240
+ readCvsData(context: CanvasRenderingContext2D | WebGLRenderingContext, position?: {
3241
+ x?: number;
3242
+ y?: number;
3243
+ width?: number;
3244
+ height?: number;
3245
+ }, bufferContainer?: Uint8Array): Uint8Array;
3172
3246
  /**
3173
- * Detect environment and get a report.
3174
- * ```js
3175
- * console.log(Dynamsoft.DCE.CameraEnhancer.detectEnvironment());
3176
- * // {"wasm":true, "worker":true, "getUserMedia":true, "camera":true, "browser":"Chrome", "version":90, "OS":"Windows"}
3177
- * ```
3247
+ * Transform pixel format.
3248
+ * @param data
3249
+ * @param originalFormat
3250
+ * @param targetFormat
3251
+ * @param copy
3252
+ * @returns
3178
3253
  */
3179
- static detectEnvironment(): Promise<any>;
3254
+ transformPixelFormat(data: Uint8Array, originalFormat: EnumPixelFormat, targetFormat: EnumPixelFormat, copy?: boolean): Uint8Array;
3180
3255
  /**
3181
- * Tests whether the application has access to the camera.
3182
- * This static method can be used before initializing a `CameraEnhancer` instance to ensure that the device's camera can be accessed, providing a way to handle permissions or other access issues preemptively.
3183
- * This method offers the additional advantage of accelerating the camera opening process for the first time.
3184
- *
3185
- * @returns A promise that resolves with an object containing:
3186
- * - `ok`: Boolean indicating whether camera access is available.
3187
- * - `message`: A string providing additional information or the reason why camera access is not available, if applicable.
3256
+ * Get image data from image.
3257
+ * @param source
3258
+ * @param sourceWidth
3259
+ * @param sourceHeight
3260
+ * @param position
3261
+ * @param options
3262
+ * @returns
3188
3263
  */
3189
- static testCameraAccess(): Promise<{
3190
- ok: boolean;
3191
- message: string;
3192
- }>;
3264
+ getImageData(source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, position: {
3265
+ sx: number;
3266
+ sy: number;
3267
+ sWidth: number;
3268
+ sHeight: number;
3269
+ dWidth: number;
3270
+ dHeight: number;
3271
+ }, options?: {
3272
+ pixelFormat?: EnumPixelFormat.RGBA | EnumPixelFormat.GREY;
3273
+ bufferContainer?: Uint8Array;
3274
+ isEnableMirroring?: boolean;
3275
+ }): {
3276
+ data: Uint8Array;
3277
+ pixelFormat: EnumPixelFormat;
3278
+ width: number;
3279
+ height: number;
3280
+ bUseWebGL: boolean;
3281
+ };
3193
3282
  /**
3194
- * Initializes a new instance of the `CameraEnhancer` class.
3195
- * @param view [Optional] Specifies a `CameraView` instance to provide the user interface element to display the live feed from the camera.
3196
- *
3197
- * @returns A promise that resolves with the initialized `CameraEnhancer` instance.
3283
+ * Draw image data to a canvas.
3284
+ * @param data
3285
+ * @param width
3286
+ * @param height
3287
+ * @param pixelFormat
3288
+ * @returns
3198
3289
  */
3199
- static createInstance(view?: CameraView): Promise<CameraEnhancer>;
3200
- private cameraManager;
3201
- private cameraView;
3290
+ convertDataToCvs(data: Uint8Array | Uint8ClampedArray, width: number, height: number, pixelFormat: EnumPixelFormat): HTMLCanvasElement;
3202
3291
  /**
3203
- * @ignore
3204
- */
3205
- private _imageDataGetter;
3206
- private _isEnableMirroring;
3207
- get isEnableMirroring(): boolean;
3292
+ * Force lose webgl context.
3293
+ * @private
3294
+ */
3295
+ forceLoseContext(): void;
3296
+ dispose(): void;
3297
+ }
3298
+
3299
+ interface CameraInfo {
3300
+ deviceId: string;
3301
+ label: string;
3302
+ /** @ignore */
3303
+ _checked: boolean;
3304
+ }
3305
+
3306
+ type CameraEvent = "before:open" | "opened" | "before:close" | "closed" | "before:camera:change" | "camera:changed" | "before:resolution:change" | "resolution:changed" | "played" | "paused" | "resumed" | "tapfocus";
3307
+ declare class CameraManager {
3308
+ #private;
3309
+ static _onLog: (message: any) => void;
3310
+ static get version(): string;
3311
+ static browserInfo: {
3312
+ browser: string;
3313
+ version: number;
3314
+ OS: string;
3315
+ };
3316
+ static onWarning: (message: string) => void;
3208
3317
  /**
3318
+ * Check if storage is available.
3209
3319
  * @ignore
3210
3320
  */
3211
- get video(): HTMLVideoElement;
3321
+ static isStorageAvailable(type: string): boolean;
3322
+ static findBestRearCameraInIOS(cameraList: Array<{
3323
+ label: string;
3324
+ deviceId: string;
3325
+ }>, options?: {
3326
+ getMainCamera?: boolean;
3327
+ }): string;
3328
+ static findBestRearCamera(cameraList: Array<{
3329
+ label: string;
3330
+ deviceId: string;
3331
+ }>, options?: {
3332
+ getMainCameraInIOS?: boolean;
3333
+ }): string;
3334
+ static findBestCamera(cameraList: Array<{
3335
+ label: string;
3336
+ deviceId: string;
3337
+ }>, facingMode: "environment" | "user" | null, options?: {
3338
+ getMainCameraInIOS?: boolean;
3339
+ }): string;
3340
+ static playVideo(videoEl: HTMLVideoElement, source: string | MediaStream | MediaSource | Blob, timeout?: number): Promise<HTMLVideoElement>;
3341
+ static testCameraAccess(constraints?: MediaStreamConstraints): Promise<{
3342
+ ok: boolean;
3343
+ errorName?: string;
3344
+ errorMessage?: string;
3345
+ }>;
3212
3346
  /**
3213
- * Sets or returns the source URL for the video stream to be used by the `CameraEnhancer`.
3214
- * 1. You can use this property to specify an existing video as the source to play which will be processed the same way as the video feed from a live camera.
3215
- * 2. When playing an existing video, the camera selection and video selection boxes will be hidden.
3216
- *
3217
- * It is particularly useful for applications that need to process or display video from a specific source rather than the device's default camera.
3347
+ * Camera/video state.
3218
3348
  */
3219
- set videoSrc(src: string);
3220
- get videoSrc(): string;
3349
+ get state(): "closed" | "opening" | "opened";
3350
+ _zoomPreSetting: {
3351
+ factor: number;
3352
+ centerPoint?: {
3353
+ x: string;
3354
+ y: string;
3355
+ };
3356
+ };
3357
+ videoSrc: string;
3358
+ _mediaStream: MediaStream;
3359
+ defaultConstraints: MediaStreamConstraints;
3360
+ cameraOpenTimeout: number;
3221
3361
  /**
3222
- * Determines whether the last used camera settings should be saved and reused the next time the `CameraEnhancer` is initialized.
3223
- *
3224
- * The default is `false`.
3225
- *
3226
- * When set to `true`, the enhancer attempts to restore the previously used camera settings, offering a more seamless user experience across sessions.
3227
- *
3228
- * - This feature makes use of the [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) of the browser.
3229
- * - This feature only works on mainstream browsers like Chrome, Firefox, and Safari. Other browsers may change the device IDs dynamically thus making it impossible to track the camera.
3362
+ * @ignore
3230
3363
  */
3231
- set ifSaveLastUsedCamera(value: boolean);
3232
- get ifSaveLastUsedCamera(): boolean;
3364
+ _arrCameras: Array<CameraInfo>;
3233
3365
  /**
3234
- * Determines whether to skip the initial camera inspection process.
3235
- *
3236
- * The default is `false`, which means to opt for an optimal rear camera at the first `open()`.
3237
- *
3238
- * Setting this property to `true` bypasses the automatic inspection and configuration that typically occurs when a camera connection is established.
3239
- * This can be useful for scenarios where the default inspection process may not be desirable or necessary.
3240
- *
3241
- * Note that if a previously used camera is already available in the [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), the inspection is skipped automatically. Read more on `ifSaveLastUsedCamera`.
3366
+ * Whether to record camera you selected after reload the page.
3242
3367
  */
3243
- set ifSkipCameraInspection(value: boolean);
3244
- get ifSkipCameraInspection(): boolean;
3368
+ set ifSaveLastUsedCamera(value: boolean);
3369
+ get ifSaveLastUsedCamera(): boolean;
3245
3370
  /**
3246
- * Specifies the timeout in milliseconds for opening the camera. The default value is 15000 ms.
3247
- *
3248
- * Setting 0 means canceling the timeout or waiting indefinitely.
3249
- *
3250
- * This property sets a limit on how long the `CameraEnhancer` will attempt to open the camera before timing out.
3251
- * It can be adjusted to accommodate different devices and scenarios, ensuring that the application does not hang indefinitely while trying to access the camera.
3371
+ * Whether to skip the process of picking a proper rear camera when opening camera the first time.
3252
3372
  */
3253
- set cameraOpenTimeout(value: number);
3254
- get cameraOpenTimeout(): number;
3255
- isTorchOn: undefined | boolean;
3256
- set singleFrameMode(value: "disabled" | "camera" | "image");
3257
- get singleFrameMode(): "disabled" | "camera" | "image";
3258
- /**
3259
- * Event handler in camera selection in default UI.
3260
- * @ignore
3373
+ ifSkipCameraInspection: boolean;
3374
+ selectIOSRearMainCameraAsDefault: boolean;
3375
+ get isVideoPlaying(): boolean;
3376
+ _focusParameters: any;
3377
+ _focusSupported: boolean;
3378
+ calculateCoordInVideo: (clientX: number, clientY: number) => {
3379
+ x: number;
3380
+ y: number;
3381
+ };
3382
+ set tapFocusEventBoundEl(element: HTMLElement);
3383
+ get tapFocusEventBoundEl(): HTMLElement;
3384
+ updateVideoElWhenSoftwareScaled: () => void;
3385
+ imageDataGetter: ImageDataGetter;
3386
+ detectedResolutions: {
3387
+ width: number;
3388
+ height: number;
3389
+ }[];
3390
+ get disposed(): boolean;
3391
+ constructor(videoEl?: HTMLVideoElement);
3392
+ setVideoEl(videoEl: HTMLVideoElement): void;
3393
+ getVideoEl(): HTMLVideoElement;
3394
+ releaseVideoEl(): void;
3395
+ isVideoLoaded(): boolean;
3396
+ /**
3397
+ * Open camera and play video.
3398
+ * @returns
3399
+ */
3400
+ open(): Promise<void>;
3401
+ close(): Promise<void>;
3402
+ pause(): void;
3403
+ resume(): Promise<void>;
3404
+ setCamera(deviceId: string): Promise<CameraInfo>;
3405
+ switchToFrontCamera(options?: {
3406
+ resolution: {
3407
+ width: number;
3408
+ height: number;
3409
+ };
3410
+ }): Promise<CameraInfo>;
3411
+ getCamera(): CameraInfo;
3412
+ _getCameras(force?: boolean): Promise<Array<CameraInfo>>;
3413
+ getCameras(): Promise<Array<CameraInfo>>;
3414
+ getAllCameras(): Promise<CameraInfo[]>;
3415
+ setResolution(width: number, height: number, exact?: boolean): Promise<{
3416
+ width: number;
3417
+ height: number;
3418
+ }>;
3419
+ getResolution(): {
3420
+ width: number;
3421
+ height: number;
3422
+ };
3423
+ getResolutions(reGet?: boolean): Promise<Array<{
3424
+ width: number;
3425
+ height: number;
3426
+ }>>;
3427
+ setMediaStreamConstraints(mediaStreamConstraints: MediaStreamConstraints, reOpen?: boolean): Promise<void>;
3428
+ getMediaStreamConstraints(): MediaStreamConstraints;
3429
+ resetMediaStreamConstraints(): void;
3430
+ getCameraCapabilities(): MediaTrackCapabilities;
3431
+ getCameraSettings(): MediaTrackSettings;
3432
+ turnOnTorch(): Promise<void>;
3433
+ turnOffTorch(): Promise<void>;
3434
+ setColorTemperature(value: number, autoCorrect?: boolean): Promise<number>;
3435
+ getColorTemperature(): number;
3436
+ setExposureCompensation(value: number, autoCorrect?: boolean): Promise<number>;
3437
+ getExposureCompensation(): number;
3438
+ setFrameRate(value: number, autoCorrect?: boolean): Promise<number>;
3439
+ getFrameRate(): number;
3440
+ setFocus(settings: {
3441
+ mode: string;
3442
+ } | {
3443
+ mode: "manual";
3444
+ distance: number;
3445
+ } | {
3446
+ mode: "manual";
3447
+ area: {
3448
+ centerPoint: {
3449
+ x: string;
3450
+ y: string;
3451
+ };
3452
+ width?: string;
3453
+ height?: string;
3454
+ };
3455
+ }, autoCorrect?: boolean): Promise<void>;
3456
+ getFocus(): Object;
3457
+ /**
3458
+ * Attention: tap focus is a feature that requires payment in DCE JS 4.x. Please consult relevant members if you want to export it to customers.
3459
+ */
3460
+ enableTapToFocus(): void;
3461
+ disableTapToFocus(): void;
3462
+ isTapToFocusEnabled(): boolean;
3463
+ /**
3464
+ *
3465
+ * @param settings factor: scale value; centerPoint: experimental argument, set the scale center. Video center by default.
3466
+ */
3467
+ setZoom(settings: {
3468
+ factor: number;
3469
+ centerPoint?: {
3470
+ x: string;
3471
+ y: string;
3472
+ };
3473
+ }): Promise<void>;
3474
+ getZoom(): {
3475
+ factor: number;
3476
+ };
3477
+ resetZoom(): Promise<void>;
3478
+ setHardwareScale(value: number, autoCorrect?: boolean): Promise<number>;
3479
+ getHardwareScale(): number;
3480
+ /**
3481
+ *
3482
+ * @param value scale value
3483
+ * @param center experimental argument, set the scale center. Video center by default.
3484
+ */
3485
+ setSoftwareScale(value: number, center?: {
3486
+ x: string;
3487
+ y: string;
3488
+ }): void;
3489
+ getSoftwareScale(): number;
3490
+ /**
3491
+ * Reset scale center to video center.
3492
+ * @experimental
3493
+ */
3494
+ resetScaleCenter(): void;
3495
+ resetSoftwareScale(): void;
3496
+ getFrameData(options?: {
3497
+ position?: {
3498
+ sx: number;
3499
+ sy: number;
3500
+ sWidth: number;
3501
+ sHeight: number;
3502
+ dWidth: number;
3503
+ dHeight: number;
3504
+ };
3505
+ pixelFormat?: EnumPixelFormat.GREY | EnumPixelFormat.RGBA;
3506
+ scale?: number;
3507
+ scaleCenter?: {
3508
+ x: string;
3509
+ y: string;
3510
+ };
3511
+ bufferContainer?: Uint8Array;
3512
+ isEnableMirroring?: boolean;
3513
+ }): {
3514
+ data: Uint8Array;
3515
+ width: number;
3516
+ height: number;
3517
+ pixelFormat: EnumPixelFormat;
3518
+ timeSpent: number;
3519
+ timeStamp: number;
3520
+ toCanvas: () => HTMLCanvasElement;
3521
+ };
3522
+ /**
3523
+ *
3524
+ * @param event {@link CameraEvent}
3525
+ * @param listener
3526
+ * @see {@link CameraEvent}
3527
+ * @see {@link off}
3528
+ */
3529
+ on(event: CameraEvent, listener: Function): void;
3530
+ /**
3531
+ *
3532
+ * @param event
3533
+ * @param listener
3534
+ * @see {@link CameraEvent}
3535
+ * @see {@link on}
3536
+ */
3537
+ off(event: CameraEvent, listener: Function): void;
3538
+ dispose(): Promise<void>;
3539
+ }
3540
+
3541
+ declare class CameraEnhancer extends ImageSourceAdapter {
3542
+ #private;
3543
+ /** @ignore */
3544
+ static _debug: boolean;
3545
+ private static _isRTU;
3546
+ static set _onLog(value: (message: any) => void);
3547
+ static get _onLog(): (message: any) => void;
3548
+ /**
3549
+ * @ignore
3550
+ */
3551
+ static browserInfo: {
3552
+ browser: string;
3553
+ version: number;
3554
+ OS: string;
3555
+ };
3556
+ /**
3557
+ * Event triggered when the running environment is not ideal.
3558
+ * @param warning The warning message.
3559
+ */
3560
+ static onWarning: (warning: Warning) => void;
3561
+ /**
3562
+ * Detect environment and get a report.
3563
+ * ```js
3564
+ * console.log(Dynamsoft.DCE.CameraEnhancer.detectEnvironment());
3565
+ * // {"wasm":true, "worker":true, "getUserMedia":true, "camera":true, "browser":"Chrome", "version":90, "OS":"Windows"}
3566
+ * ```
3567
+ */
3568
+ static detectEnvironment(): Promise<any>;
3569
+ /**
3570
+ * Tests whether the application has access to the camera.
3571
+ * This static method can be used before initializing a `CameraEnhancer` instance to ensure that the device's camera can be accessed, providing a way to handle permissions or other access issues preemptively.
3572
+ * This method offers the additional advantage of accelerating the camera opening process for the first time.
3573
+ *
3574
+ * @returns A promise that resolves with an object containing:
3575
+ * - `ok`: Boolean indicating whether camera access is available.
3576
+ * - `message`: A string providing additional information or the reason why camera access is not available, if applicable.
3577
+ */
3578
+ static testCameraAccess(): Promise<{
3579
+ ok: boolean;
3580
+ message: string;
3581
+ }>;
3582
+ /**
3583
+ * Initializes a new instance of the `CameraEnhancer` class.
3584
+ * @param view [Optional] Specifies a `CameraView` instance to provide the user interface element to display the live feed from the camera.
3585
+ *
3586
+ * @returns A promise that resolves with the initialized `CameraEnhancer` instance.
3587
+ */
3588
+ static createInstance(view?: CameraView): Promise<CameraEnhancer>;
3589
+ cameraManager: CameraManager;
3590
+ private cameraView;
3591
+ /**
3592
+ * @ignore
3593
+ */
3594
+ private _imageDataGetter;
3595
+ private _isEnableMirroring;
3596
+ get isEnableMirroring(): boolean;
3597
+ /**
3598
+ * @ignore
3599
+ */
3600
+ get video(): HTMLVideoElement;
3601
+ /**
3602
+ * Sets or returns the source URL for the video stream to be used by the `CameraEnhancer`.
3603
+ * 1. You can use this property to specify an existing video as the source to play which will be processed the same way as the video feed from a live camera.
3604
+ * 2. When playing an existing video, the camera selection and video selection boxes will be hidden.
3605
+ *
3606
+ * It is particularly useful for applications that need to process or display video from a specific source rather than the device's default camera.
3607
+ */
3608
+ set videoSrc(src: string);
3609
+ get videoSrc(): string;
3610
+ /**
3611
+ * Determines whether the last used camera settings should be saved and reused the next time the `CameraEnhancer` is initialized.
3612
+ *
3613
+ * The default is `false`.
3614
+ *
3615
+ * When set to `true`, the enhancer attempts to restore the previously used camera settings, offering a more seamless user experience across sessions.
3616
+ *
3617
+ * - This feature makes use of the [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) of the browser.
3618
+ * - This feature only works on mainstream browsers like Chrome, Firefox, and Safari. Other browsers may change the device IDs dynamically thus making it impossible to track the camera.
3619
+ */
3620
+ set ifSaveLastUsedCamera(value: boolean);
3621
+ get ifSaveLastUsedCamera(): boolean;
3622
+ /**
3623
+ * Determines whether to skip the initial camera inspection process.
3624
+ *
3625
+ * The default is `false`, which means to opt for an optimal rear camera at the first `open()`.
3626
+ *
3627
+ * Setting this property to `true` bypasses the automatic inspection and configuration that typically occurs when a camera connection is established.
3628
+ * This can be useful for scenarios where the default inspection process may not be desirable or necessary.
3629
+ *
3630
+ * Note that if a previously used camera is already available in the [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), the inspection is skipped automatically. Read more on `ifSaveLastUsedCamera`.
3631
+ */
3632
+ set ifSkipCameraInspection(value: boolean);
3633
+ get ifSkipCameraInspection(): boolean;
3634
+ /**
3635
+ * Specifies the timeout in milliseconds for opening the camera. The default value is 15000 ms.
3636
+ *
3637
+ * Setting 0 means canceling the timeout or waiting indefinitely.
3638
+ *
3639
+ * This property sets a limit on how long the `CameraEnhancer` will attempt to open the camera before timing out.
3640
+ * It can be adjusted to accommodate different devices and scenarios, ensuring that the application does not hang indefinitely while trying to access the camera.
3641
+ */
3642
+ set cameraOpenTimeout(value: number);
3643
+ get cameraOpenTimeout(): number;
3644
+ isTorchOn: undefined | boolean;
3645
+ set singleFrameMode(value: "disabled" | "camera" | "image");
3646
+ get singleFrameMode(): "disabled" | "camera" | "image";
3647
+ /**
3648
+ * Event handler in camera selection in default UI.
3649
+ * @ignore
3261
3650
  */
3262
3651
  private _onCameraSelChange;
3263
3652
  /**
@@ -4106,417 +4495,67 @@ declare class ImageEditorView extends View {
4106
4495
  * @returns Boolean indicating whether the `ImageEditorView` instance has been disposed of.
4107
4496
  */
4108
4497
  get disposed(): boolean;
4109
- private constructor();
4110
- /**
4111
- * Differ from 'setUIElement()', 'setUIElement()' allow parameter of 'string' type, which means a url, '_setUIElement()' only accept parameter of 'HTMLElement' type.
4112
- * @param element
4113
- */
4114
- private _setUIElement;
4115
- setUIElement(elementOrUrl: HTMLElement | string): Promise<void>;
4116
- getUIElement(): HTMLElement;
4117
- private _bindUI;
4118
- private _unbindUI;
4119
- /**
4120
- * Draw image in inner canvas.
4121
- * @ignore
4122
- */
4123
- private setImage;
4124
- /**
4125
- * Not used yet.
4126
- * @ignore
4127
- */
4128
- private getImage;
4129
- /**
4130
- * Not used yet.
4131
- * @ignore
4132
- */
4133
- private clearImage;
4134
- /**
4135
- * Not used yet.
4136
- * @ignore
4137
- */
4138
- private removeImage;
4139
- /**
4140
- * Sets the image to be drawn on the `ImageEditorView`.
4141
- * This method allows for the initialization or updating of the image.
4142
- * @param image The image to be drawn on the `ImageEditorView`.
4143
- */
4144
- setOriginalImage(img: DSImageData | HTMLCanvasElement | HTMLImageElement): void;
4145
- /**
4146
- * Returns the current image drawn on the `ImageEditorView`.
4147
- *
4148
- * @returns The current image drawn on the `ImageEditorView`. The returned type will match the format of the image originally set via `setOriginalImage()`.
4149
- */
4150
- getOriginalImage(): DSImageData | HTMLCanvasElement | HTMLImageElement;
4151
- /**
4152
- * Get dimensions of content(that is, the image). It decides what dimensions the layers should be created.
4153
- * @returns
4154
- */
4155
- protected getContentDimensions(): {
4156
- width: number;
4157
- height: number;
4158
- objectFit: string;
4159
- };
4160
- /**
4161
- * Create drawing layer with specified id and size.
4162
- * Differ from 'createDrawingLayer()', the drawing layers created'createDrawingLayer()' can not Specified id, and their size is the same as video.
4163
- * @ignore
4164
- */
4165
- _createDrawingLayer(drawingLayerId: number, width?: number, height?: number, objectFit?: string): DrawingLayer;
4166
- /**
4167
- * Releases all resources used by the `ImageEditorView` instance.
4168
- */
4169
- dispose(): void;
4170
- }
4171
-
4172
- declare class ImageDataGetter {
4173
- #private;
4174
- static _onLog: (message: any) => void;
4175
- static get version(): string;
4176
- static _webGLSupported: boolean;
4177
- static get webGLSupported(): boolean;
4178
- useWebGLByDefault: boolean;
4179
- _reusedCvs: HTMLCanvasElement;
4180
- _reusedWebGLCvs?: HTMLCanvasElement;
4181
- get disposed(): boolean;
4182
- constructor();
4183
- /**
4184
- * Draw a image to canvas.
4185
- * TODO: fix image is flipped when drawing in 'WebGL'.
4186
- * @param canvas
4187
- * @param source
4188
- * @param sourceWidth
4189
- * @param sourceHeight
4190
- * @param position
4191
- * @param options
4192
- * @param options.bufferContainer if it is set and WebGL is used, the image data will be put into this variable.
4193
- * @returns
4194
- */
4195
- drawImage(canvas: HTMLCanvasElement, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, sourceWidth: number, sourceHeight: number, position?: {
4196
- sx?: number;
4197
- sy?: number;
4198
- sWidth?: number;
4199
- sHeight?: number;
4200
- dx?: number;
4201
- dy?: number;
4202
- dWidth?: number;
4203
- dHeight?: number;
4204
- }, options?: {
4205
- pixelFormat?: EnumPixelFormat;
4206
- bUseWebGL?: boolean;
4207
- bufferContainer?: Uint8Array;
4208
- isEnableMirroring?: boolean;
4209
- }): {
4210
- context: CanvasRenderingContext2D | WebGLRenderingContext;
4211
- pixelFormat: EnumPixelFormat;
4212
- bUseWebGL: boolean;
4213
- };
4214
- /**
4215
- * Read 'Unit8Array' from context of canvas.
4216
- * @param context
4217
- * @param position
4218
- * @param bufferContainer If set, the data will be put into this variable, which will be useful when you want to reuse container.
4219
- * @returns
4220
- */
4221
- readCvsData(context: CanvasRenderingContext2D | WebGLRenderingContext, position?: {
4222
- x?: number;
4223
- y?: number;
4224
- width?: number;
4225
- height?: number;
4226
- }, bufferContainer?: Uint8Array): Uint8Array;
4227
- /**
4228
- * Transform pixel format.
4229
- * @param data
4230
- * @param originalFormat
4231
- * @param targetFormat
4232
- * @param copy
4233
- * @returns
4234
- */
4235
- transformPixelFormat(data: Uint8Array, originalFormat: EnumPixelFormat, targetFormat: EnumPixelFormat, copy?: boolean): Uint8Array;
4236
- /**
4237
- * Get image data from image.
4238
- * @param source
4239
- * @param sourceWidth
4240
- * @param sourceHeight
4241
- * @param position
4242
- * @param options
4243
- * @returns
4244
- */
4245
- getImageData(source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, position: {
4246
- sx: number;
4247
- sy: number;
4248
- sWidth: number;
4249
- sHeight: number;
4250
- dWidth: number;
4251
- dHeight: number;
4252
- }, options?: {
4253
- pixelFormat?: EnumPixelFormat.RGBA | EnumPixelFormat.GREY;
4254
- bufferContainer?: Uint8Array;
4255
- isEnableMirroring?: boolean;
4256
- }): {
4257
- data: Uint8Array;
4258
- pixelFormat: EnumPixelFormat;
4259
- width: number;
4260
- height: number;
4261
- bUseWebGL: boolean;
4262
- };
4263
- /**
4264
- * Draw image data to a canvas.
4265
- * @param data
4266
- * @param width
4267
- * @param height
4268
- * @param pixelFormat
4269
- * @returns
4270
- */
4271
- convertDataToCvs(data: Uint8Array | Uint8ClampedArray, width: number, height: number, pixelFormat: EnumPixelFormat): HTMLCanvasElement;
4272
- /**
4273
- * Force lose webgl context.
4274
- * @private
4275
- */
4276
- forceLoseContext(): void;
4277
- dispose(): void;
4278
- }
4279
-
4280
- interface CameraInfo {
4281
- deviceId: string;
4282
- label: string;
4283
- /** @ignore */
4284
- _checked: boolean;
4285
- }
4286
-
4287
- type CameraEvent = "before:open" | "opened" | "before:close" | "closed" | "before:camera:change" | "camera:changed" | "before:resolution:change" | "resolution:changed" | "played" | "paused" | "resumed" | "tapfocus";
4288
- declare class CameraManager {
4289
- #private;
4290
- static _onLog: (message: any) => void;
4291
- static get version(): string;
4292
- static browserInfo: {
4293
- browser: string;
4294
- version: number;
4295
- OS: string;
4296
- };
4297
- static onWarning: (message: string) => void;
4298
- /**
4299
- * Check if storage is available.
4300
- * @ignore
4301
- */
4302
- static isStorageAvailable(type: string): boolean;
4303
- static findBestRearCameraInIOS(cameraList: Array<{
4304
- label: string;
4305
- deviceId: string;
4306
- }>, options?: {
4307
- getMainCamera?: boolean;
4308
- }): string;
4309
- static findBestRearCamera(cameraList: Array<{
4310
- label: string;
4311
- deviceId: string;
4312
- }>, options?: {
4313
- getMainCameraInIOS?: boolean;
4314
- }): string;
4315
- static findBestCamera(cameraList: Array<{
4316
- label: string;
4317
- deviceId: string;
4318
- }>, facingMode: "environment" | "user" | null, options?: {
4319
- getMainCameraInIOS?: boolean;
4320
- }): string;
4321
- static playVideo(videoEl: HTMLVideoElement, source: string | MediaStream | MediaSource | Blob, timeout?: number): Promise<HTMLVideoElement>;
4322
- static testCameraAccess(constraints?: MediaStreamConstraints): Promise<{
4323
- ok: boolean;
4324
- errorName?: string;
4325
- errorMessage?: string;
4326
- }>;
4327
- /**
4328
- * Camera/video state.
4329
- */
4330
- get state(): "closed" | "opening" | "opened";
4331
- _zoomPreSetting: {
4332
- factor: number;
4333
- centerPoint?: {
4334
- x: string;
4335
- y: string;
4336
- };
4337
- };
4338
- videoSrc: string;
4339
- _mediaStream: MediaStream;
4340
- defaultConstraints: MediaStreamConstraints;
4341
- cameraOpenTimeout: number;
4498
+ private constructor();
4342
4499
  /**
4343
- * @ignore
4500
+ * Differ from 'setUIElement()', 'setUIElement()' allow parameter of 'string' type, which means a url, '_setUIElement()' only accept parameter of 'HTMLElement' type.
4501
+ * @param element
4344
4502
  */
4345
- _arrCameras: Array<CameraInfo>;
4503
+ private _setUIElement;
4504
+ setUIElement(elementOrUrl: HTMLElement | string): Promise<void>;
4505
+ getUIElement(): HTMLElement;
4506
+ private _bindUI;
4507
+ private _unbindUI;
4346
4508
  /**
4347
- * Whether to record camera you selected after reload the page.
4509
+ * Draw image in inner canvas.
4510
+ * @ignore
4348
4511
  */
4349
- set ifSaveLastUsedCamera(value: boolean);
4350
- get ifSaveLastUsedCamera(): boolean;
4512
+ private setImage;
4351
4513
  /**
4352
- * Whether to skip the process of picking a proper rear camera when opening camera the first time.
4514
+ * Not used yet.
4515
+ * @ignore
4353
4516
  */
4354
- ifSkipCameraInspection: boolean;
4355
- selectIOSRearMainCameraAsDefault: boolean;
4356
- get isVideoPlaying(): boolean;
4357
- _focusParameters: any;
4358
- _focusSupported: boolean;
4359
- calculateCoordInVideo: (clientX: number, clientY: number) => {
4360
- x: number;
4361
- y: number;
4362
- };
4363
- set tapFocusEventBoundEl(element: HTMLElement);
4364
- get tapFocusEventBoundEl(): HTMLElement;
4365
- updateVideoElWhenSoftwareScaled: () => void;
4366
- imageDataGetter: ImageDataGetter;
4367
- detectedResolutions: {
4368
- width: number;
4369
- height: number;
4370
- }[];
4371
- get disposed(): boolean;
4372
- constructor(videoEl?: HTMLVideoElement);
4373
- setVideoEl(videoEl: HTMLVideoElement): void;
4374
- getVideoEl(): HTMLVideoElement;
4375
- releaseVideoEl(): void;
4376
- isVideoLoaded(): boolean;
4517
+ private getImage;
4377
4518
  /**
4378
- * Open camera and play video.
4379
- * @returns
4519
+ * Not used yet.
4520
+ * @ignore
4380
4521
  */
4381
- open(): Promise<void>;
4382
- close(): Promise<void>;
4383
- pause(): void;
4384
- resume(): Promise<void>;
4385
- setCamera(deviceId: string): Promise<CameraInfo>;
4386
- switchToFrontCamera(options?: {
4387
- resolution: {
4388
- width: number;
4389
- height: number;
4390
- };
4391
- }): Promise<CameraInfo>;
4392
- getCamera(): CameraInfo;
4393
- _getCameras(force?: boolean): Promise<Array<CameraInfo>>;
4394
- getCameras(): Promise<Array<CameraInfo>>;
4395
- getAllCameras(): Promise<CameraInfo[]>;
4396
- setResolution(width: number, height: number, exact?: boolean): Promise<{
4397
- width: number;
4398
- height: number;
4399
- }>;
4400
- getResolution(): {
4401
- width: number;
4402
- height: number;
4403
- };
4404
- getResolutions(reGet?: boolean): Promise<Array<{
4405
- width: number;
4406
- height: number;
4407
- }>>;
4408
- setMediaStreamConstraints(mediaStreamConstraints: MediaStreamConstraints, reOpen?: boolean): Promise<void>;
4409
- getMediaStreamConstraints(): MediaStreamConstraints;
4410
- resetMediaStreamConstraints(): void;
4411
- getCameraCapabilities(): MediaTrackCapabilities;
4412
- getCameraSettings(): MediaTrackSettings;
4413
- turnOnTorch(): Promise<void>;
4414
- turnOffTorch(): Promise<void>;
4415
- setColorTemperature(value: number, autoCorrect?: boolean): Promise<number>;
4416
- getColorTemperature(): number;
4417
- setExposureCompensation(value: number, autoCorrect?: boolean): Promise<number>;
4418
- getExposureCompensation(): number;
4419
- setFrameRate(value: number, autoCorrect?: boolean): Promise<number>;
4420
- getFrameRate(): number;
4421
- setFocus(settings: {
4422
- mode: string;
4423
- } | {
4424
- mode: "manual";
4425
- distance: number;
4426
- } | {
4427
- mode: "manual";
4428
- area: {
4429
- centerPoint: {
4430
- x: string;
4431
- y: string;
4432
- };
4433
- width?: string;
4434
- height?: string;
4435
- };
4436
- }, autoCorrect?: boolean): Promise<void>;
4437
- getFocus(): Object;
4522
+ private clearImage;
4438
4523
  /**
4439
- * Attention: tap focus is a feature that requires payment in DCE JS 4.x. Please consult relevant members if you want to export it to customers.
4524
+ * Not used yet.
4525
+ * @ignore
4440
4526
  */
4441
- enableTapToFocus(): void;
4442
- disableTapToFocus(): void;
4443
- isTapToFocusEnabled(): boolean;
4527
+ private removeImage;
4444
4528
  /**
4445
- *
4446
- * @param settings factor: scale value; centerPoint: experimental argument, set the scale center. Video center by default.
4529
+ * Sets the image to be drawn on the `ImageEditorView`.
4530
+ * This method allows for the initialization or updating of the image.
4531
+ * @param image The image to be drawn on the `ImageEditorView`.
4447
4532
  */
4448
- setZoom(settings: {
4449
- factor: number;
4450
- centerPoint?: {
4451
- x: string;
4452
- y: string;
4453
- };
4454
- }): Promise<void>;
4455
- getZoom(): {
4456
- factor: number;
4457
- };
4458
- resetZoom(): Promise<void>;
4459
- setHardwareScale(value: number, autoCorrect?: boolean): Promise<number>;
4460
- getHardwareScale(): number;
4533
+ setOriginalImage(img: DSImageData | HTMLCanvasElement | HTMLImageElement): void;
4461
4534
  /**
4535
+ * Returns the current image drawn on the `ImageEditorView`.
4462
4536
  *
4463
- * @param value scale value
4464
- * @param center experimental argument, set the scale center. Video center by default.
4537
+ * @returns The current image drawn on the `ImageEditorView`. The returned type will match the format of the image originally set via `setOriginalImage()`.
4465
4538
  */
4466
- setSoftwareScale(value: number, center?: {
4467
- x: string;
4468
- y: string;
4469
- }): void;
4470
- getSoftwareScale(): number;
4539
+ getOriginalImage(): DSImageData | HTMLCanvasElement | HTMLImageElement;
4471
4540
  /**
4472
- * Reset scale center to video center.
4473
- * @experimental
4474
- */
4475
- resetScaleCenter(): void;
4476
- resetSoftwareScale(): void;
4477
- getFrameData(options?: {
4478
- position?: {
4479
- sx: number;
4480
- sy: number;
4481
- sWidth: number;
4482
- sHeight: number;
4483
- dWidth: number;
4484
- dHeight: number;
4485
- };
4486
- pixelFormat?: EnumPixelFormat.GREY | EnumPixelFormat.RGBA;
4487
- scale?: number;
4488
- scaleCenter?: {
4489
- x: string;
4490
- y: string;
4491
- };
4492
- bufferContainer?: Uint8Array;
4493
- isEnableMirroring?: boolean;
4494
- }): {
4495
- data: Uint8Array;
4541
+ * Get dimensions of content(that is, the image). It decides what dimensions the layers should be created.
4542
+ * @returns
4543
+ */
4544
+ protected getContentDimensions(): {
4496
4545
  width: number;
4497
4546
  height: number;
4498
- pixelFormat: EnumPixelFormat;
4499
- timeSpent: number;
4500
- timeStamp: number;
4501
- toCanvas: () => HTMLCanvasElement;
4547
+ objectFit: string;
4502
4548
  };
4503
4549
  /**
4504
- *
4505
- * @param event {@link CameraEvent}
4506
- * @param listener
4507
- * @see {@link CameraEvent}
4508
- * @see {@link off}
4550
+ * Create drawing layer with specified id and size.
4551
+ * Differ from 'createDrawingLayer()', the drawing layers created'createDrawingLayer()' can not Specified id, and their size is the same as video.
4552
+ * @ignore
4509
4553
  */
4510
- on(event: CameraEvent, listener: Function): void;
4554
+ _createDrawingLayer(drawingLayerId: number, width?: number, height?: number, objectFit?: string): DrawingLayer;
4511
4555
  /**
4512
- *
4513
- * @param event
4514
- * @param listener
4515
- * @see {@link CameraEvent}
4516
- * @see {@link on}
4556
+ * Releases all resources used by the `ImageEditorView` instance.
4517
4557
  */
4518
- off(event: CameraEvent, listener: Function): void;
4519
- dispose(): Promise<void>;
4558
+ dispose(): void;
4520
4559
  }
4521
4560
 
4522
4561
  declare class Feedback {
@@ -4591,10 +4630,6 @@ interface ParsedResultItem extends CapturedResultItem {
4591
4630
  * The parsed result represented as a JSON-formatted string.
4592
4631
  */
4593
4632
  jsonString: string;
4594
- parsedFields: Array<{
4595
- FieldName: string;
4596
- Value: string;
4597
- }>;
4598
4633
  /**
4599
4634
  * Retrieves the value of a specified field.
4600
4635
  * @param fieldName The name of the field whose value is being requested.
@@ -4652,7 +4687,7 @@ declare class CodeParser {
4652
4687
  *
4653
4688
  * @returns A promise that resolves when the operation has completed. It does not provide any value upon resolution.
4654
4689
  */
4655
- initSettings(settings: string): Promise<void>;
4690
+ initSettings(settings: string): Promise<ErrorInfo>;
4656
4691
  /**
4657
4692
  * Restores all runtime settings to their original default values.
4658
4693
  *
@@ -4786,7 +4821,7 @@ declare class UtilityModule {
4786
4821
  static getVersion(): string;
4787
4822
  }
4788
4823
 
4789
- type resultItemTypesString = "barcode" | "text_line" | "detected_quad" | "normalized_image";
4824
+ type resultItemTypesString = "barcode" | "text_line" | "detected_quad" | "deskewed_image";
4790
4825
 
4791
4826
  declare class MultiFrameResultCrossFilter implements CapturedResultFilter {
4792
4827
  #private;
@@ -4872,7 +4907,156 @@ declare class MultiFrameResultCrossFilter implements CapturedResultFilter {
4872
4907
  latestOverlappingFilter(result: any): void;
4873
4908
  }
4874
4909
 
4875
- export { MultiFrameResultCrossFilter, UtilityModule };
4910
+ declare class ImageIO {
4911
+ #private;
4912
+ /**
4913
+ * This method reads an image from a file. The file format is automatically detected based on the file extensioor content.
4914
+ *
4915
+ * @param file The file to read, as a File object.
4916
+ *
4917
+ * @returns A promise that resolves with the loaded image of type `DSImageData`.
4918
+ */
4919
+ readFromFile(file: File): Promise<DSImageData>;
4920
+ /**
4921
+ * This method saves an image in either PNG or JPG format. The desired file format is inferred from the filextension provided in the 'name' parameter. Should the specified file format be omitted or unsupported, thdata will default to being exported in PNG format.
4922
+ *
4923
+ * @param image The image to be saved, of type `DSImageData`.
4924
+ * @param name The name of the file, as a string, under which the image will be saved.
4925
+ * @param download An optional boolean flag that, when set to true, triggers the download of the file.
4926
+ *
4927
+ * @returns A promise that resolves with the saved File object.
4928
+ */
4929
+ saveToFile(image: DSImageData, name: string, download?: boolean): Promise<File>;
4930
+ /**
4931
+ * Reads image data from memory using the specified ID.
4932
+ *
4933
+ * @param id - The memory ID referencing a previously stored image.
4934
+ *
4935
+ * @returns A Promise that resolves to the `DSImageData` object.
4936
+ */
4937
+ readFromMemory(id: number): Promise<DSImageData>;
4938
+ /**
4939
+ * This method saves an image to memory. The desired file format is inferred from the 'format' parameter. Should the specified file format be omitted or unsupported, the data will default to being exported in PNG format.
4940
+ *
4941
+ * @param image A `Blob` representing the image to be saved.
4942
+ * @param fileFormat The desired image format.
4943
+ *
4944
+ * @returns A Promise that resolves to a memory ID which can later be used to retrieve the image via readFromMemory.
4945
+ */
4946
+ saveToMemory(image: Blob, fileFormat: EnumImageFileFormat): Promise<number>;
4947
+ /**
4948
+ * This method reads an image from a Base64-encoded string. The image format is automatically detected based on the content of the string.
4949
+ *
4950
+ * @param base64String The Base64-encoded string representing the image.
4951
+ *
4952
+ * @returns A promise that resolves with the loaded image of type `DSImageData`.
4953
+ */
4954
+ readFromBase64String(base64String: string): Promise<DSImageData>;
4955
+ /**
4956
+ * This method saves an image to a Base64-encoded string. The desired file format is inferred from the 'format' parameter. Should the specified file format be omitted or unsupported, the data will default to being exported in PNG format.
4957
+ *
4958
+ * @param image The image to be saved, of type `Blob`.
4959
+ * @param format The desired image format.
4960
+ *
4961
+ * @returns A promise that resolves with a Base64-encoded string representing the image.
4962
+ */
4963
+ saveToBase64String(image: Blob, fileFormat: EnumImageFileFormat): Promise<string>;
4964
+ }
4965
+
4966
+ declare class ImageDrawer {
4967
+ /**
4968
+ * This method draws various shapes on an image, and save it in PNG format.
4969
+ *
4970
+ * @param image The image to be saved.
4971
+ * @param drawingItem An array of different shapes to draw on the image.
4972
+ * @param type The type of drawing shapes.
4973
+ * @param color The color to use for drawing. Defaults to 0xFFFF0000 (red).
4974
+ * @param thickness The thickness of the lines to draw. Defaults to 1.
4975
+ * @param download An optional boolean flag that, when set to true, triggers the download of the file.
4976
+ *
4977
+ * @returns A promise that resolves with the saved File object.
4978
+ */
4979
+ drawOnImage(image: Blob | string | DSImageData, drawingItem: Array<Quadrilateral> | Quadrilateral | Array<LineSegment> | LineSegment | Array<Contour> | Contour | Array<Corner> | Corner | Array<Edge> | Edge, type: "quads" | "lines" | "contours" | "corners" | "edges", color?: number, thickness?: number, name?: string, download?: boolean): Promise<DSImageData>;
4980
+ }
4981
+
4982
+ declare enum EnumFilterType {
4983
+ /**High-pass filter: Enhances edges and fine details by attenuating low-frequency components.*/
4984
+ FT_HIGH_PASS = 0,
4985
+ /**Sharpen filter: Increases contrast along edges to make the image appear more defined.*/
4986
+ FT_SHARPEN = 1,
4987
+ /**Smooth (blur) filter: Reduces noise and detail by averaging pixel values, creating a softening effect.*/
4988
+ FT_SMOOTH = 2
4989
+ }
4990
+
4991
+ declare class ImageProcessor {
4992
+ /**
4993
+ * Crops an image using a rectangle or quadrilateral.
4994
+ * @param image The image data to be cropped.
4995
+ * @param roi The rectangle or quadrilateral to be cropped.
4996
+ *
4997
+ * @returns A promise that resolves with the cropped image data.
4998
+ */
4999
+ cropImage(image: Blob, roi: DSRect): Promise<DSImageData>;
5000
+ /**
5001
+ * Adjusts the brightness of the image.
5002
+ * @param image The image data to be adjusted.
5003
+ * @param brightness Brightness adjustment value (range: [-100, 100]).
5004
+ *
5005
+ * @returns A promise that resolves with the adjusted image data.
5006
+ */
5007
+ adjustBrightness(image: Blob, brightness: number): Promise<DSImageData>;
5008
+ /**
5009
+ * Adjusts the contrast of the image.
5010
+ * @param image The image data to be adjusted.
5011
+ * @param contrast Contrast adjustment value (range: [-100, 100]).
5012
+ *
5013
+ * @returns A promise that resolves with the adjusted image data.
5014
+ */
5015
+ adjustContrast(image: Blob, contrast: number): Promise<DSImageData>;
5016
+ /**
5017
+ * Applies a specified image filter to an input image.
5018
+ * @param image The image data to be filtered.
5019
+ * @param filterType The type of filter to apply.
5020
+ * @returns A promise that resolves with the filtered image data.
5021
+ */
5022
+ filterImage(image: Blob, filterType: EnumFilterType): Promise<DSImageData>;
5023
+ /**
5024
+ * Converts a colour image to grayscale.
5025
+ * @param image The image data to be converted.
5026
+ * @param R [R=0.3] - Weight for the red channel.
5027
+ * @param G [G=0.59] - Weight for the green channel.
5028
+ * @param B [B=0.11] - Weight for the blue channel.
5029
+ * @returns A promise that resolves with the grayscale image data.
5030
+ */
5031
+ convertToGray(image: Blob, R?: number, G?: number, B?: number): Promise<DSImageData>;
5032
+ /**
5033
+ * Converts a grayscale image to a binary image using a global threshold.
5034
+ * @param image The grayscale image data.
5035
+ * @param threshold [threshold=-1] Global threshold for binarization (-1 for automatic calculation).
5036
+ * @param invert [invert=false] Whether to invert the binary image.
5037
+ * @returns A promise that resolves with the binary image data.
5038
+ */
5039
+ convertToBinaryGlobal(image: Blob, threshold?: number, invert?: boolean): Promise<DSImageData>;
5040
+ /**
5041
+ * Converts a grayscale image to a binary image using local (adaptive) binarization.
5042
+ * @param image The grayscale image data.
5043
+ * @param blockSize [blockSize=0] Size of the block for local binarization.
5044
+ * @param compensation [compensation=0] Adjustment value to modify the threshold.
5045
+ * @param invert [invert=false] Whether to invert the binary image.
5046
+ * @returns A promise that resolves with the binary image data.
5047
+ */
5048
+ convertToBinaryLocal(image: Blob, blockSize?: number, compensation?: number, invert?: boolean): Promise<DSImageData>;
5049
+ /**
5050
+ * Crops and deskews an image using a quadrilateral.
5051
+ * @param image The image data to be cropped and deskewed.
5052
+ * @param roi The quadrilateral defining the region of interest to be cropped and deskewed.
5053
+ *
5054
+ * @returns A promise that resolves with the cropped and deskewed image data.
5055
+ */
5056
+ cropAndDeskewImage(image: Blob, roi: Quadrilateral): Promise<DSImageData>;
5057
+ }
5058
+
5059
+ export { EnumFilterType, ImageDrawer, ImageIO, ImageProcessor, MultiFrameResultCrossFilter, UtilityModule };
4876
5060
 
4877
5061
 
4878
5062
 
@@ -4923,6 +5107,7 @@ interface BarcodeScannerConfig {
4923
5107
  showResultView?: boolean;
4924
5108
  showUploadImageButton?: boolean;
4925
5109
  showPoweredByDynamsoft?: boolean;
5110
+ autoStartCapturing?: boolean;
4926
5111
  scannerViewConfig?: ScannerViewConfig;
4927
5112
  resultViewConfig?: ResultViewConfig;
4928
5113
  uiPath?: string;
@@ -4938,6 +5123,11 @@ interface BarcodeScannerConfig {
4938
5123
  cameraEnhancer: CameraEnhancer;
4939
5124
  cvRouter: CaptureVisionRouter;
4940
5125
  }) => void;
5126
+ onCaptureStart?: (components: {
5127
+ cameraView: CameraView;
5128
+ cameraEnhancer: CameraEnhancer;
5129
+ cvRouter: CaptureVisionRouter;
5130
+ }) => void;
4941
5131
  }
4942
5132
  interface ScannerViewConfig {
4943
5133
  container?: HTMLElement | string;
@@ -4984,6 +5174,7 @@ declare class BarcodeScanner {
4984
5174
  private _cvRouter;
4985
5175
  config: BarcodeScannerConfig;
4986
5176
  constructor(config?: BarcodeScannerConfig);
5177
+ get disposed(): boolean;
4987
5178
  launch(): Promise<BarcodeScanResult>;
4988
5179
  decode(imageOrFile: Blob | string | DSImageData | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement, templateName?: string): Promise<CapturedResult>;
4989
5180
  dispose(): void;