Resource Base
Table of contents

Auxiliary APIs

Name Description
on() Attach an event handler function for a built-in event.
off() Remove an event handler.
dispose() Releases all resources used by the CameraEnhancer instance.
getVersion() Returns the version of the library.
detectEnvironment() Returns a report on the current running environments.

on

Attach an event handler function for a built-in event.

on(eventName: EventName, listener: Function): void;

Parameters

eventName: specifies the event.

listener: specifies the handler function.

Return value

None.

Code Snippet

let enhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance();
enhancer.on("cameraChange", playCallBackInfo => {
    console.log(playCallBackInfo.deviceId);
});
enhancer.on("cameraOpen", playCallBackInfo => {
    console.log(playCallBackInfo.deviceId);
});
enhancer.on("cameraClose", playCallBackInfo => {
    console.log(playCallBackInfo.deviceId);
});
enhancer.on("resolutionChange", playCallBackInfo => {
    console.log("width:" + playCallBackInfo.width);
    console.log("height:" + playCallBackInfo.height);
});
enhancer.on("played", playCallBackInfo => {
    console.log(playCallBackInfo.deviceId);
});
enhancer.on("singleFrameAcquired", dceFrame => {
    document.body.appendChild(dceFrame.toCanvas());
});
enhancer.on("frameAddedToBuffer", () => {
    let dceFrame = enhancer.getFrameFromBuffer();
    document.body.appendChild(dceFrame.toCanvas());
});

off

Remove an event handler.

off(eventName: EventName, listener: Function): void;

Parameters

eventName: specifies the event.

listener: specifies the handler function.

Return value

None.

Code Snippet

let enhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance();
let cameraChanged = playCallBackInfo => {
    console.log(playCallBackInfo.deviceId);
    enhancer.off("cameraChange", cameraChanged);
}
enhancer.on("cameraChange", cameraChanged);

dispose

Releases all resources used by the CameraEnhancer instance.

The HTML elements used by the instance’s UI element are only removed when removeUIElement is set to true. Otherwise, they are only hidden.

dispose(removeUIElement?: boolean): void;

Parameters

removeUIElement: whether to hide or remove the HTML elements in the instance’s UI element.

Return value

None.

Code Snippet

let enhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance();
// Use the object to perform some tasks
enhancer.dispose();

getVersion

Returns the version of the library.

static getVersion(): string;

Parameters

None.

Return value

The version string of the library.

Code Snippet

Dynamsoft.DCE.CameraEnhancer.getVersion(); // 'JS 1.0.0.20210628'

detectEnvironment

Returns a report (in JSON) on the current running environments.

static detectEnvironment(): Promise<any>;

Parameters

None.

Return value

A JSON object about the running environment. For example

{
    "wasm": true,
    "worker": true,
    "getUserMedia": true,
    "camera": true,
    "browser": "Chrome",
    "version": 90,
    "OS": "Windows"
}

Code Snippet

await Dynamsoft.DCE.CameraEnhancer.detectEnvironment();

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article:

version 2.3.2

  • Latest version(4.0.3)
  • Version 4.x
    • Version 4.0.2
    • Version 4.0.1
    • Version 4.0.0
  • Version 3.x
    • Version 3.3.10
    • Version 3.3.9
    • Version 3.3.8
    • Version 3.3.7
    • Version 3.3.6
    • Version 3.3.5
    • Version 3.3.4
    • Version 3.3.3
    • Version 3.3.2
    • Version 3.3.1
    • Version 3.3.0
    • Version 3.2.0
    • Version 3.1.0
    • Version 3.0.1
    • Version 3.0.0
  • Version 2.x
    • Version 2.3.5
    • Version 2.3.2
    • Version 2.3.1
    • Version 2.3.0
    • Version 2.1.4
    • Version 2.1.3
    • Version 2.1.0
    • Version 2.0.0
  • Documentation Homepage
Change +