Deprecation warning

Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.

We are deprecating the 5.x API on all platforms (except Linux). Release 5.19 in April 2021 will be our final. Applications running 5.x will continue to work, and we will continue to release critical bug fixes and security patches only, for one year. We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.

You'll find the updated documentation at: Data Capture SDK Documentation for React Native

Scandit.BarcodePicker Class Reference

Classes

enum  ChangedProperty
 
enum  Warning
 

Public Member Functions

void applySettings (ScanSettings settings)
 
void pauseScanning ()
 
void resumeScanning ()
 
void stopScanning ()
 
void startScanning ()
 
void startScanningInPausedState ()
 
void setGuiStyle (int guiStyle)
 
void setMatrixScanHighlightingColor (int state, Object color)
 
void switchTorchOn (boolean on)
 
Sound Configuration

Customize the scan sound.

void setBeepEnabled (boolean enabled)
 
void setVibrateEnabled (boolean enabled)
 
Torch Configuration

Enable and customize appearance of the torch icon.

void setTorchEnabled (boolean enabled)
 
void setTorchButtonMarginsAndSize (int leftMargin, int topMargin, int width, int height)
 
Camera Switch Configuration

Enable camera switch and set icons

void setCameraSwitchVisibility (CameraSwitchVisibility visibility)
 
void setCameraSwitchMarginsAndSize (int rightMargin, int topMargin, int width, int height)
 
Text Recognition Switch Configuration

Sets whether the button to switch between different recognition modes should be visible.

void setTextRecognitionSwitchVisible (boolean isVisible)
 
Viewfinder Configuration

Customize the viewfinder where the barcode location is highlighted.

void setViewfinderDimension (number width, number height, number landscapeWidth, number landscapeHeight)
 
void setViewfinderColor (Object color)
 
void setViewfinderDecodedColor (Object color)
 
Non-Official Methods
void setOverlayProperty (String key, Object value)
 

Public Attributes

ScanSettings scanSettings
 
boolean shouldPassBarcodeFrame
 
function onScan
 
function onRecognizeNewCodes
 
function onChangeTrackedCodes
 
function onSettingsApplied
 
function onBarcodeFrameAvailable
 
function onTextRecognized
 
function onWarnings
 
function onPropertyChanged
 

Detailed Description

The main class for scanning barcodes with the Scandit Barcode Scanner.

This class sets up the recognition process, the preview view, controls the camera and provides a callback interface when barcodes are recognized.


Class Documentation

enum Scandit::BarcodePicker::ChangedProperty
Class Members
TORCH The torch has changed its state.

New state will be either 0 (torch is unavailable) or 1 (torch is off) or 2 (torch is on).

SWITCH_CAMERA The camera has been switched from front to back-facing, or from back to front-facing.
RECOGNITION_MODE The recognition mode has been changed.
RELATIVE_ZOOM The relative zoom factor times 1000.
enum Scandit::BarcodePicker::Warning

Warnings that can be raised by the frame processing engine.

Class Members
TOO_MUCH_GLARE_WARNING Too much glare warning.
NOT_ENOUGH_CONTRAST_WARNING Not enough contrast warning.

Member Function Documentation

void applySettings ( ScanSettings  settings)

Reconfigure the barcode picker with new settings.

The settings are applied asynchronously. Once they have been applied, all new frames will be processed with the new settings.

Parameters
settingsthe settings to apply.
void pauseScanning ( )

Asynchronously pause the scanning process while keeping the camera preview running.

Use this method when you plan to briefly pause the scanning process and intend to resume it later. It is not recommended to use this method when you are interrupting the scanning process for longer periods of time as the camera preview will use considerable power. For such scenarios use ScanSession.stopScanning instead.

void resumeScanning ( )

Asynchronously resume a previously paused scanning process.

Use this method to resume scanning after ScanSession.pauseScanning or pauseScanning was called. Calling resume on a picker that was not previously started with startScanning() or startScanningInPausedState() is not possible.

void stopScanning ( )

Asynchronously stop the scanning process and camera preview.

void startScanning ( )

Asynchronously start the camera preview and scanning process.

void startScanningInPausedState ( )

Asynchronously start the camera preview and initialize the scanning process in a paused state.

void setGuiStyle ( int  guiStyle)

Set the barcode picker GUI style.

Parameters
guiStylethe gui style to set, see ScanOverlay.GuiStyle
void setMatrixScanHighlightingColor ( int  state,
Object  color 
)

Set the matrix scanning highlighting color.

Parameters
statethe state for which you want to change the color, see {Scandit.ScanOverlay.MatrixScanState} color the color you want to set, this parameter can be a hex string or a color literal such as 'red' or 'yellow'
void switchTorchOn ( boolean  on)

Switches the torch (if available) on or off programmatically This method should only be called after scanning has been started.

Otherwise, it will have no effect. There is also a method to add a torch icon that the user can click to activate the torch.

Parameters
ontrue when the torch should be switched on, false if the torch should be turned off.
void setBeepEnabled ( boolean  enabled)

Enables (or disables) the sound when a barcode is recognized.

If the phone's ring mode is set to muted or vibrate, no beep will be played regardless of the value.

Enabled by default.

Parameters
enabledwhether the beep is enabled.
void setVibrateEnabled ( boolean  enabled)

Enables or disables the vibration when a code was recognized.

If the phone's ring mode is set to muted, no beep will be played regardless of the value.

Enabled by default.

Parameters
enabledwhether vibrate is enabled.
void setTorchEnabled ( boolean  enabled)

Enables or disables the torch toggle button for all devices/cameras that support a torch.

By default it is enabled. The torch icon is never shown when the camera does not have a torch (most tablets, front cameras, etc).

Since
5.7.0
Parameters
enabledWhether the torch button should be shown.
void setTorchButtonMarginsAndSize ( int  leftMargin,
int  topMargin,
int  width,
int  height 
)

Sets the position at which the button to enable the torch is drawn.

By default the margins are 15 and width and height are 40.

Since
5.7.0
Parameters
leftMarginLeft margin in points.
topMarginTop margin in points.
widthWidth in points.
heightHeight in points.
void setCameraSwitchMarginsAndSize ( int  rightMargin,
int  topMargin,
int  width,
int  height 
)

Sets the position at which the button to switch the camera is drawn.

By default the margins are 15 and width and height are 40.

Since
5.7.0
Parameters
rightMarginRight margin in dp.
topMarginTop margin in dp.
widthWidth in dp.
heightHeight in dp.
void setTextRecognitionSwitchVisible ( boolean  isVisible)

Sets whether the button to switch between different recognition modes should be visible.

If the scanner only supports one recognition mode the button is never shown.

Parameters
isVisibleWhether the button should be visible.
Since
5.7.0
void setViewfinderDimension ( number  width,
number  height,
number  landscapeWidth,
number  landscapeHeight 
)

Sets the size of the viewfinder relative to the size of the BarcodePicker's size.

Changing this value does not(!) affect the area in which barcodes are successfully recognized. It only changes the size of the box drawn onto the scan screen.

By default the width is 0.8, height is 0.4, landscapeWidth is 0.6, landscapeHeight is 0.4

Parameters
widthWidth of the viewfinder rectangle in portrait orientation.
heightHeight of the viewfinder rectangle in portrait orientation.
landscapeWidthWidth of the viewfinder rectangle in landscape orientation.
landscapeHeightHeight of the viewfinder rectangle in landscape orientation.
void setViewfinderColor ( Object  color)

Sets the color of the viewfinder before a bar code has been recognized.

Note: This feature is only available with the Scandit SDK Enterprise Packages.

By default the color is white

Parameters
colorthe color to set, this parameter can be a hex string or a color literal such as 'red' or 'yellow'
void setViewfinderDecodedColor ( Object  color)

Sets the color of the viewfinder once the bar code has been recognized.

Note: This feature is only available with the Scandit SDK Enterprise Packages.

By default the color is light blue

Parameters
colorthe color to set, this parameter can be a hex string or a color literal such as 'red' or 'yellow'
void setOverlayProperty ( String  key,
Object  value 
)

Set custom overlay property.

This function is for internal use/and or experimental features and any functionality that can be accessed through it can and will vanish without public notice from one version to the next. Do not use this method unless you specifically have to.

Parameters
keyThe name of the property
valuethe value for the property.

Member Data Documentation

ScanSettings scanSettings

Prop used to pass the initial scan settings to the picker.

boolean shouldPassBarcodeFrame

Prop used to inform the picker whether it should make the frame data available via the BarcodePicker.onBarcodeFrameAvailable callback.

function onScan

Prop used to set the scan callback.

function onRecognizeNewCodes

Prop used to set the matrix scan callback.

function onChangeTrackedCodes

Prop used to set the matrix scan callback that's called every frame to get continuous updates about tracked codes.

function onSettingsApplied

Prop used to set a callback called after new settings have been applied.

function onBarcodeFrameAvailable

Prop used to set a callback that provides frame data in base64 string format.

The onBarcodeFrameAvailable method is executed after each frame is processed by the picker, but only if new codes have been recognized in that particular frame. Note that the callback will only be invoked if the BarcodePicker.shouldPassBarcodeFrame property is set to true.

function onTextRecognized

Prop used to set the text recognition callback.

function onWarnings

Prop used to set the warnings callback.

The onWarnings method will be executed after every time a warning is raised by the frame processing engine.

function onPropertyChanged

Prop used to set the property changed callback.

The onPropertyChanged method is executed whenever the state of the barcode picker changes. Events that can invoke this method include changes to the torch, camera facing, recognition mode and relative zoom. The onPropertyChanged should accept two arguments. The first one is a string. It defines which property of the BarcodePicker has been changed and its value is one of ChangedProperty enum values. The second one is an int that represents the new state of the property.