Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 00431ad

Browse files
authored
Merge pull request #8 from Dynamsoft/_dev
3.2.0
2 parents 8ca63af + 1747714 commit 00431ad

File tree

12 files changed

+152
-54
lines changed

12 files changed

+152
-54
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ __pycache__
2929
package-lock.json
3030
yarn.lock
3131
.git
32+
.npmrc
3233
/*.zip
3334
/*.py
3435
/*.exe

Api Reference.url

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[InternetShortcut]
2-
URL=https://www.dynamsoft.com/camera-enhancer/docs/programming/javascript/api-reference/?ver=3.1.0
2+
URL=https://www.dynamsoft.com/camera-enhancer/docs/programming/javascript/api-reference/?ver=3.2.0

LICENSE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Copyright © 2003–2022 Dynamsoft. All Rights Reserved.
2+
3+
The use of this software is governed by the Dynamsoft Terms and Conditions.
4+
https://www.dynamsoft.com/company/license-agreement/

README.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,31 @@ Once integrated, your users can open your website in a browser, access their cam
77
> **Example Usage**
88
>
99
> See how Dynamsoft Camera Enhancer helps in camera control and video recognition:
10+
>
1011
> - **Barcode scanning from video stream**: check [Dynamsoft Barcode Reader JS User Guide](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/?ver=latest)
1112
> - **MRZ scanning and OCR from video stream**: check [Dynamsoft Label Recognizer JS User Guide](https://www.dynamsoft.com/label-recognition/programming/javascript/user-guide.html?ver=latest&utm_source=dceguide)
1213
1314
In this guide, you will learn step by step on how to integrate the Dynamsoft Camera Enhancer SDK into your website.
1415

15-
**Table of Contents**
16-
17-
* [Getting Started](#getting-started)
18-
* [Include the SDK](#include-the-sdk)
19-
* [Interact with the SDK](#interact-with-the-sdk)
20-
* [Hosting the SDK](#hosting-the-sdk)
21-
* [FAQ](#faq)
22-
* [API Documentation](#api-documentation)
23-
* [Release Notes](#release-notes)
24-
* [Next Steps](#next-steps)
16+
- [Dynamsoft Camera Enhancer for Your Website](#dynamsoft-camera-enhancer-for-your-website)
17+
- [Getting Started](#getting-started)
18+
- [Include the SDK](#include-the-sdk)
19+
- [Use a CDN](#use-a-cdn)
20+
- [Host the SDK yourself](#host-the-sdk-yourself)
21+
- [Interact with the SDK](#interact-with-the-sdk)
22+
- [Create a `CameraEnhancer` object](#create-a-cameraenhancer-object)
23+
- [Configure the `CameraEnhancer` object](#configure-the-cameraenhancer-object)
24+
- [Customize the UI](#customize-the-ui)
25+
- [Hosting the SDK](#hosting-the-sdk)
26+
- [Step One: Deploy the dist folder](#step-one-deploy-the-dist-folder)
27+
- [Step Two: Configure the Server](#step-two-configure-the-server)
28+
- [Step Three: Include the SDK from the server](#step-three-include-the-sdk-from-the-server)
29+
- [FAQ](#faq)
30+
- [Can I open the web page directly from the hard drive?](#can-i-open-the-web-page-directly-from-the-hard-drive)
31+
- [Why can't I use my camera?](#why-cant-i-use-my-camera)
32+
- [API Documentation](#api-documentation)
33+
- [Release Notes](#release-notes)
34+
- [Next Steps](#next-steps)
2535

2636
## Getting Started
2737

@@ -31,35 +41,37 @@ In this guide, you will learn step by step on how to integrate the Dynamsoft Cam
3141

3242
The simplest way to include the SDK is to use either the [jsDelivr](https://jsdelivr.com/) or [UNPKG](https://unpkg.com/) CDN.
3343

34-
* jsDelivr
44+
- jsDelivr
3545

3646
```html
37-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@3.1.0/dist/dce.js"></script>
47+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer/dist/dce.js"></script>
3848
```
3949

40-
* UNPKG
50+
- UNPKG
4151

4252
```html
43-
<script src="https://unpkg.com/dynamsoft-camera-enhancer@3.1.0/dist/dce.js"></script>
53+
<script src="https://unpkg.com/dynamsoft-camera-enhancer/dist/dce.js"></script>
4454
```
4555

56+
> In some rare cases, you might not be able to access the CDN. If this happens, you can use [https://download2.dynamsoft.com/dce/dynamsoft-camera-enhancer-js/dynamsoft-camera-enhancer-js-3.2.0/dist/dce.js](https://download2.dynamsoft.com/dce/dynamsoft-camera-enhancer-js/dynamsoft-camera-enhancer-js-3.2.0/dist/dce.js)
57+
4658
#### Host the SDK yourself
4759

4860
Besides using the CDN, you can also download the SDK and host it locally.
4961

5062
The following shows a few ways to download the SDK.
5163

52-
* From the website
64+
- From the website
5365

5466
[Download the JavaScript Package](https://www.dynamsoft.com/camera-enhancer/downloads/1000021-confirmation/?utm_source=github)
5567

56-
* yarn
68+
- yarn
5769

5870
```cmd
5971
yarn add dynamsoft-camera-enhancer
6072
```
6173

62-
* npm
74+
- npm
6375

6476
```cmd
6577
npm install dynamsoft-camera-enhancer --save
@@ -68,7 +80,7 @@ The following shows a few ways to download the SDK.
6880
Depending on how you downloaded the SDK and where you put it. You can typically include it like this:
6981

7082
```html
71-
<script src="/dce-js-3.1.0/dist/dce.js"></script>
83+
<script src="/dce-js-3.2.0/dist/dce.js"></script>
7284
```
7385

7486
or
@@ -105,8 +117,9 @@ As shown in the code snippet below, before opening the video stream, we need to
105117
<script>
106118
(async () => {
107119
let enhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance();
108-
await enhancer.open();
120+
await enhancer.setUIElement(Dynamsoft.DCE.CameraEnhancer.defaultUIElementURL);
109121
document.getElementById("enhancerUIContainer").appendChild(enhancer.getUIElement());
122+
await enhancer.open();
110123
})();
111124
</script>
112125
```
@@ -134,10 +147,11 @@ Dynamsoft.DCE.CameraEnhancer.defaultUIElementURL = "THE-URL-TO-THE-FILE";
134147
<script>
135148
(async () => {
136149
let enhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance();
137-
// In order to get the UIElement to put on the page, call open() first.
138-
await enhancer.open();
139-
// Gets the internally built UI element and bind it to an element on the page.
150+
// Sets the internally built UI element
151+
await enhancer.setUIElement(Dynamsoft.DCE.CameraEnhancer.defaultUIElementURL);
152+
// Gets the internally built UI element and add it to the page.
140153
document.getElementById("enhancerUIContainer").appendChild(enhancer.getUIElement());
154+
await enhancer.open();
141155
// The following line hides the close button
142156
document.getElementsByClassName("dce-btn-close")[0].style.display = "none";
143157
})();
@@ -173,7 +187,7 @@ Dynamsoft.DCE.CameraEnhancer.defaultUIElementURL = "THE-URL-TO-THE-FILE";
173187
<select class="dce-sel-resolution"></select>
174188
```
175189

176-
> By default, only 4 hard-coded resolutions (3840 x 2160, 1920 x 1080, 1280 x 720, 640 x 480), are populated as options. You can show a customized set of options by hardcoding them.
190+
> By default, only 3 hard-coded resolutions (1920 x 1080, 1280 x 720, 640 x 480), are populated as options. You can show a customized set of options by hardcoding them.
177191
178192
```html
179193
<select class="dce-sel-resolution">

dist/dce.esm.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dce.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dce.mjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/types/class/cameraenhancer.d.ts

Lines changed: 90 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class CameraEnhancer implements ImageSource {
3636
private static _engineResourcePath?;
3737
/**
3838
* ```js
39-
* Dynamsoft.DCE.CameraEnhancer.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@3.1.0/dist/";
39+
* Dynamsoft.DCE.CameraEnhancer.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@3.2.0/dist/";
4040
* ```
4141
*/
4242
static set engineResourcePath(value: string);
@@ -48,6 +48,10 @@ export default class CameraEnhancer implements ImageSource {
4848
static isStorageAvailable(type: string): boolean;
4949
/** @ignore */
5050
static isDCEFrame(value: any): boolean;
51+
static testCameraAccess(): Promise<{
52+
ok: boolean;
53+
message: string;
54+
}>;
5155
private _maxCvsSideLength;
5256
private _defaultMaxCvsSideLength;
5357
/** @ignore */
@@ -60,7 +64,7 @@ export default class CameraEnhancer implements ImageSource {
6064
/**
6165
* The url of the default UI.
6266
* ```js
63-
* Dynamsoft.DCE.CameraEnhancer.defaultUIElementURL = "https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@3.1.0/dist/dce.ui.html";
67+
* Dynamsoft.DCE.CameraEnhancer.defaultUIElementURL = "https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@3.2.0/dist/dce.ui.html";
6468
* let pEnhancer = null;
6569
* (async()=>{
6670
* let enhancer = await (pEnhancer = pEnhancer || Dynamsoft.DCE.CameraEnhancer.createInstance());
@@ -167,6 +171,14 @@ export default class CameraEnhancer implements ImageSource {
167171
private _webGLProgramInfo;
168172
private _webGLBuffers;
169173
private _softwareScale;
174+
private _scaleCenter;
175+
private _focusParameters;
176+
private _tapFocusEnabled;
177+
private _focusSupported;
178+
private _focusArea;
179+
private _tapDoFocus;
180+
private _touchMoved;
181+
private _touchMoveEvent;
170182
private _recordedStates;
171183
/**
172184
* @deprecated
@@ -297,6 +309,11 @@ export default class CameraEnhancer implements ImageSource {
297309
private _arrScanRegionOverlays;
298310
private _drawingLayersManager;
299311
private _layerBaseCvs;
312+
private _drawingLayerOfTip;
313+
private _tipStyleId;
314+
private _tipArgs;
315+
private _hideTipTimeoutId;
316+
onTipSuggested: (occasion: string, message: string) => void;
300317
/**
301318
* Set the scan region.
302319
* ```js
@@ -352,7 +369,7 @@ export default class CameraEnhancer implements ImageSource {
352369
* ```
353370
* @see [[getViewDecorator]],[[setViewDecoratorLineWidth]],[[setViewDecoratorStrokeStyle]],[[setViewDecoratorFillStyle]],[[setViewDecoratorMaskFillStyle]]
354371
*/
355-
setViewDecorator(type: string | string[], area: Area): void;
372+
setViewDecorator(type: "rectangle" | "focus" | "crossline" | "crosshair" | string[], area: Area): void;
356373
/**
357374
* Return the view decorator type, area and the decorator itself in a object.
358375
* @see [[setViewDecorator]]
@@ -364,22 +381,22 @@ export default class CameraEnhancer implements ImageSource {
364381
* Set the line width for drawing the view decorator.
365382
* @see [[setViewDecorator]]
366383
*/
367-
setViewDecoratorLineWidth(type: string, width: number): void;
384+
setViewDecoratorLineWidth(type: "rectangle" | "focus" | "crossline" | "crosshair", width: number): void;
368385
/**
369386
* Set the stroke style for drawing the view decorator.
370387
* @see [[setViewDecorator]]
371388
*/
372-
setViewDecoratorStrokeStyle(type: string, style: string): void;
389+
setViewDecoratorStrokeStyle(type: "rectangle" | "focus" | "crossline" | "crosshair", style: string): void;
373390
/**
374391
* Set the fill style for drawing the view decorator.
375392
* @see [[setViewDecorator]]
376393
*/
377-
setViewDecoratorFillStyle(type: string, style: string): void;
394+
setViewDecoratorFillStyle(type: "rectangle" | "focus", style: string): void;
378395
/**
379396
* Set the fill style for drawing the mask for the view decorator.
380397
* @see [[setViewDecorator]]
381398
*/
382-
setViewDecoratorMaskFillStyle(type: string, style: string): void;
399+
setViewDecoratorMaskFillStyle(type: "rectangle" | "focus", style: string): void;
383400
/**
384401
* Might be called when:
385402
* 1. 'setViewDecoratorLineWidth', 'setViewDecoratorStrokeStyle', 'setViewDecoratorFillStyle' or 'setViewDecoratorMaskFillStyle' is called;
@@ -658,7 +675,7 @@ export default class CameraEnhancer implements ImageSource {
658675
* ```
659676
* @see [[off]]
660677
*/
661-
on(eventName: string, listener: Function): void;
678+
on(eventName: "cameraOpen" | "cameraClose" | "cameraChange" | "resolutionChange" | "played" | "singleFrameAcquired" | "frameAddedToBuffer", listener: Function): void;
662679
/**
663680
* Remove the specified event handler.
664681
* ```js
@@ -672,7 +689,7 @@ export default class CameraEnhancer implements ImageSource {
672689
* ```
673690
* @see [[on]]
674691
*/
675-
off(eventName: string, listener: Function): void;
692+
off(eventName: "cameraOpen" | "cameraClose" | "cameraChange" | "resolutionChange" | "played" | "singleFrameAcquired" | "frameAddedToBuffer", listener: Function): void;
676693
/**
677694
* Remove event handlers of specified type.
678695
* @param eventName
@@ -798,17 +815,44 @@ export default class CameraEnhancer implements ImageSource {
798815
*/
799816
setExposureCompensation(value: number): Promise<void>;
800817
getExposureCompensation(): number;
818+
private _setHardwareScale;
819+
private _getHardwareScale;
820+
private _setSoftwareScale;
821+
private _getSoftwareScale;
822+
private _setScaleCenter;
823+
private _resetScaleCenter;
824+
private _isVideoCenter;
825+
/**
826+
*
827+
* @param value
828+
* @deprecated
829+
*/
830+
private _setZoom;
801831
/**
802832
* Adjusts the zoom ratio.
803833
* Only available when the camera is open.
804834
* ```js
805-
* await enhancer.setZoom(400);
835+
* await enhancer.setZoom({factor: 2});
806836
* ```
807837
* @see [[getCapabilities]]
808838
* @category Camera Settings
809839
*/
810-
setZoom(value: number): Promise<void>;
840+
setZoom(settings: number | {
841+
factor: number;
842+
centerPoint?: {
843+
x: string;
844+
y: string;
845+
};
846+
}): Promise<void>;
847+
/**
848+
* @returns
849+
* @deprecated
850+
*/
811851
getZoom(): number;
852+
getZoomSettings(): {
853+
factor: number;
854+
};
855+
resetZoom(): Promise<void>;
812856
/**
813857
* Adjusts the frame rate. Only available in Chrome, Edge and Safari.
814858
* Only available when the camera is open.
@@ -830,6 +874,7 @@ export default class CameraEnhancer implements ImageSource {
830874
* @category Camera Settings
831875
*/
832876
getFrameRate(): number;
877+
private _setFocus;
833878
/**
834879
* Adjusts the focus distance. Only available in Chrome and Edge.
835880
* Only available when the camera is open.
@@ -840,7 +885,22 @@ export default class CameraEnhancer implements ImageSource {
840885
* @see [[getFocus]],[[getCapabilities]]
841886
* @category Camera Settings
842887
*/
843-
setFocus(mode: string, distance?: number): Promise<void>;
888+
setFocus(settings: string | {
889+
mode: string;
890+
} | {
891+
mode: "manual";
892+
distance: number;
893+
} | {
894+
mode: "manual";
895+
area: {
896+
centerPoint: {
897+
x: string;
898+
y: string;
899+
};
900+
width?: string;
901+
height?: string;
902+
};
903+
}, distance?: number): Promise<void>;
844904
/**
845905
* Get the focus distance.
846906
* Only available when the camera is open.
@@ -849,12 +909,16 @@ export default class CameraEnhancer implements ImageSource {
849909
* ```
850910
* @see [[setFocus]],[[getCapabilities]]
851911
* @category Camera Settings
912+
* @deprecated
852913
*/
853914
getFocus(): Object;
854-
private _setHardwareScale;
855-
private _getHardwareScale;
856-
private _setSoftwareScale;
857-
private _getSoftwareScale;
915+
getFocusSettings(): Object;
916+
private _setFocusAndGetContract;
917+
private _doFocusDetail;
918+
private _setLocalFocus;
919+
enableTapToFocus(): Promise<void>;
920+
disableTapToFocus(): void;
921+
isTapToFocusEnabled(): boolean;
858922
/**
859923
* Might be called when:
860924
* 1. container resizes;
@@ -901,6 +965,10 @@ export default class CameraEnhancer implements ImageSource {
901965
region?: Region;
902966
pixelFormat?: PixelFormat;
903967
scale?: number;
968+
scaleCenter?: {
969+
x: string;
970+
y: string;
971+
};
904972
}): DCEFrame;
905973
/**
906974
* @private
@@ -927,6 +995,7 @@ export default class CameraEnhancer implements ImageSource {
927995
* @see [[maxNumberOfFramesInBuffer]],[[numberOfFramesInBuffer]]
928996
*/
929997
getFrameFromBuffer(index?: number): DCEFrame;
998+
clearFrameBuffer(): void;
930999
/**
9311000
* Force lose webgl context.
9321001
* @private
@@ -944,6 +1013,7 @@ export default class CameraEnhancer implements ImageSource {
9441013
*/
9451014
private _updateDrawingLayersSize;
9461015
_createDrawingLayer(drawingLayerId?: number): import("./drawinglayer").default;
1016+
deleteDrawingLayer(drawingLayerId: number): void;
9471017
createDrawingLayer(): import("./drawinglayer").default;
9481018
getDrawingLayer(drawingLayerId: number): import("./drawinglayer").default;
9491019
getDrawingLayers(): import("./drawinglayer").default[];
@@ -953,6 +1023,10 @@ export default class CameraEnhancer implements ImageSource {
9531023
getDrawingStyles(): import("..").DrawingStyle[];
9541024
updateDrawingStyle(styleId: number, styleDefinition: any): void;
9551025
clearDrawingLayers(): void;
1026+
showTip(x: number, y: number, width: number, initialMessage?: string, duration?: number, autoShowSuggestedTip?: boolean): void;
1027+
hideTip(): void;
1028+
updateTipMessage(message: string): void;
1029+
suggestTip(occasion: string, message: string): void;
9561030
private _controler;
9571031
_createControler(): Controler;
9581032
_destroyControler(): void;

0 commit comments

Comments
 (0)