JavaScript API Reference
CameraEnhancer
Initialization
| Name | Description |
|---|---|
| createInstance() | Creates a CameraEnhancer instance. |
| defaultUIElementURL | Returns or sets the URL of the .html file that defines the default UI Element. |
| getUIElement() | Returns the HTML element that is used by the CameraEnhancer instance. |
| setUIElement() | Specifies an HTML element for the CameraEnhancer instance to use as its UI element. |
| onWarning | A callback which is triggered when the running environment is not ideal. |
| testCameraAccess | Test whether there is an available camera. |
Camera Control
| Name | Description |
|---|---|
| ifSkipCameraInspection | Returns or sets whether to skip camera inspection at initialization to save time. |
| ifSaveLastUsedCamera | Returns or sets whether to save the last used camera and resolution. |
| 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() | Turn 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. |
| 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. |
| getResolutions() | Returns the resolutions supported by the current video input. |
| videoSrc | Sets or returns the source of the video. |
| cameraOpenTimeout | Control the maximum time allowed for opening a selected camera. |
Advanced Camera Control
| Name | Description |
|---|---|
| setFrameRate() | Adjusts the frame rate. |
| getFrameRate() | Returns the real-time frame rate. |
| turnOnTorch() | Turns on the torch/flashlight if the current camera supports it. |
| turnOffTorch() | Turns off the torch/flashlight. |
| getZoomSettings() | Returns the zoom settings. |
| setZoom() | Zooms the video stream. |
| resetZoom() | Resets the zoom level of the video. |
| getFocusSettings() | Returns the focus settings. |
| setFocus() | Sets how the camera focuses. |
| enableTapToFocus() | Enables manual camera focus when clicking/tapping on the video. |
| disableTapToFocus() | Disables manual camera focus when clicking/tapping on the video. |
| isTapToFocusEnabled() | Returns whether clicking/tapping on the video invokes the camera to focus. |
| getCapabilities() | Inspects and returns the capabilities of the selected camera. |
| getCameraSettings() | Returns the current values for each constrainable property of the selected camera. |
| getColorTemperature() | Returns the color temperature of the selected camera. |
| setColorTemperature() | Adjusts the color temperature of the selected camera. |
| getExposureCompensation() | Returns the exposure compensation index of the selected camera. |
| setExposureCompensation() | Sets the exposure compensation index of the selected camera. |
Frame Acquisition
| Name | Description |
|---|---|
| setScanRegion() | Specifies which part of the original video is considered when processing frames. |
| getScanRegion() | Returns the scan region. |
| getFrame() | Returns a DCEFrame object which contains the image data of the latest frame from the video input. |
| getFrameFromBuffer() | Returns a DCEFrame object which contains the image data of the specified buffered frame. |
| clearFrameBuffer() | Removes all buffered frames. |
| startFetchingLoop() | Starts a fetching loop that continuously put frames in a buffer. |
| stopFetchingLoop() | Stops the fetching loop. |
| isFetchingLoopStarted() | Returns the state of the fetching loop. |
| framePixelFormat | Sets or returns the pixel format of the images generated by getFrame(). |
| maxNumberOfFramesInBuffer | Sets or returns how many frames can be buffered. |
| numberOfFramesInBuffer | Returns how many frames there are in the buffer. |
| loopInterval | Returns or sets the start time of the next fetch operation. |
| singleFrameMode | Returns or sets whether to enable the singe-frame mode. |
UI
| Name | Description |
|---|---|
| getVisibleRegion() | Returns a Region object which specifies which part of the original video is shown in the video element. |
| addScanRegionOverlayCanvas() | Adds a canvas of the same size as the scan area directly above the scan area. |
| removeScanRegionOverlayCanvas() | Removes the specified Canvas element. |
| ifShowScanRegionMask | Returns or sets whether the scan region mask is shown. |
| ifShowScanRegionLaser | Returns or sets whether the laser indicator is shown in the scan region. |
| setScanRegionMaskStyle() | Sets the styles for the scan region mask. |
| setVideoFit() | Sets the object-fit CSS property of the video element. |
| getVideoFit() | Returns the value of the object-fit CSS property of the video element. |
| setViewDecorator() | Sets and shows the view decorator. |
| getViewDecorator() | Gets what view decorator is shown. |
| setViewDecoratorLineWidth() | Sets the line width for drawing the view decorator. |
| setViewDecoratorStrokeStyle() | Sets the stroke style for drawing the view decorator. |
| setViewDecoratorFillStyle() | Sets the fill style for drawing the view decorator. |
| setViewDecoratorMaskFillStyle() | Sets the fill style for drawing the ask for the view decorator. |
| createDrawingLayer() | Creates a DrawingLayer object and put it in an array of DrawingLayers. |
| deleteDrawingLayer() | Deletes a DrawingLayer object specified by its ID. |
| getDrawingLayer() | Gets the DrawingLayer specified by its ID. |
| getDrawingLayers() | Returns an array of all DrawingLayer objects. |
| clearDrawingLayers() | Removes all DrawingLayers. |
| createDrawingStyle() | Creates a new DrawingStyle object and returns its ID. |
| getDrawingStyle() | Returns the DrawingStyle object specified by its Id. |
| getDrawingStyles() | Returns all DrawingStyle objects. |
| updateDrawingStyle() | Updates an existing DrawingStyle specified by its ID. |
| setOriginalImage() | Sets the original image to be drawn on the editor canvas. |
| getOriginalImage() | Returns the original image shown on the editor. |
| showOriginalImage() | Shows the original image. |
| hideOriginalImage() | Hides the original image. |
| deleteOriginalImage() | Deletes the original image and remove the canvas that shows it. |
| getSelectedDrawingItems() | Returns the selected DrawingItem object(s). |
| showTip() | Shows a Tip message. |
| hideTip() | Hides the Tip message. |
| updateTipMessage() | Changes the Tip message. |
| onTipSuggested() | An event that gets triggered whenever a Tip is suggested. |
| convertToPageCoordinates() | Converts coordinates of a point to the coordinates relative to the top left point of the entire document. |
| convertToClientCoordinates() | Converts coordinates of a point to the coordinates within the application’s viewport at which the event occurred (as opposed to the coordinate within the page). |
Auxiliary APIs
| Name | Description |
|---|---|
| on() | Attaches an event handler function for a built-in event. |
| off() | Removes an event handler. |
| offAll() | Removes all event handlers from the specified event. If no event is specified, remove all event handlers. |
| dispose() | Releases all resources used by the CameraEnhancer instance. |
| disposed | A readonly boolean value indicating whether the CameraEnhancer instance has been disposed. |
| getVersion() | Returns the version of the library. |
| detectEnvironment() | Returns a report on the current running environments. |
DrawingLayer
| Name | Description |
|---|---|
| getId() | Returns the ID of the DrawingLayer. |
| addDrawingItems() | Adds DrawingItem(s) to the DrawingLayer. |
| getDrawingItems() | Returns all DrawingItem(s) or just some of them based on a filter function. |
| setDrawingItems() | Replaces all DrawingItem(s) of the DrawingLayer with new ones. |
| hasDrawingItem() | Checks out if a DrawingItem belongs to the layer. |
| removeDrawingItems() | Removes DrawingItem(s) from the DrawingLayer. |
| clearDrawingItems() | Removes all DrawingItem(s) from the DrawingLayer. |
| setDrawingStyle() | Sets the style for the DrawingLayer or for a particular mediaType or for a particular mediaType in a particular state. |
| setVisible() | Shows or hides the DrawingLayer. |
| isVisible() | Returns whether the DrawingLayer is visible. |
| renderAll() | Renders all DrawingItems, usually required when the style for one or more items is changed. |
| onSelectionChange() | An event handler that is triggered when different DrawingItem(s) gets selected/deselected on the DrawingLayer. |
| setMode() | Changes the mode of the layer. |
| getMode() | Returns the current mode. |
DrawingItem
| Type Name | Description |
|---|---|
| DT_Rect | Defines a DrawingItem the shape of a rectangle. |
| DT_Arc | Defines a DrawingItem the shape of a arc. |
| DT_Line | Defines a DrawingItem the shape of a line. |
| DT_Polygon | Defines a DrawingItem the shape of a polygon. |
| DT_Text | Defines a DrawingItem that draws text. |
| DT_Image | Defines a DrawingItem that draws an image. |
| DT_Group | Defines a DrawingItem which is a combination of more than one DrawingItem of the other six types. |