Resource Base
Table of contents

Dynamsoft Camera Enhancer JavaScript API Reference

Class CameraEnhancer

Create and Destroy Instances

Name Description
static createInstance() Initializes a new instance of the CameraEnhancer class.
dispose() Releases all resources used by the CameraEnhancer instance.
disposed Returns whether the CameraEnhancer instance has been disposed of.

Basic Camera Control

Name Description
cameraOpenTimeout Specifies the timeout in milliseconds for opening the camera.
close Closes the currently active camera and stops the video stream.
getAllCameras Retrieves a list of all available video input devices (cameras) on the current device.
getAvailableResolutions Retrieves a list of available resolutions supported by the currently selected camera.
getCameraState Retrieves the current state of the camera.
getResolution Gets the current resolution of the video stream.
getSelectedCamera Returns the currently selected camera device.
getVideoSettings Retrieves the current video settings applied to the camera stream.
ifSaveLastUsedCamera Determines whether the last used camera settings should be saved and reused the next time the CameraEnhancer is initialized.
ifSkipCameraInspection Determines whether to skip the initial camera inspection process.
isOpen Checks if the camera is currently open and streaming video.
isPaused Checks if the video stream is currently paused.
open Opens the currently selected camera and starts the video stream.
pause Pauses the video stream without closing the camera.
resume Resumes the video stream from a paused state.
selectCamera Selects a specific camera for use by the CameraEnhancer.
setResolution Sets the resolution of the video stream to a specified value.
testCameraAccess Tests whether the application has access to the camera.
updateVideoSettings Updates the video settings for the camera stream with new constraints.
videoSrc Sets or returns the source URL for the video stream to be used by the CameraEnhancer.

Advanced Camera Control

Name Description
disableEnhancedFeatures Disables one or more previously enabled enhanced features.
enableEnhancedFeatures Enables one or more enhanced features that require a license.
getAutoZoomRange Retrieves the current auto zoom range settings for the camera.
getCameraSettings Retrieves the current settings of the camera.
getCapabilities Gets the capabilities of the current camera.
getColorTemperature Retrieves the current color temperature setting of the camera’s video feed.
getExposureCompensation Retrieves the current exposure compensation setting of the camera’s video feed.
getFocusSettings Retrieves the current focus settings of the camera.
getFrameRate Retrieves the current frame rate of the camera’s video stream.
getZoomSettings Retrieves the current zoom settings of the camera.
resetZoom Resets the zoom level of the camera to its default value.
setAutoZoomRange Sets the auto zoom range for the camera.
setColorTemperature Sets the color temperature of the camera’s video feed.
setExposureCompensation Sets the exposure compensation of the camera’s video feed.
setFocus Sets the focus mode of the camera.
setFrameRate Sets the frame rate of the camera’s video stream.
setZoom Sets the zoom level of the camera.
turnOffTorch Turns off the camera’s torch (flashlight) mode.
turnOnTorch Turns on the camera’s torch (flashlight) mode, if supported.

Frame Acquisition

Name Description
addImageToBuffer Adds an image to the internal buffer.
clearBuffer Clears all images from the buffer, resetting the state for new image fetching.
fetchImage Fetches the current frame from the camera’s video feed.
getBufferOverflowProtectionMode Retrieves the current mode for handling buffer overflow.
getColourChannelUsageType Retrieves the current usage type for color channels in images.
getImage Retrieves a buffered image, of type DSImageData.
getImageCount Retrieves the current number of images in the buffer.
getImageFetchInterval Retrieves the current interval at which images are continuously fetched from the camera’s video feed.
getMaxImageCount Retrieves the maximum number of images that can be buffered.
getPixelFormat Retrieves the current pixel format used for images fetched from the camera.
getScanRegion Retrieves the current scan region set within the camera’s view.
hasImage Checks if an image with the specified ID is present in the buffer.
hasNextImageToFetch Determines whether there are more images available to fetch.
isBufferEmpty Determines whether the buffer is currently empty.
setBufferOverflowProtectionMode Sets the behavior for handling new incoming images when the buffer is full.
setColourChannelUsageType Sets the usage type for color channels in images.
setErrorListener Sets an error listener to receive notifications about errors that occur during image source operations.
setImageFetchInterval Sets the interval at which images are continuously fetched from the camera’s video feed.
setMaxImageCount Sets the maximum number of images that can be buffered at any time.
setNextImageToReturn Sets the processing priority of a specific image so that it is returned the next time getImage() is called.
setPixelFormat Sets the pixel format for the images fetched from the camera.
setScanRegion Sets the scan region within the camera’s view which limits the frame acquisition to a specific area of the video feed.
singleFrameMode Controls the single-frame mode of the CameraEnhancer.
startFetching Starts the process of fetching images.
stopFetching Stops the process of fetching images.
takePhoto Initiates a sequence to capture a single frame/image, halting the video stream temporarily.

UI

Name Description
convertToPageCoordinates Converts coordinates from the video’s coordinate system to coordinates relative to the whole page.
convertToClientCoordinates Converts coordinates from the video’s coordinate system to coordinates relative to the viewport.
setCameraView Sets the CameraView instance to be used with the CameraEnhancer.
getCameraView Retrieves the current CameraView instance associated with the CameraEnhancer.
getVideoEl Retrieves the HTMLVideoElement used by the CameraEnhancer for displaying the camera feed.

Auxiliary

Name Description
on() Registers an event listener for specific camera-related events.
off() Removes an event listener previously registered with the on method.

View Classes

Class CameraView

Name Description
static createInstance Initializes a new instance of the CameraView class with optional UI customization.
dispose Releases all resources used by the CameraView instance.
disposed Returns whether the CameraView instance has been disposed of.
static defaultUIElementURL Specifies the URL to a default UI definition file.
getUIElement Retrieves the current UI element associated with the CameraView instance.
setUIElement Sets a specific HTMLDivElement as the UI element for the CameraView instance.
createDrawingLayer Creates a new DrawingLayer object.
getDrawingLayer Retrieves a DrawingLayer object by its unique identifier (ID).
getAllDrawingLayers Returns an array of all DrawingLayer objects managed by this instance.
clearUserDefinedDrawingLayers Clears all user-defined DrawingLayer objects.
deleteUserDefinedDrawingLayer Deletes a user-defined DrawingLayer object by ID.
clearAllInnerDrawingItems Clears all system-defined DrawingItem objects while keeping user-defined ones.
getVideoElement Retrieves the HTMLVideoElement used for displaying video.
setVideoFit Sets the object-fit CSS property of the HTMLVideoElement.
getVideoFit Retrieves the current value of the object-fit CSS property.
getVisibleRegionOfVideo Returns the region of the video that is currently visible to the user.
setScanRegionMaskStyle Sets the style of the scan region mask, including line width, stroke color, and fill color.
getScanRegionMaskStyle Retrieves the current style of the scan region mask.
setScanRegionMaskVisible Sets the visibility of the scan region mask.
isScanRegionMaskVisible Checks if the scan region mask is currently visible.
setScanLaserVisible Sets the visibility of the scan laser effect.
isScanLaserVisible Checks if the scan laser effect is currently visible.
getTipConfig Retrieves the current configuration of the tip message box.
setTipConfig Applies configuration settings to the tip message box.
setTipVisible Controls the visibility of the tip message box on the screen.
isTipVisible Checks whether the tip message box is currently visible.
updateTipMessage Updates the message displayed in the tip message box.

Class ImageEditorView

Name Description
static createInstance Initializes a new instance of the ImageEditorView class.
dispose Releases all resources used by the ImageEditorView instance.
disposed Returns whether the ImageEditorView instance has been disposed of.
getUIElement Returns the HTMLDivElement, where the ImageEditorView UI is loaded.
setUIElement Sets a specific HTMLDivElement, where the UI element for the ImageEditorView will be loaded.
setOriginalImage Sets the image to be drawn on the ImageEditorView.
getOriginalImage Returns the current image drawn on the ImageEditorView.
createDrawingLayer Creates a new DrawingLayer object and returns it.
getDrawingLayer Retrieves a DrawingLayer object by its unique identifier (ID).
getAllDrawingLayers Returns an array of all DrawingLayer objects managed by this DrawingLayerManager.
clearUserDefinedDrawingLayers Clears all user-defined DrawingLayer objects.
deleteUserDefinedDrawingLayer Deletes a user-defined DrawingLayer object specified by its unique identifier (ID).
getSelectedDrawingItems Asynchronously returns an array of all selected DrawingItem instances across different layers.

Auxiliary Classes

CameraEnhancerModule

Name Description
static getVersion() Returns the version of the CameraEnhancer Module.

DrawingItem

Name Description
coordinateBase Returns or sets the coordinate system base.
drawingLayerId Returns the numeric ID for the DrawingLayer this DrawingItem belongs to.
drawingStyleId Returns or sets the numeric ID for the DrawingStyle that applies to this DrawingItem.
mediaType Returns an enumeration value which indicates the type of this DrawingItem (e.g., image, line, text).
getState() Returns the current state of the DrawingItem
on() Binds a listener for a specific event. eventName.
off() Unbinds a listener for a specific event.
addNote() Adds a Note object to this DrawingItem.
getNote() Returns a Note object specified by its name, if it exists.
getNotes() Returns a collection of all existing Note objects on this DrawingItem.
hasNote() Checks if a Note object with the specified name exists.
updateNote() Updates the content of a specified Note object.
deleteNote() Deletes a Note object specified by its name.
clearNotes() Deletes all Note objects on this DrawingItem.

Child classes based on DrawingItem

ImageDrawingItem

Name Description
constructor ImageDrawingItem() Constructor for the class.
maintainAspectRatio Determines whether the image’s aspect ratio should be maintained when it is drawn.
getImage() Retrieves the current image being used for drawing.
setImage() Sets the image to be used for drawing.
getImageRect() Returns the rectangle area within which the image is drawn.
setImageRect() Sets the rectangle area within which the image should be drawn.

LineDrawingItem

Name Description
constructor LineDrawingItem() Constructor for the class.
getLine() Retrieves the current line being used for drawing.
setLine() Sets the line to be used for drawing.

QuadDrawingItem

Name Description
constructor QuadDrawingItem() Constructor for the class.
getQuad() Retrieves the current quadrilateral being used for drawing.
setQuad() Sets the quadrilateral to be used for drawing.

RectDrawingItem

Name Description
constructor RectDrawingItem() Constructor for the class.
getRect() Retrieves the current rectangle being used for drawing.
setRect() Sets the rectangle to be used for drawing.

TextDrawingItem

Name Description
constructor TextDrawingItem() Constructor for the class.
getText() Retrieves the current text being used for drawing.
setText() Sets the text to be used for drawing.
getTextRect() Returns the rectangle area within which the text is drawn.
setTextRect() Sets the rectangle area within which the text should be drawn.

DrawingLayer

Name Description
getId() Retrieves the unique identifier of the layer.
isVisible() Retrieves the visibility status of the layer.
setVisible() Sets the visibility of the layer.
setDefaultStyle() Establishes the baseline styling preferences for DrawingItem objects on the layer.
addDrawingItems() Adds an array of DrawingItem objects to the layer.
removeDrawingItems() Removes specified DrawingItem objects from the layer.
setDrawingItems() Sets the layer’s DrawingItem objects, replacing any existing items.
getDrawingItems() Retrieves DrawingItem objects from the layer, optionally filtered by a custom function.
hasDrawingItem() Checks if a specific DrawingItem exists within the layer.
clearDrawingItems() Clears all DrawingItem objects from the layer.
renderAll() Forces a re-render of all DrawingItem objects on the layer.

DrawingStyleManager

Name Description
static createDrawingStyle() Generates a new DrawingStyle object, providing its unique ID.
static getDrawingStyle() Retrieves a specific DrawingStyle object using its ID.
static getDrawingStyles() Fetches a collection of all available DrawingStyle objects.
static updateDrawingStyle() Modifies an identified DrawingStyle object by its ID.

Feedback

Name Description
static beep() Initiates a beep sound upon invocation.
static beepSoundSource Returns or sets the beep’s sound source.
static vibrate() Activates device vibration upon invocation.
static vibrateDuration Determines the vibration’s duration in milliseconds.

Interfaces

Enumerations

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • 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 +