Barcode scanner configuration settings methods.

This is a collection of configuration methods, which are meant to be passed as JSON object literals in an array as param for the loadSettings method.

The loadSettings API method is meant to be called in the configuration stage, i.e. before starting a scan. Thus the configuration methods listed here control settings that can be changed prior and not during scanning.

However, there are a few methods that are safe to be used during scanning, so they are also available as API methods.

### Configuration stage

The configuration stage is any code you place inside of the scannerConfig() method. The SDK will execute this method whenever needed depending on SDK use.

The configuration stage always precedes the scanning stage (i.e. the use of startScanning, scanImage or scanFrame API methods).

Here is an example of a typical configuration:

    var scannerConfig = function(){

        mwbScanner.setCallback(myCallback); //see MyCallback type for an example callback

        mwbScanner.setIcon("cognex_icon.png");

        // Some predefined settings, comment out the ones you don't want enabled
        var mw_c = mwbScanner.getConstants(),
        settings = [
            {"method" : "MWBsetActiveCodes", "value" : [
                mw_c.MWB_CODE_MASK_QR |
                mw_c.MWB_CODE_MASK_DM |
                //mw_c.MWB_CODE_MASK_RSS |
                //mw_c.MWB_CODE_MASK_39 |
                mw_c.MWB_CODE_MASK_EANUPC |
                mw_c.MWB_CODE_MASK_128 |
                mw_c.MWB_CODE_MASK_PDF |
                //mw_c.MWB_CODE_MASK_AZTEC |
                //mw_c.MWB_CODE_MASK_25 |
                //mw_c.MWB_CODE_MASK_93 |
                //mw_c.MWB_CODE_MASK_CODABAR |
                //mw_c.MWB_CODE_MASK_DOTCODE |
                //mw_c.MWB_CODE_MASK_11 |
                //mw_c.MWB_CODE_MASK_MSI |
                //mw_c.MWB_CODE_MASK_MAXICODE |
                //mw_c.MWB_CODE_MASK_POSTAL |
                //mw_c.MWB_CODE_MASK_TELEPEN |
                0x0 //for binary-OR syntax purposes
            ]}
            ,{"method" : "MWBsetLevel", "value" : [2]}
            ,{"method" : "MWBenableHiRes", "value" : [mw_c.CamRes_HD]}
            ,{"method" : "MWBsetDecoderTimeout", "value" : [10]}
            ,{"method" : "MWBsetDpsLimit", "value" : [2]}
        ];

        mwbScanner.loadSettings(settings);
    };

The methods listed below have an example JSON object literal which can be used in a settings array (as done in the configuration example above).

### Hierarchy

- BarcodeScanner

## Index

### Methods

- MWBcloseScannerOnDecode
- MWBduplicateCodeDelay
- MWBenableCameraSwitcher
- MWBenableCapturedFrameReturn
- MWBenableClose
- MWBenableFlash
- MWBenableHiRes
- MWBenableMirroredPreview
- MWBenableZoom
- MWBsetActiveCodes
- MWBsetActiveParser
- MWBsetActiveSubcodes
- MWBsetBlinkingLineVisible
- MWBsetCameraSwitcherOptions
- MWBsetDecoderTimeout
- MWBsetDirection
- MWBsetDpsLimit
- MWBsetFlags
- MWBsetLevel
- MWBsetMinLength
- MWBsetOverlayMode
- MWBsetOverlayAppearance
- MWBsetParam
- MWBsetPauseMode
- MWBsetScanningRect
- MWBsetZoomLevel
- MWBturnFlashOn
- MWBuseFrontCamera

## Methods

### MWBcloseScannerOnDecode

- MWBcloseScannerOnDecode(shouldClose: boolean): void

- Enable / disable continuous scanning.

  - Example JSON object literal:

      {"method" : "MWBcloseScannerOnDecode", "value" : [true]}

  #### Parameters

  - ##### shouldClose: boolean

    Should the scanner close after scanning has finished.

    Default value is true (disable continuous scanning).

    If false, result callback will be performed and scanner will be paused. The User can call resumeScanning to continue scanning, or closeScanner to close the scanner.

  #### Returns void

### MWBduplicateCodeDelay

- MWBduplicateCodeDelay(delay: number): void

- Ignore result if the same code is scanned in continuous scanning mode.

  - Example JSON object literal:

      {"method" : "MWBduplicateCodeDelay", "value" : [1000]}

  #### Parameters

  - ##### delay: number

    Time interval in milliseconds between 2 scan results with the same result.code

    > Note: Internal implementation uses seconds. Provided value is rounded.

  #### Returns void

### MWBenableCameraSwitcher

- MWBenableCameraSwitcher(enable: boolean): void

- Enable or disable camera switcher button on cameraPreview.

  - Example JSON object literal:

      {"method" : "MWBenableCameraSwitcher", "value" : [true]}

  Usually for situations where the device has multiple cameras, the camera switcher UI lists all found cameras, and allows to switch to a different camera. Doing so stops the current scanning and starts a new scanning session with the chosen camera.

  By default MWBuseFrontCamera is used until another camera is selected (picked and switched to) from the camera switcher UI (either manually or by using the CAMERA_SWITCHER_USE_ON_START option).

  Once a specific camera is selected (picked and switched to) from the camera switcher, the MWBuseFrontCamera setting no longer has effect.

  #### Parameters

  - ##### enable: boolean

    Enable camera switcher button on cameraPreview. Default value is false (disabled).

  #### Returns void

### MWBenableCapturedFrameReturn

- MWBenableCapturedFrameReturn(enableCapturedFrame: boolean): void

- Enable / disable the return of the captured frame in the result on a successful scan.

  - Example JSON object literal:

      {"method" : "MWBenableCapturedFrameReturn", "value" : [true]}

  > Note: Depending on frame size i.e. camera resolution used, the captured frame object may take up a fair amount of memory, and won't be marked for GC as long as a reference exists to it. This effect may be further compounded if continuous scanning is used.

  #### Parameters

  - ##### enableCapturedFrame: boolean

    Should the captured frame of a successful scan be returned in the result.

    Default value is false (captured frame will not be provided in result).

  #### Returns void

### MWBenableClose

- MWBenableClose(enable: boolean): void

- Enable or disable close button on cameraPreview (partial view).

  > If cameraPreview is in full screen mode, button will be present regardless of param.

  - Example JSON object literal:

      {"method" : "MWBenableClose", "value" : [true]}

  #### Parameters

  - ##### enable: boolean

    Enable close button on cameraPreview. Default value is false (disabled).

  #### Returns void

### MWBenableFlash

- MWBenableFlash(enable: boolean): void

- Enable or disable flash toggle button on cameraPreview.

  > If device doesn't support flash mode button will be hidden regardless of param.

  - Example JSON object literal:

      {"method" : "MWBenableFlash", "value" : [true]}

  #### Parameters

  - ##### enable: boolean

    Enable flash button on cameraPreview. Default value is true (enabled).

  #### Returns void

### MWBenableHiRes

- MWBenableHiRes(enable: number | boolean): void

- Enable or disable high resolution scanning. It's recommended to enable it when target barcodes are of high density or small footprint.

  > If device doesn't support high or exact resolution param will have no effect and closest available resolution will be used.

  - Example JSON object literal:

      {"method" : "MWBenableHiRes", "value" : [mw_c.CamRes_HD]}

  #### Parameters

  - ##### enable: number | boolean

    Enable high resolution (720p) or specify exact resolution. Default value is true (enabled) / CamRes_HD (720p).

    Accepts

    - boolean
      - false         480p
      - true         720p
    - constants
      - CamRes_SD     480p
      - CamRes_HD     720p
      - CamRes_FHD     1080p

  #### Returns void

### MWBenableMirroredPreview

- MWBenableMirroredPreview(mode: number): void

- Enable mirrored camera preview.

  The mirroring is done along the X-axis. It's recommended when the used camera is facing the user (i.e. front camera).

  - Example JSON object literal:

      {"method" : "MWBenableMirroredPreview", "value" : [mw_c.MIRROR_FRONTCAM]}

  #### Parameters

  - ##### mode: number

    The type of mirroring to apply. Default value is MIRROR_NONE.

    - Available mirror modes are:
      - MIRROR_NONE - No camera preview mirroring is done
      - MIRROR_FRONTCAM - Camera preview mirroring is done only when using front cameras

        > Note: The MIRROR_FRONTCAM option relies on proper camera type (front or back) selection. While most often this will be correct (i.e. on mobile devices), it is not guaranteed to always be the case (depends on device, browser and camera).

      - MIRROR_ALWAYS - Camera preview mirroring is always done

  #### Returns void

### MWBenableZoom

- MWBenableZoom(enable: boolean): void

- Enable or disable zoom button on cameraPreview.

  > If device doesn't support zoom button will be hidden regardless of param.

  - Example JSON object literal:

      {"method" : "MWBenableZoom", "value" : [true]}

  #### Parameters

  - ##### enable: boolean

    Enable zoom button on cameraPreview. Default value is true (enabled).

  #### Returns void

### MWBsetActiveCodes

- MWBsetActiveCodes(activeCodes: number): void

- Enables or disables symbology types to decode.

  - Example JSON object literal:

      {"method" : "MWBsetActiveCodes", "value" : [
          mw_c.MWB_CODE_MASK_QR |
          mw_c.MWB_CODE_MASK_DM |
          //mw_c.MWB_CODE_MASK_RSS |
          //mw_c.MWB_CODE_MASK_39 |
          mw_c.MWB_CODE_MASK_EANUPC |
          mw_c.MWB_CODE_MASK_128 |
          mw_c.MWB_CODE_MASK_PDF |
          //mw_c.MWB_CODE_MASK_AZTEC |
          //mw_c.MWB_CODE_MASK_25 |
          //mw_c.MWB_CODE_MASK_93 |
          //mw_c.MWB_CODE_MASK_CODABAR |
          //mw_c.MWB_CODE_MASK_DOTCODE |
          //mw_c.MWB_CODE_MASK_11 |
          //mw_c.MWB_CODE_MASK_MSI |
          //mw_c.MWB_CODE_MASK_MAXICODE |
          //mw_c.MWB_CODE_MASK_POSTAL |
          //mw_c.MWB_CODE_MASK_TELEPEN |
          0x0 //for binary-OR syntax purposes
      ]}

  #### Parameters

  - ##### activeCodes: number

    ORed bit flags (MWB_CODE_MASK_...) of symbology types to be activated.

    - Available symbology types:
      - MWB_CODE_MASK_NONE
      - MWB_CODE_MASK_QR
      - MWB_CODE_MASK_DM
      - MWB_CODE_MASK_RSS (GS1 DataBar)
      - MWB_CODE_MASK_39
      - MWB_CODE_MASK_EANUPC
      - MWB_CODE_MASK_128
      - MWB_CODE_MASK_PDF
      - MWB_CODE_MASK_AZTEC
      - MWB_CODE_MASK_25
      - MWB_CODE_MASK_93
      - MWB_CODE_MASK_CODABAR
      - MWB_CODE_MASK_DOTCODE
      - MWB_CODE_MASK_11
      - MWB_CODE_MASK_MSI
      - MWB_CODE_MASK_MAXICODE
      - MWB_CODE_MASK_POSTAL
      - MWB_CODE_MASK_TELEPEN
      - MWB_CODE_MASK_ALL

  #### Returns void

### MWBsetActiveParser

- MWBsetActiveParser(activeParser: number): void

- Sets active or inactive status of parser types.

  - Example JSON object literal:

      {"method" : "MWBsetActiveParser", "value" : [mw_c.MWP_PARSER_MASK_GS1]}

  #### Parameters

  - ##### activeParser: number

    ORed bit flags (MWP_PARSER_MASK_...) of parser types to be activated.

    - Available parser types:
      - MWP_PARSER_MASK_NONE
      - MWP_PARSER_MASK_GS1
      - MWP_PARSER_MASK_IUID
      - MWP_PARSER_MASK_ISBT

        > Note: The ISBT parser has been removed since version 1.0.4 in favor of reducing SDK size. Should there be a need for it, contact us.

      - MWP_PARSER_MASK_AAMVA
      - MWP_PARSER_MASK_HIBC
      - MWP_PARSER_MASK_SCM
      - MWP_PARSER_MASK_AUTO

  #### Returns void

### MWBsetActiveSubcodes

- MWBsetActiveSubcodes(codeMask: number, subMask: number): void

- Sets active subcodes for given code group flag. Subcodes under some symbology types are all activated by default.

  - Example JSON object literal:

      {"method" : "MWBsetActiveSubcodes", "value" : [mw_c.MWB_CODE_MASK_RSS, mw_c.MWB_SUBC_MASK_RSS_14_STACK]}

  #### Parameters

  - ##### codeMask: number

    Single symbology type/group (MWB_CODE_MASK_...)

  - ##### subMask: number

    ORed bit flags of requested symbology subtypes (MWB_SUBC_MASK_...)

  #### Returns void

### MWBsetBlinkingLineVisible

- MWBsetBlinkingLineVisible(visible: boolean): void

- Set the visibility of the cameraPreview blinking lines.

  > Note: This setting is also available as an API method.

  - Example JSON object literal:

      {"method" : "MWBsetBlinkingLineVisible", "value" : [true]}

  #### Parameters

  - ##### visible: boolean

    Visible blinking lines. Default value is true.

  #### Returns void

### MWBsetCameraSwitcherOptions

- MWBsetCameraSwitcherOptions(options: number): void

- Choose configuration options for camera switcher.

  - Example JSON object literal:

      {"method" : "MWBsetCameraSwitcherOptions", "value" : [
          //mw_c.CAMERA_SWITCHER_INIT_ON_START |
          //mw_c.CAMERA_SWITCHER_USE_ON_START |
          //mw_c.CAMERA_SWITCHER_USE_BEST_CAMERA |

          0x0 //for binary-OR syntax purposes
      ]}

  #### Parameters

  - ##### options: number

    Configuration options for camera switcher. Default value is 0x0 (no option enabled)

    - Available camera switcher options:
      - CAMERA_SWITCHER_INIT_ON_START - Init camera switcher before starting a scan
      - CAMERA_SWITCHER_USE_ON_START - Use the first camera from all detected cameras
      - CAMERA_SWITCHER_USE_BEST_CAMERA - Try to use the main back camera from multiple back cameras

  #### Returns void

### MWBsetDecoderTimeout

- MWBsetDecoderTimeout(timeout: number): void

- Set the amount of time in seconds the camera preview will be on before closeScanner is called.

  - Example JSON object literal:

      {"method" : "MWBsetDecoderTimeout", "value" : [30]}

  #### Parameters

  - ##### timeout: number

    Time in seconds. Default value is 30.

    Accepted value range is 10-60. Also accepts 0 to disable the timeout.

    Values out of range will result in applying the default value 30.

  #### Returns void

### MWBsetDirection

- MWBsetDirection(direction: number): void

- This function enables some control over scanning lines choice for 1D barcodes. By ORing available bit-masks user can add one or more direction options to scanning lines set.

  - Example JSON object literal:

      {"method" : 'MWBsetDirection', "value" : [mw_c.MWB_SCANDIRECTION_HORIZONTAL | mw_c.MWB_SCANDIRECTION_VERTICAL]}

  #### Parameters

  - ##### direction: number

    ORed bit mask of direction modes given with MWB_SCANDIRECTION_... bit-masks

    - Available direction modes:
      - MWB_SCANDIRECTION_HORIZONTAL - horizontal lines
      - MWB_SCANDIRECTION_VERTICAL - vertical lines
      - MWB_SCANDIRECTION_OMNI - omnidirectional lines
      - MWB_SCANDIRECTION_AUTODETECT - enables BarcodeScanner's autodetection of barcode direction

  #### Returns void

### MWBsetDpsLimit

- MWBsetDpsLimit(dpsLimit: number): void

- Set decodes per second, i.e. number of frames that are sent for decoding in a given second. This setting only works with our camera preview i.e. when using the startScanning method.

  > Performance: Use of a decodes per second limit is recommended, such as 1 or 2 at the most, and in reality, there is rarely a need for a higher decoding rate. Having a higher dps results in higher CPU usage, which can lead to non-responsiveness of the cameraPreview.

  - Example JSON object literal:

      {"method" : "MWBsetDpsLimit", "value" : [2]}

  #### Parameters

  - ##### dpsLimit: number

    Decodes per second limit. Default value is 2.

    Accepted value range is 1-30.

  #### Returns void

### MWBsetFlags

- MWBsetFlags(codeMask: number, flags: number): void

- Sets options (if any) for symbology type specified in codeMask. Options are given in flags as bitwise OR of option bits. Available options depend on selected symbology type.

  - Example JSON object literal:

      {"method" : "MWBsetFlags", "value" : [0, mw_c.MWB_CFG_GLOBAL_ENABLE_MULTI]}

  #### Parameters

  - ##### codeMask: number

    Single symbology type/group (MWB_CODE_MASK_...) or 0 for global flags

  - ##### flags: number

    ORed bit mask of selected symbology type options (MWB_CFG_...) or global flags (MWB_CFG_GLOBAL_...)

  #### Returns void

### MWBsetLevel

- MWBsetLevel(level: number): void

- Set the barcode scanner effort level.

  Barcode detector relies on image processing and geometry interpolation for extracting optimal data for decoding. Higher effort level involves more processing and intermediate parameter values, thus increasing probability of successful detection with low quality images, but also consuming more CPU time.

  > Performance: Use suitable effort level for a given use case to balance successful detection and CPU usage. Effort levels 4 and 5 should be reserved for scanning from image only (non-live scanning).

  - Example JSON object literal:

      {"method" : "MWBsetLevel", "value" : [2]}

  #### Parameters

  - ##### level: number

    Effort level - available values are 1, 2, 3, 4 and 5. Default value is 2. Levels greater than 3 are not suitable for real-time decoding.

  #### Returns void

### MWBsetMinLength

- MWBsetMinLength(codeMask: number, minLength: number): void

- Sets minimum result length for symbology type specified in codeMask.

  - Example JSON object literal:

      {"method" : "MWBsetMinLength", "value" : [mw_c.MWB_CODE_MASK_25, 5]}

  #### Parameters

  - ##### codeMask: number

    Single symbology type/group (MWB_CODE_MASK_...)

  - ##### minLength: number

    Minimum result length for selected symbology type

  #### Returns void

### MWBsetOverlayMode

- MWBsetOverlayMode(mode: number): void

- Choose overlay graphics type for cameraPreview.

  > Note: This setting is also available as an API method.

  > Note: Using OverlayModeMW is the only way to have a viewfinder on the cameraPreview, which indicates the active area the decoder is scanning. The viewfinder is a union of the scanning rectangles of all active codes.

  - Example JSON object literal:

      {"method" : "MWBsetOverlayMode", "value" : [mw_c.OverlayModeImage]}

  #### Parameters

  - ##### mode: number

    Overlay mode.

    - Available overlay modes are:
      - OverlayModeNone - No overlay is displayed
      - OverlayModeMW - Use MW Dynamic Viewfinder with blinking lines (you can customize display options by changing defaults)

        > Note: The blinking lines visibility has priority over OverlayModeMW

      - OverlayModeImage - Show image on top of cameraPreview

  #### Returns void

### MWBsetOverlayAppearance

- MWBsetOverlayAppearance(overlayProperties: object): void

- Customize overlay appearance for OverlayModeMW.

  - Example JSON object literal:

      {"method" : "MWBsetOverlayAppearance", "value" : [
          {
              "BorderVisible": true
              ,"BorderAndLinesColor": "rgba(255, 255, 0, 1.0)"
              ,"LocationBorderColor": "rgba(0, 255, 255, 1.0)"
              ,"LocationShowTime": 500
          }
      ]}

  #### Parameters

  - ##### overlayProperties: object

    An object of various overlay properties and their values.

    - Available overlay properties for setting custom values to are:
      - BorderVisible - boolean
      - BorderAndLinesColor - string (css color value in the rgba functional notation)
      - LocationBorderColor - string (css color value in the rgba functional notation)
      - LocationShowTime - number (ms)

  #### Returns void

### MWBsetParam

- MWBsetParam(codeMask: number, paramId: number, paramValue: number): void

- Set custom symbology param id / value pair for symbology type specified in a codeMask.

  - Example JSON object literal:

      {"method" : "MWBsetParam", "value" : [mw_c.MWB_CODE_MASK_39, mw_c.MWB_PAR_ID_VERIFY_LOCATION, mw_c.MWB_PAR_VALUE_VERIFY_LOCATION_ON]}

  #### Parameters

  - ##### codeMask: number

    Single symbology type/group (MWB_CODE_MASK_...)

  - ##### paramId: number

    The ID of param

  - ##### paramValue: number

    Integer value of param

  #### Returns void

### MWBsetPauseMode

- MWBsetPauseMode(mode: number): void

- Set cameraPreview pause mode.

  - Example JSON object literal:

      {"method" : "MWBsetPauseMode", "value" : [mw_c.PM_STOP_BLINKING]}

  #### Parameters

  - ##### mode: number

    Pause mode defines what happens when the scanner is paused. Default value is PM_STOP_BLINKING

    - Available pause modes are:
      - PM_NONE - Nothing happens
      - PM_PAUSE - Blinking lines are replaced with a pause view
      - PM_STOP_BLINKING - Blinking lines stop blinking

        > Note: The blinking lines visibility has priority over PM_STOP_BLINKING

  #### Returns void

### MWBsetScanningRect

- MWBsetScanningRect(codeMask: number, left: number, top: number, width: number, height: number): void

- Sets rectangular area for barcode scanning with selected single symbology type.

  After applying this setting, all subsequent scans will be restricted to this region. Only codes inside defined region are decoded. If rectangle is not set, whole image / frame is scanned. If width or height is zero, whole image / frame is scanned.

  Dimensions parameters (left, top, width, height) are interpreted as percentage of image / frame dimensions, i.e. ranges are 0 - 100 for all parameters.

  - Example JSON object literal:

      {"method" : "MWBsetScanningRect", "value" : [mw_c.MWB_CODE_MASK_PDF, 2, 2, 96, 96]}

  #### Parameters

  - ##### codeMask: number

    Single symbology type/group (MWB_CODE_MASK_...)

  - ##### left: number

    X coordinate of left edge (percentage)

  - ##### top: number

    Y coordinate of top edge (percentage)

  - ##### width: number

    Rectangle width (x axis) (percentage)

  - ##### height: number

    Rectangle height (y axis) (percentage)

  #### Returns void

### MWBsetZoomLevel

- MWBsetZoomLevel(zoomLevel: number): void

- Set desired initial zoom level. Zoom is supported only by Chrome.

  - Example JSON object literal:

      {"method" : "MWBsetZoomLevel", "value" : [1]}

  #### Parameters

  - ##### zoomLevel: number

    Initial zoom level. Default is 0.

    - Available zoom level values are:
      - 0 - no zoom
      - 1 - 50% zoom
      - 2 - 100% zoom

  #### Returns void

### MWBturnFlashOn

- MWBturnFlashOn(flashOn: boolean): void

- Set default state of flash (torch) when scanner is started.

  - Example JSON object literal:

      {"method" : "MWBturnFlashOn", "value" : [true]}

  #### Parameters

  - ##### flashOn: boolean

    Turn on initial flash state. Default value is false (disabled).

  #### Returns void

### MWBuseFrontCamera

- MWBuseFrontCamera(useFrontCamera: boolean): void

- Use front facing camera.

  - Example JSON object literal:

      {"method" : "MWBuseFrontCamera", "value" : [false]}

  #### Parameters

  - ##### useFrontCamera: boolean

    Whether or not to use front facing camera. Default value is false (i.e. use back camera).

  #### Returns void

Generated using TypeDoc