Resource Base
Table of contents

Camera Control

Basic Control

Name Description
getAllCameras() Returns information of all available cameras on the device.
selectCamera() Chooses a camera as the video source.
getSelectedCamera() Returns information about the selected / current camera.
open() Turns on the camera to start streaming live video.
close() Stops video streaming and releases the camera.
isOpen() Returns whether the selected camera is turned on / occupied.
onPlayed Defines a callback which is triggered when the video streaming first starts or restarts when its source (camera) or resolution changes.
pause() Pauses video streaming without releasing the camera.
resume() Resumes video streaming.
setResolution() Sets the resolution of the current video input.
getResolution() Returns the resolution of the current video input.

Advanced Control

Name Description
setFrameRate() Adjusts the frame rate.
getFrameRate() Returns the real-time frame rate.
turnOnTorch() Turns on the torch/flashlight.
turnOffTorch() Turns off the torch/flashlight.
setZoom() Sets the zoom level of the video.
getCapabilities() Inspects and returns the capabilities of the selected camera.
setColorTemperature() Adjusts the color temperature of the selected camera.
setExposureCompensation() Sets the exposure compensation index of the selected camera.

getAllCameras

Returns information of all available cameras on the device.

getAllCameras(): Promise<VideoDeviceInfo[]>

Parameters

None.

Return value

A promise resolving to an array of VideoDeviceInfo objects.

Code Snippet

let cameras = await enhancer.getAllCameras();
if (cameras.length) {
    await enhancer.selectCamera(cameras[0]);
}

See also

VideoDeviceInfo

selectCamera

Chooses a camera as the video source.

If called before open() or show(), the selected camera will be used. Otherwise, the system will decide which one to use.

selectCamera(cameraObjectOrDeviceID: VideoDeviceInfo | string): Promise<PlayCallbackInfo>

Parameters

cameraObjectOrDeviceID: specifies the camera.

Return value

A promise resolving to a PlayCallbackInfo object.

Code Snippet

let cameras = await enhancer.getAllCameras();
if (cameras.length) {
    await enhancer.selectCamera(cameras[0]);
}

See also

PlayCallbackInfo

getSelectedCamera

Returns information about the selected / current camera.

getSelectedCamera(): Promise<VideoDeviceInfo | null>

Parameters

None.

Return value

A promise resolving to a VideoDeviceInfo object.

Code Snippet

let camera = await enhancer.getSelectedCamera();

See also

VideoDeviceInfo

open

Turns on the camera to start streaming live video.

open(): void

Parameters

None.

Return value

None.

close

Stops video streaming and releases the camera.

close(): void

Parameters

None.

Return value

None.

isOpen

Returns whether the selected camera is turned on / occupied.

isOpen(): boolean

Parameters

None.

Return value

true means the camera is turned on and false the opposite.

onPlayed

Defines a callback which is triggered when the video streaming first starts or restarts when its source (camera) or resolution changes.

onPlayed: (playCallBackInfo:PlayCallBackInfo) => {}

Arguments

playCallBackInfo: returns the resolution of the video input.

Code Snippet

let pEnhancer = null;
(async () => {
    let enhancer = await (pEnhancer = pEnhancer || Dynamsoft.DCE.CameraEnhancer.createInstance());
    enhancer.onPlayed = playCallBackInfo => {
        console.log(playCallBackInfo.width);
    };
    await enhancer.open();
})();

See also

PlayCallbackInfo

pause

Pauses video streaming without releasing the camera.

pause(): void

Parameters

None.

Return value

None.

resume()

Resumes video streaming.

resume(): void

Parameters

None.

Return value

None.

setResolution

Sets the resolution of the current video input. If the specified resolution is not exactly supported, the closest resolution will be applied.

setResolution(width: number, height: number): Promise<PlayCallbackInfo>

Parameters

width: specifies the horizontal resolution.

height: specifies the vertical resolution.

Return value

A promise resolving to a PlayCallbackInfo object.

Code Snippet

await enhancer.setResolution(width, height);

See also

PlayCallbackInfo

getResolution

Returns the resolution of the current video input.

getResolution(): [number, number]

Parameters

None.

Return value

An array of two numbers representing the resolution in the sequence of [width, height].

Code Snippet

let resolution = enhancer.getResolution();
console.log(resolution[0] + " x " + resolution[1]);

setFrameRate

Adjusts the frame rate.

At present, this method only works in Edge, Safari, Chrome and other Chromium-based browsers (Firefox is not supported). Also, it should be called when a camera is open.

setFrameRate(rate: number): Promise<void>

Parameters

rate: specifies the new frame rate.

Return value

A promise that resolves when the operation succeeds.

Code Snippet

await enhancer.setFrameRate(10);

See also

getCapabilities

getFrameRate

Returns the real-time frame rate.

getFrameRate(): number;

Parameters

None.

Return value

The calculated real-time frame rate.

Code Snippet

await enhancer.getFrameRate();

turnOnTorch

Turns on the torch/flashlight.

This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported.

turnOnTorch(): Promise<void>

Parameters

None.

Return value

A promise that resolves when the operation succeeds.

Code Snippet

await enhancer.turnOnTorch();

See also

turnOffTorch

getCapabilities

turnOffTorch

Turns off the torch/flashlight.

This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported.

turnOffTorch(): Promise<void>

Parameters

None.

Return value

A promise that resolves when the operation succeeds.

Code Snippet

await enhancer.turnOffTorch();

See also

turnOnTorch

getCapabilities

setZoom

Sets the zoom level of the video.

This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported.

setZoom(zoomValue: number): Promise<void>

Parameters

zoomValue: specifies the zoom level.

Return value

A promise that resolves when the operation succeeds.

Code Snippet

await enhancer.setZoom(2);

See also

getCapabilities

getCapabilities

Inspects and returns the capabilities of the selected camera.

getCapabilities(): MediaTrackCapabilities

Parameters

None.

Return value

A MediaTrackCapabilities object which specifies the values or range of values for each constrainable property of the current camera.

Code Snippet

enhancer.getCapabilities();
/* Result sample
{
  aspectRatio: {max: 1280, min: 0.001388888888888889},
  brightness: {max: 64, min: -64, step: 1},
  colorTemperature: {max: 6500, min: 2800, step: 10},
  contrast: {max: 95, min: 0, step: 1},
  deviceId: "3a505c29a3312600ea0afd79f8e2b4ba4fba3e539257801ff1de8718c27f2bed",
  exposureMode: ["continuous", "manual"],
  exposureTime: {max: 10000, min: 39.0625, step: 39.0625},
  facingMode: [],
  focusDistance: {max: 1024, min: 0, step: 10},
  focusMode: ["continuous", "manual"],
  frameRate: {max: 30, min: 0},
  groupId: "35a82dcb7d5b0ef5bda550718d194f04a812c976175e926ccb81fb9d235d010f",
  height: {max: 720, min: 1},
  resizeMode: ["none", "crop-and-scale"],
  saturation: {max: 100, min: 0, step: 1},
  sharpness: {max: 7, min: 1, step: 1},
  whiteBalanceMode: ["continuous", "manual"],
  width: {max: 1280, min: 1}
}
*/

See also

MediaTrackCapabilities

setColorTemperature

Adjusts the color temperature of the selected camera.

This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported.

setColorTemperature(colorTemperatur: number): Promise<void>

Parameters

colorTemperatur: specifies the new color temperature.

Return value

A promise that resolves when the operation succeeds.

Code Snippet

await enhancer.setColorTemperature(5000);

See also

getCapabilities

setExposureCompensation

Sets the exposure compensation index of the selected camera.

This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported.

setExposureCompensation(exposureCompensation: number): Promise<void>

Parameters

exposureCompensation: specifies the new exposure compensation index.

Return value

A promise that resolves when the operation succeeds.

Code Snippet

await enhancer.setExposureCompensation(-0.7);

See also

getCapabilities

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

version 2.0.3

  • Latest version(4.0.2)
  • Version 4.x
    • 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
Change +