Web Demos

BARCODE READER SDK DEMO

Explore the flexibe barcode reading settings to optimize for your specific usage scenario.

WEB TWAIN SDK DEMO

Try the most popular web scanner features: scan images, import local images and PDF files, edit, save to local, upload to database, and etc.

BARCODE READER JAVASCRIPT DEMO

Transform any camera-equipped devices into real-time, browser-based barcode and QR code scanners.

MRZ SCANNER WEB DEMO

Detects the machine-readable zone of a passport, scans the text, and parses into human-readable data.

APP STORE DEMOS

BARCODE READER SDK FOR IOS

BARCODE READER SDK FOR ANDROID

VIEW MORE DEMOS >
Dev Center
Table of contents

{WebTwainObject}.Addon.Camera

{WebTwainObject} denotes the WebTwain instance.

Dynamsoft provides a built-in feature to handle camera capturing, prospective adjusting, etc. Check out the APIs showVideo() and closeVideo(). Please NOTE that these two APIs should not be mixed with other more specific APIs like play(), pause() and stop(), etc.

Methods

       
getSourceList() selectSource() getCurrentSource() closeSource()
getResolution() setResolution() getCurrentResolution() play()
pause() resume() stop() getStatus()
capture() showVideo() closeVideo()  

Events

   
video-closed video-error

getSourceList

Syntax

/**
 * Return a list of all available cameras.
 */
getSourceList(): Promise<DeviceInfo[]>;

interface DeviceInfo{
    deviceId: string;
    label: string;
}

Example

DWObject.Addon.Camera.getSourceList();

selectSource

Syntax

/**
 * Select a camera to use.
 * @param deviceId Specify the camera with its deviceId.
 */
selectSource(deviceId: string): Promise<DeviceInfo>;

getCurrentSource

Syntax

/**
 * Return the info about the current camera.
 */
getCurrentSource():DeviceInfo;

closeSource

Syntax

/**
 * Close the current camera.
 */
closeSource(): Promise<DeviceInfo>;

getResolution

Syntax

/**
 * Return the resolutions supported by the current camera.
 */
getResolution(): Promise<Resolution[]>

interface Resolution{
    width: number;
    height: number;
}

setResolution

Syntax

/**
 * Set the resolution for the current camera.
 * @param resolution Specify the resolution.
 */
setResolution(resolution: Resolution): Promise<Resolution>;

getCurrentResolution

Syntax

/**
 * Return the resolution of the current camera.
 */
getCurrentResolution(): Promise<Resolution>;

Usage notes

If the camera is playing, the actual resolution is returned. If the camera is not playing, the last set resolution or null is returned.


play

Syntax

/**
 * Start streaming video from the current camera.
 * @param element Specify an HTML element to put the video stream in.
 * @param resolution Specify the initial resolution.
 * @param fill Whether to fill the viewer space with the video stream and leave no margin. The default value is `false`.
 */
play(element?: HTMLElement,
    resolution?: Resolution,
    fill?: boolean
): Promise<Resolution>;

Usage notes

If no camera is chosen, the default camera is used.

If the method is called without arguments or null is passed to element , the video will show in the main viewer.


pause

Syntax

/**
 * Pause the video stream.
 */
pause(): void;

resume

Syntax

/**
 * Resume the video stream.
 */
resume(): void;

stop

Syntax

/**
 * Stop the video stream.
 */
stop(): void;

getStatus

Syntax

/**
 * Return the status of the current camera.
 */
getStatus(): string;

Usage notes

The status string is either empty or one of the following: “playing”, “paused”, “stopped”. An empty string means no camera is open.


capture

Syntax

/**
 * Capture a frame from the video stream.
 */
capture(): Promise<Blob>;

showVideo

Syntax

/**
 * Start streaming video from the current camera in the viewer.
 * @param deviceId Specify a camera.
 * @param resolution Specify the initial resolution.
 * @param mode Specify the mode.
 * @param fill Whether to fill the viewer area with the video stream and leave no margin.
 */
showVideo(deviceId?: string,
    resolution?: Resolution,
    mode?: string,
    fill?: boolean
): Promise<Resolution>;

Usage notes

There are two available modes: document and picture .

  • picture: border detection is turned off and supports taking images consecutively. This is the default mode.
  • document: border detection will be on and only supports taking one image at a time.

closeVideo

Syntax

/**
 * Close the camera and hide the video streaming UI.
 */
closeVideo(): void;

video-closed

Syntax

/**
 * This event is triggered when the video is closed.
 */
on("video-closed", callback: () => void): boolean;

video-error

Syntax

/**
 * This event is triggered when the video playing operation. throws out an error.
 * @argument errorCode The error code.
 * @argument errorString The error string.
 */
on("video-error", callback: (errorCode, errorString) => void): boolean;

Is this page helpful?

YesYes NoNo

In this article:

version 17.1.1

  • Latest Version
  • Version 17.2.1
  • Version 17.1.1
  • Version 17.0
  • Version 16.2
  • Version 16.1.1
Change +
© 2003–2022 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support