Fired when an error occurs during camera access.
The Error that was triggered.
Fired when a new frame is processed by the external Scandit Data Capture library. This event is fired on every frame, independently from the number of recognized barcodes or texts (can both be none). The returned barcodes and texts are affected by ScanSettings's codeDuplicateFilter and TextRecognitionSettings's textDuplicateFilter options.
The result of the scanning operation on the image.
Fired when the external Scandit Data Capture library has been loaded and the barcode picker can thus start to scan barcodes or texts.
Fired when new barcodes or texts are recognized in the image frame. The returned barcodes and texts are affected by ScanSettings's codeDuplicateFilter and TextRecognitionSettings's textDuplicateFilter options.
The result of the scanning operation on the image.
Fired when an error occurs during scanning initialization and execution. The barcode picker will be automatically paused when this happens.
The ScanditEngineError that was triggered.
Fired when a new frame is submitted to the external Scandit Data Capture library to be processed. As the frame is not processed yet, the ScanResult.barcodes property will always be empty (no results yet).
The result of the scanning operation on the image.
Access the currently set or default camera, requesting user permissions if needed. This method is meant to be used after the picker has been initialized with disabled camera access (accessCamera=false) or after pauseScanning has been called with the pause camera stream option. Calling this doesn't do anything if the camera is already being accessed.
Depending on device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:
AbortError
NoCameraAvailableError
NotAllowedError
NotFoundError
NotReadableError
SecurityError
In Single Image Mode this method has no effect.
A promise resolving to the updated BarcodePicker object when the camera is accessed.
See the on method.
The name of the event to listen to.
The listener function.
The updated BarcodePicker object.
Try to apply new settings to the currently used camera for video input, if no settings are passed the default ones are set.
If camera access is enabled, the camera is updated and accessed with the new settings. If not, the camera settings are stored and used for the future initial camera access.
Depending on device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:
AbortError
NoCameraAvailableError
NotAllowedError
NotFoundError
NotReadableError
SecurityError
In Single Image Mode this method has no effect.
The new camera options used when accessing the camera, by default hd
resolution is used.
A promise resolving to the updated BarcodePicker object when the camera is updated (and accessed, if camera access is currently enabled).
Apply a new set of scan settings to the internal scanner (replacing old settings).
The scan configuration object to be applied to the scanner.
The updated BarcodePicker object.
Clear the internal scanner session.
This removes all recognized barcodes/texts from the scanner session and allows them to be scanned again in case a custom codeDuplicateFilter and/or textDuplicateFilter option was set in ScanSettings or TextRecognitionSettings.
The updated BarcodePicker object.
Create a new parser object.
The format of the input data for the parser.
The newly created parser.
Stop scanning and displaying video output, remove HTML elements added to the page, destroy the internal Scanner (by default) and destroy the barcode picker itself; ensuring complete cleanup.
This method should be called after you don't plan to use the picker anymore, before the object is automatically cleaned up by JavaScript. The barcode picker must not be used in any way after this call.
If the Scanner is or will be in use for other purposes, the relative option can be passed to prevent its destruction.
Whether to destroy the internally used Scanner or not.
The currently active camera.
Whether a GUI button to switch between different cameras is shown (when available).
Whether the currently selected camera's video is mirrored along the vertical axis.
Whether camera zoom control via pinching gesture on the video is enabled (when available, only Chrome).
Whether a sound should be played on barcode/text recognition (iOS requires user input). Note that the sound is played if there's at least a barcode or text not rejected via ScanResult.rejectCode or ScanResult.rejectText.
Whether the barcode picker has loaded the external Scandit Data Capture library and is ready to scan.
Whether the scanning is currently paused.
Whether manual camera focus when clicking/tapping on the video is enabled (when available, only Chrome).
Whether a GUI button to toggle device torch on/off is shown (when available, only Chrome).
Whether the device should vibrate on barcode/text recognition (only Chrome & Firefox, requires user input). Note that the vibration is triggered if there's at least a barcode or text not rejected via ScanResult.rejectCode or ScanResult.rejectText.
Whether the picker is in a visible state or not.
Add the listener function to the listeners array for an event.
No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.
The name of the event to listen to.
The listener function.
The updated BarcodePicker object.
Add the listener function to the listeners array for the ready event, fired when the external Scandit Data Capture library has been loaded and the barcode picker can thus start to scan barcodes or texts. If the library has already been loaded the listener is called immediately.
No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.
The name of the event to listen to.
The listener function.
The updated BarcodePicker object.
Add the listener function to the listeners array for the submitFrame event, fired when a new frame is submitted to the external Scandit Data Capture library to be processed. As the frame is not processed yet, the ScanResult.barcodes and ScanResult.texts properties will always be empty (no results yet).
No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.
The name of the event to listen to.
The listener function, which will be invoked with a ScanResult object.
The updated BarcodePicker object.
Add the listener function to the listeners array for the processFrame event, fired when a new frame is processed. This event is fired on every frame, independently from the number of recognized barcodes or texts (can both be none). The returned barcodes and texts are affected by ScanSettings's codeDuplicateFilter and TextRecognitionSettings's textDuplicateFilter options.
No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.
The name of the event to listen to.
The listener function, which will be invoked with a ScanResult object.
The updated BarcodePicker object.
Add the listener function to the listeners array for the scan event, fired when new barcodes or texts are recognized in the image frame. The returned barcodes and texts are affected by ScanSettings's codeDuplicateFilter and TextRecognitionSettings's textDuplicateFilter options.
No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.
The name of the event to listen to.
The listener function, which will be invoked with a ScanResult object.
The updated BarcodePicker object.
Add the listener function to the listeners array for the scanError event, fired when an error occurs during scanning initialization and execution. The barcode picker will be automatically paused when this happens.
No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.
The name of the event to listen to.
The listener function, which will be invoked with an ScanditEngineError
object.
The updated BarcodePicker object.
Add the listener function to the listeners array for the cameraAccessError event, fired when an error occurs during camera access..
No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.
The name of the event to listen to.
The listener function, which will be invoked with an Error
object.
The updated BarcodePicker object.
Pause the recognition of codes/texts in the input image.
By default video from the camera is still shown, if the pauseCamera option is enabled the camera stream is paused (camera access is fully interrupted) and will be resumed when calling resumeScanning, setActiveCamera, setCameraType or accessCamera, possibly requesting user permissions if needed.
In Single Image Mode the input for submitting a picture is disabled.
Whether to also pause the camera stream.
The updated BarcodePicker object.
Reassign the barcode picker to a different HTML element.
All the barcode picker elements inside the current origin element will be moved to the new given one.
If an invalid element is given, a NoOriginElementError
error is thrown.
The HTMLElement into which all the necessary elements for the picker will be moved.
The updated BarcodePicker object.
Remove all listeners from the given event's listener array.
The name of the event from which to remove all listeners.
The updated BarcodePicker object.
Remove the specified listener from the given event's listener array.
The name of the event from which to remove the listener.
The listener function to be removed.
The updated BarcodePicker object.
Resume the recognition of codes/texts in the input image.
If the camera stream was stopped when calling pauseScanning, the camera stream is also resumed and user permissions are requested if needed to resume video input.
In Single Image Mode the input for submitting a picture is enabled.
The updated BarcodePicker object.
Select a camera to be used for video input, if no camera is passed, the default one (based on cameraType) is selected.
If camera access is enabled, the camera is enabled and accessed. If not, the camera is stored and used for the future initial camera access.
Depending on device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:
AbortError
NoCameraAvailableError
NotAllowedError
NotFoundError
NotReadableError
SecurityError
In Single Image Mode this method has no effect.
The new camera to be used, by default the automatically detected back camera is used.
The camera options used when accessing the camera, by default hd
resolution is used.
A promise resolving to the updated BarcodePicker object when the camera is set (and accessed, if camera access is currently enabled).
Show or hide a GUI button to switch between Wide and UltraWide cameras on iPhone devices (when available).
In Single Image Mode this method has no effect.
Whether to show a GUI button to switch between Wide and UltraWide cameras on specific iPhone devices.
The updated BarcodePicker object.
Show or hide a GUI button to switch between different cameras (when available).
In Single Image Mode this method has no effect.
Whether to show a GUI button to switch between different cameras.
The updated BarcodePicker object.
Select a camera to be used for video input by specifying the wanted camera type (facing mode/direction): the main camera detected for the given camera type will be used.
If camera access is enabled, the camera is enabled and accessed. If not, the camera type is stored and used for the future initial camera access.
If the target camera is already in use or no camera with the given type is found this method has no effect.
Depending on device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:
AbortError
NoCameraAvailableError
NotAllowedError
NotFoundError
NotReadableError
SecurityError
The new camera type (facing mode/direction) to be used for video input and Single Image Mode (when available).
A promise resolving to the updated BarcodePicker object when the camera is updated (and accessed, if camera access is currently enabled).
Set the GUI style for the picker.
In Single Image Mode this method has no effect.
When the GUI style is set to laser or viewfinder, the GUI will flash on barcode/text recognition. Note that the GUI will flash if there's at least a barcode or text not rejected via ScanResult.rejectCode or ScanResult.rejectText.
The new GUI style to be applied.
The updated BarcodePicker object.
Set the area of the laser displayed when the GUI style is set to laser (the laser will match the width and be vertically centered). Note that this functionality affects UI only and doesn't change the actual searchArea option set via ScanSettings. If no area is passed, the default automatic size behaviour is set, where the laser will match the current area of the image in which barcodes/texts are searched, controlled via the searchArea option in ScanSettings.
The new search area, by default the area will match ScanSettings's searchArea option.
The updated BarcodePicker object.
Enable or disable camera video mirroring along the vertical axis. By default front cameras are automatically mirrored. This setting is applied per camera and the method has no effect if no camera is currently selected.
In Single Image Mode this method has no effect.
Whether the camera video is mirrored along the vertical axis.
The updated BarcodePicker object.
Enable or disable camera zoom control via pinching gesture on the video (when available, only Chrome).
In Single Image Mode this method has no effect.
Whether to enable camera zoom control via pinching gesture on the video.
The updated BarcodePicker object.
Enable or disable playing a sound on barcode/text recognition (iOS requires user input).
The sound is played if there's at least a barcode or text not rejected via ScanResult.rejectCode or ScanResult.rejectText.
Whether a sound should be played on barcode/text recognition.
The updated BarcodePicker object.
Enable or disable manual camera focus when clicking/tapping on the video (when available, only Chrome).
In Single Image Mode this method has no effect.
Whether to enable manual camera focus when clicking/tapping on the video.
The updated BarcodePicker object.
Set the target frames per second to be processed by the external Scandit Data Capture library.
The final speed is limited by the camera framerate (usually 30 FPS) and the frame processing time of the device. By setting this to lower numbers devices can save power by performing less work during scanning operations, depending on device speed (faster devices can "sleep" for longer periods).
In Single Image Mode this method has no effect.
The target frames per second to be processed. Must be a number bigger than 0, by default set to 30.
The updated BarcodePicker object.
Enable or disable the torch/flashlight of the device (when available, only Chrome). Changing active camera or camera settings will cause the torch to become disabled.
A button on the BarcodePicker GUI to let the user toggle this functionality can also be set on creation via the enableTorchToggle option (enabled by default, when available).
In Single Image Mode this method has no effect.
Whether the torch should be enabled or disabled.
A promise resolving to the updated BarcodePicker object when the torch is enabled/disabled.
Show or hide a GUI button to toggle device torch on/off (when available, only Chrome).
In Single Image Mode this method has no effect.
Whether to show a GUI button to toggle device torch on/off.
The updated BarcodePicker object.
Enable or disable vibrating the device on barcode/text recognition (only Chrome & Firefox, requires user input).
The vibration is triggered if there's at least a barcode or text not rejected via ScanResult.rejectCode or ScanResult.rejectText.
Whether the device should vibrate on barcode/text recognition.
The updated BarcodePicker object.
Set the fit type for the video element of the picker.
If the "cover" type is selected the maximum available search area for barcode/text detection is (continuously) adjusted automatically according to the visible area of the picker.
In Single Image Mode this method has no effect.
The new fit type to be applied.
The updated BarcodePicker object.
Set the area of the viewfinder displayed when the GUI style is set to viewfinder. Note that this functionality affects UI only and doesn't change the actual search area set via ScanSettings. If no area is passed, the default automatic size behaviour is set, where the viewfinder will match the current area of the image in which barcodes/texts are searched, controlled via the searchArea option in ScanSettings.
The new search area, by default the area will match the ScanSettings's searchArea.
The updated BarcodePicker object.
Enable or disable picker visibility.
Note that this does not affect camera access, frame processing or any other picker logic.
Whether the picker is in a visible state or not.
The updated BarcodePicker object.
Set the zoom level of the device (when available, only Chrome). Changing active camera or camera settings will cause the zoom to be reset.
In Single Image Mode this method has no effect.
The percentage of the max zoom (between 0 and 1).
The updated BarcodePicker object.
Create a BarcodePicker instance, creating the needed HTML in the given origin element. If the accessCamera option is enabled (active by default) and the picker is not in Single Image Mode, the available cameras are accessed and camera access permission is requested to the user if needed. This object expects that at least a camera is available. The active camera is accessed and kept active during the lifetime of the picker (also when hidden or scanning is paused), and is only released when destroy is called.
It is required to having configured the library via configure before this object can be created.
Depending on library configuration, parameters, device/browser features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:
AbortError
LibraryNotConfiguredError
NoCameraAvailableError
NoOriginElementError
NotAllowedError
NotFoundError
NotReadableError
SecurityError
UnsupportedBrowserError
The HTMLElement inside which all the necessary elements for the picker will be added.
hd
resolution is used.
{
desktop: {
usageStrategy: SingleImageModeSettings.UsageStrategy.FALLBACK,
informationElement: <HTMLElement>,
buttonElement: <SVGElement>,
containerStyle: { backgroundColor: "#333333" },
informationStyle: { color: "#FFFFFF" },
buttonStyle: { borderColor: "#FFFFFF", color: "#FFFFFF", fill: "#FFFFFF" }
},
mobile: {
usageStrategy: SingleImageModeSettings.UsageStrategy.FALLBACK,
informationElement: <HTMLElement>,
buttonElement: <SVGElement>,
containerStyle: { backgroundColor: "#333333" },
informationStyle: { color: "#FFFFFF" },
buttonStyle: { borderColor: "#FFFFFF", color: "#FFFFFF", fill: "#FFFFFF" }
}
}
Settings for Single Image Mode: an alternative/fallback mode for a barcode picker to provide single camera
pictures to be scanned instead of continuous camera video stream access. In Single Image Mode users click/tap to
directly take a picture with the camera (mobile) or upload a file (desktop). Its usage depends on the given
settings and the camera video stream features provided by the OS/browser.
A promise resolving to the created ready BarcodePicker object.
Generated using TypeDoc
A barcode picker element used to get and show camera input and perform scanning operations.
The barcode picker will automatically fit and scale inside the given originElement.
Each barcode picker internally contains a Scanner object with its own WebWorker thread running a separate copy of the external Scandit Data Capture library. To optimize loading times and performance it's recommended to reuse the same picker and to already create the picker in advance (hidden) and just display it when needed whenever possible.
As the loading of the external Scandit Data Capture library can take some time, the picker always starts inactive (but showing GUI and video) and then activates, if not paused, as soon as the library is ready to scan. The on method targeting the ready event can be used to set up a listener function to be called when the library is loaded. The picker will be ready to start scanning when the library is fully loaded.
By default the external Scandit Data Capture library is preloaded in order to reduce the initialization time as much as possible.
The picker can also operate in Single Image Mode: letting the user click/tap to take a single image to be scanned via the camera (mobile) or a file select dialog (desktop). This is provided automatically as fallback by default when the OS/browser only supports part of the needed features and cannot provide direct access to the camera for video streaming and continuous scanning, or can also be forced on/off. This behaviour can be set up on creation via the singleImageModeSettings option. Note that in this mode some of the functions provided by the picker will have no effect.
By default an alert is shown if an internal error during scanning is encountered which prevents the scanning procedure from continuing when running on a local IP address. As this uses the built-in scanError event functionality, if unwanted it can be disabled by calling removeAllListeners on the BarcodePicker instance (right after creation).
In accordance with our license terms, the Scandit logo displayed in the bottom right corner of the barcode picker must be displayed and cannot be hidden by any method. Workarounds are not allowed.