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 (cameraAccess=false). Calling this doesn't do anything if the camera has already been 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:
A promise resolving to the updated BarcodePicker object when the camera is accessed.
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.
Depending on device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:
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).
Applies 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.
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 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.
The currently active camera.
Whether the camera video is mirrored along the vertical axis.
Whether a sound should be played on barcode recognition (iOS requires user input).
Whether the barcode picker has loaded the external Scandit Engine library and is ready to scan.
Whether the scanning is currently paused.
Whether the device should vibrate on barcode recognition (only Chrome & Firefox, requires user input).
Whether the picker is in a visible state or not.
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 (can be none). The returned barcodes are affected by the ScanSettings.setCodeDuplicateFilter option.
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 listener function, which will be invoked with a ScanResult object.
Whether the listener should just be triggered only once and then discarded.
The updated BarcodePicker object.
Add the listener function to the listeners array for the "ready" event, fired when the external Scandit Engine library has been loaded and the barcode picker can thus start to scan barcodes.
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 listener function.
The updated BarcodePicker object.
Add the listener function to the listeners array for the "scan" event, fired when new barcodes are recognized in the image frame. The returned barcodes are affected by the ScanSettings.setCodeDuplicateFilter option.
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 listener function, which will be invoked with a ScanResult object.
Whether the listener should just be triggered only once and then discarded.
The updated BarcodePicker object.
Add the listener function to the listeners array for the "scan error" 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 listener function, which will be invoked with an ScanditEngineError object.
Whether the listener should just be triggered only once and then discarded.
The updated BarcodePicker object.
Pause the recognition of codes 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, possibly requesting user permissions if needed.
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.
The HTMLElement into which all the necessary elements for the picker will be moved.
The updated BarcodePicker object.
Removes the specified listener from the "processFrame" event listener array. This will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times then this method must be called multiple times to remove each instance.
The listener function to be removed.
The updated BarcodePicker object.
Removes all listeners from the "processFrame" event listener array.
The updated BarcodePicker object.
Removes the specified listener from the "scan error" event listener array. This will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times then this method must be called multiple times to remove each instance.
The listener function to be removed.
The updated BarcodePicker object.
Removes all listeners from the "scan error" event listener array.
The updated BarcodePicker object.
Removes the specified listener from the "scan" event listener array. This will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times then this method must be called multiple times to remove each instance.
The listener function to be removed.
The updated BarcodePicker object.
Removes all listeners from the "scan" event listener array.
The updated BarcodePicker object.
Resume the recognition of codes 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.
The updated BarcodePicker object.
Select a camera to be used for video input.
If camera access is enabled, the camera is enabled and 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:
The new camera to be 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).
Set the GUI style for the picker.
The new GUI style to be applied.
The updated BarcodePicker object.
Enable or disable camera video mirroring along the vertical axis.
Whether the camera video is mirrored along the vertical axis.
The updated BarcodePicker object.
Enable or disable playing a sound on barcode recognition (iOS requires user input).
Whether a sound should be played on barcode recognition.
The updated BarcodePicker object.
Set the target frames per second to be processed by the scanning engine.
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).
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).
Whether the torch should be enabled or disabled.
The updated BarcodePicker object.
Enable or disable vibrating the device on barcode recognition (only Chrome & Firefox, requires user input).
Whether the device should vibrate on barcode 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 detection is (continuously) adjusted automatically according to the visible area of the picker.
The new fit type to be applied.
The updated BarcodePicker object.
Enable or disable picker visibility.
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.
The percentage of the max zoom (between 0 and 1).
The updated BarcodePicker object.
Creates a BarcodePicker instance, creating the needed HTML in the given origin element. If the accessCamera option is enabled (active by default) the available cameras are accessed and a 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.
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 onScanError event functionality, if unwanted it can be disabled by calling removeScanErrorListeners on the BarcodePicker instance (right after creation).
Depending on parameters, device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:
The HTMLElement inside which all the necessary elements for the picker will be added.
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 Engine 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 Engine 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 onReady method can be used to set up a listener function to be called when the library is loaded.
You are not allowed to hide the Scandit logo present in the corner of the GUI.