# Class: CortexDecoderLibrary

## CortexDecoderLibrary()

All member function will return it's results via the callback function referred in the first parameter. The second (optional)parameter references a callback function that will be fired in case of an error.

## Constructor

#### new CortexDecoderLibrary()

Source:
  - codePlugin.js, line 20

### Methods

#### activateLicense(productKey) → {boolean}

Activating a license for the native Cortex Decoder Library. For security purposes we recommend to place the License Key in your projects config.xml file

##### Parameters:

Name | Type | Description
--- | --- | ---
`productKey` | string | Valid License Key or emty String.

Source:
  - codePlugin.js, line 43

##### Returns:

Type
  boolean

#### captureCurrentImageInBuffer() → {boolean}

This method will capture the current image in the buffer and store it in the camera roll.

Source:
  - codePlugin.js, line 56

##### Returns:

Type
  boolean

#### changeBeepPlayerSound(name)

Allows the user to change the beep noise.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | Enter the number as a string to trigger the change of the beep sound. "1" = Default Beep "2" = Carbilicon Beep "3" = Computer Beep "4" = Tone Beep.

Default Value:
  - default is 1.
Source:
  - codePlugin.js, line 70

#### closeCamera()

Closes the camera.

Source:
  - codePlugin.js, line 82

#### closeSharedObject()

Close the singleton object returned by #sharedObject(Context), stop the decoder, stop the camera preview, close the camera, and stop all background threads.

Source:
  - codePlugin.js, line 94

#### CRD_Set(property, value)

##### Parameters:

Name | Type | Description
--- | --- | ---
`property` | int |
`value` | any | Boolean, ByteBuffer or int.

Source:
  - codePlugin.js, line 107

#### currentSizeOfDecoderVideo() → {Size}

Returns the current size of the camera image sent to the decoder.

Source:
  - codePlugin.js, line 119

##### Returns:

Size object containing width and height of the camera image.

Type
  Size

#### decoderTimeLimitInMilliseconds(milliseconds)

This method sets a timeout for the decoder for one frame. If this timeout is reached it will start on the next frame if available.

##### Parameters:

Name | Type | Description
--- | --- | ---
`milliseconds` | int | This should be a positive integer representing the timeout in milliseconds. If set to 0 no timeout will be used.

Source:
  - codePlugin.js, line 131

#### decoderVersion() → {string}

Returns the CortexDecoder version string.

Source:
  - codePlugin.js, line 143

##### Returns:

A String containing the decoder version.

Type
  string

#### decoderVersionLevel() → {string}

Returns the CortexDecoder Level string.

Source:
  - codePlugin.js, line 155

##### Returns:

A String containing the level of the decoding capabilities.

Type
  string

#### doDecode(pixBuf, width, height, stride)

This function scans the image and decodes the barcodes present in the image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pixBuf` | bytearray | an Image is converted to a byte buffer so that it can be used by the decoder to decode the barcode
`width` | int | the width of the image
`height` | int | the height of the image
`stride` | int | the stride/width of the image

Source:
  - codePlugin.js, line 170

#### enableBeepPlayer(enable)

Enables or disables the beep sound during a successful scan.

##### Parameters:

Name | Type | Description
--- | --- | ---
`enable` | boolean | true to enable.

Source:
  - codePlugin.js, line 182

#### enableFixedExposureMode(enabled, exposureValue)

This method enables fixed exposure mode where user can change the exposure compensation values.

##### Parameters:

Name | Type | Description
--- | --- | ---
`enabled` | boolean | If set to true, then fixed exposure mode is enabled.
`exposureValue` | long | This should be a Long integer representing the new value for exposure compensation.

Source:
  - codePlugin.js, line 195

#### enableScannedImageCapture(enable)

This method enables or disables the capture of the image that was used for decoding the barcode. This method will put the decoder in debug mode, which will result in a loss of performance.

##### Parameters:

Name | Type | Description
--- | --- | ---
`enable` | boolean | true to enable.

Source:
  - codePlugin.js, line 207

#### enableVibrateOnScan(enable)

Enables or disables vibrate on successful scan.

##### Parameters:

Name | Type | Description
--- | --- | ---
`enable` | boolean | true to enable.

Source:
  - codePlugin.js, line 219

#### ensureRegionOfInterest(enable)

Enables or disables strict region of interest (ROI) decoding. When enabled, the barcode will not decoded unless its entire area is inside the ROI. When disabled, the barcode will be decoded if a sufficient portion of the barcode is in the ROI.

##### Parameters:

Name | Type | Description
--- | --- | ---
`enable` | boolean | true to enable.

Source:
  - codePlugin.js, line 231

#### generateDeviceID()

This method is used to generate Device Unique ID.

Source:
  - codePlugin.js, line 242

#### getCameraPreview() → {View}

Returns the View object that will display the live preview images from the camera.

Source:
  - codePlugin.js, line 254

##### Returns:

A View with the live preview.

Type
  View

#### getDecodeVal() → {int}

Returns the CRD_Decode Value. If the return value is equal to 908 then that means the license has expired.

Source:
  - codePlugin.js, line 266

##### Returns:

An integer representing the state of the deocder.

Type
  int

#### getExposureTime() → {Array.<long>}

This method is used to get the exposure time that the camera supports

Source:
  - codePlugin.js, line 278

##### Returns:

a long array that holds the minimum and maximum exposure time supported by the camera

Type
  Array.<long>

#### getFocusDistance() → {Array.<float>}

This method is used to get the minimum focus distance that the object can be focused.

Source:
  - codePlugin.js, line 290

##### Returns:

an float array with 0 as the first value and minimum focus distance as second value (for camera2)

Type
  Array.<float>

#### getLicensedSymbologies() → {Array.<string>}

This method returns an array that contains all the licensed symbologies from the decoder.

Source:
  - codePlugin.js, line 302

##### Returns:

an string array that holds all licensed symbologies that are supported by the decoder

Type
  Array.<string>

#### getMaxZoom() → {float}

This method is used to get the maximum camera zoom that camera supports.

Source:
  - codePlugin.js, line 314

##### Returns:

float that corresponds to maximum zoom value that camera supports.

Type
  float

#### getSdkVersion() → {string}

Returns the CortexDecoder Level string.

Source:
  - codePlugin.js, line 326

##### Returns:

a string containing the level of the decoding capabilities.

Type
  string

#### getSensitivityBoost() → {Array.<string>}

This method is used to get the sensitivity boost supported by the camera.

Source:
  - codePlugin.js, line 338

##### Returns:

an array list that holds all the iso names that are supported by the camera.

Type
  Array.<string>

#### getSizeForROI() → {Size}

Returns the size of the image being sent to the decoder. This could differ slighly from resolution size.

Source:
  - codePlugin.js, line 350

##### Returns:

Type
  Size

#### getSupportedCameraTypes() → {Array.<CameraType>}

Returns an array of the supported camera types.

Source:
  - codePlugin.js, line 362

##### Returns:

Type
  Array.<CameraType>

#### getSupportedFocusModes() → {Array.<Focus>}

Returns an array of the supported Focus modes.

Source:
  - codePlugin.js, line 374

##### Returns:

Type
  Array.<Focus>

#### getSupportedWhiteBalance() → {Array.<string>}

This method is used to get the white balance modes supported by the camera.

Source:
  - codePlugin.js, line 386

##### Returns:

a string array that holds all white balance modes that are supported by the camera.

Type
  Array.<string>

#### getZoomRatios() → {Array.<float>}

This method is used to get the zoom ratios supported by the camera.

Source:
  - codePlugin.js, line 398

##### Returns:

a float array that holds all the zoom ratios that are supported by the camera.

Type
  Array.<float>

#### hasTorch() → {boolean}

Returns true if the camera has a torch that can be turned on.

Source:
  - codePlugin.js, line 410

##### Returns:

Type
  boolean

#### isLicenseActivated() → {boolean}

This method is used to check whether license is activated or not.

Source:
  - codePlugin.js, line 422

##### Returns:

true if license is activated for the app.

Type
  boolean

#### isLicenseExpired() → {boolean}

Checks whether the license is expired.

Source:
  - codePlugin.js, line 434

##### Returns:

true if license is expired.

Type
  boolean

#### isZoomSupported() → {boolean}

This method is used to know whether the camera supports zoom or not.

Source:
  - codePlugin.js, line 446

##### Returns:

true if the camera supports zoom.

Type
  boolean

#### libraryVersion() → {string}

Returns the CortexDecoderLibrary version string.

Source:
  - codePlugin.js, line 458

##### Returns:

a string containing the library version.

Type
  string

#### loadLicenseFile(fileContent)

This method is used to load the license file, activate the license and load the decoder functions.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fileContent` | string | a string that consists the content of the license file obtained License Server.

Source:
  - codePlugin.js, line 470

#### lowContrastDecodingEnabled(enabled)

This method enables & disables low contrast images of common 1D barcodes: Code 128, Code 39, UPC/EAN/JAN, I 2of 5, Codabar, Code 93. With the low contrast mode enabled, a light on dark (i.e. inverse image) barcode can also be decoded.

##### Parameters:

Name | Type | Description
--- | --- | ---
`enabled` | boolean | true to enable.

Source:
  - codePlugin.js, line 482

#### playBeepSound()

This is to manually trigger the beep sound to play.

Source:
  - codePlugin.js, line 493

#### regionOfInterestHeight(roiHeight)

This method sets barcode decoding ROI (Region of Interest). The ROI is a rectangle specified by the position of the top-left corner point and the width and height. By default, the ROI is the entire valid image area. It can be set to a smaller region to speed up the decoding if needed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`roiHeight` | int | This is the height of the ROI rectangle. The default value is 0, indicating the full image height is used. Otherwise, roiHeight can be a value up to (imageHeight – roiHeight).

Source:
  - codePlugin.js, line 505

#### regionOfInterestLeft(column)

This method sets barcode decoding ROI (Region of Interest). The ROI is a rectangle specified by the position of the top-left corner point and the width and height. By default, the ROI is the entire valid image area. It can be set to a smaller region to speed up the decoding if needed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`column` | int | This is the x or column coordinate of the ROI upper-left corner. The default value is 0.

Source:
  - codePlugin.js, line 517

#### regionOfInterestTop(row)

This method sets barcode decoding ROI (Region of Interest). The ROI is a rectangle specified by the position of the top-left corner point and the width and height. By default, the ROI is the entire valid image area. It can be set to a smaller region to speed up the decoding if needed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`row` | int | This is the y or row coordinate of the ROI top-left corner. The default value is 0.

Source:
  - codePlugin.js, line 529

#### regionOfInterestWidth(roiWidth)

This method sets barcode decoding ROI (Region of Interest). The ROI is a rectangle specified by the position of the top-left corner point and the width and height. By default, the ROI is the entire valid image area. It can be set to a smaller region to speed up the decoding if needed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`roiWidth` | int | This is the width of the ROI rectangle. The default value is 0, indicating the full image width is used. Otherwise, roiWidth can be a value up to (imageWidth – roiWidth).

Source:
  - codePlugin.js, line 541

#### setAutoFocusResetByCount(mEnabled)

A function to enable the camera to always run in autofocus mode when there is no decode for 20 frames.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mEnabled` | boolean | if true then autofocus restart every 20 frames of no decode is enabled.

Source:
  - codePlugin.js, line 553

#### setCameraType(cameraType) → {boolean}

Sets the camera type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`cameraType` | CamerType |

Source:
  - codePlugin.js, line 566

##### Returns:

Type
  boolean

#### setCameraZoom(enabled, zoom)

This method is used to set the camera zoom to a certain value when the camera zoom customization is enabled.

##### Parameters:

Name | Type | Description
--- | --- | ---
`enabled` | boolean | true to enable the feature.
`zoom` | float | float value that specifies the zoom value that camera should use.

Source:
  - codePlugin.js, line 579

#### setDecoderResolution(resolution)

This method sets the active resolution mode.

##### Parameters:

Name | Type | Description
--- | --- | ---
`resolution` | Resolution | Resolution to use for decoding.

Source:
  - codePlugin.js, line 591

#### setDecoderToleranceLevel(toleranceLevel)

Set the tolerance level to value from 0 thru 10. 0 means the target pointer has to be inside the barcode box for it to decode. Values 1 thru 9 expand the box by N times half of the barcode height in all four directions. Setting value to 10 means infinite tolerance. So when enabling picklist mode use value of either 0 or 1 and when disabling Pick list mode (default) use value of 10.

##### Parameters:

Name | Type | Description
--- | --- | ---
`toleranceLevel` | int | sets the tolerance level.

Source:
  - codePlugin.js, line 603

#### setEncodingCharsetName(charsetName)

This method sets the charset to be used when encoding decoded barcode data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`charsetName` | string | Charset to use for encoding barcode data.

Source:
  - codePlugin.js, line 615

#### setExactlyNBarcodes(enable)

##### Parameters:

Name | Type | Description
--- | --- | ---
`enable` | boolean |

Source:
  - codePlugin.js, line 626

#### setExposureSensitivity(iso)

This method is used to set the exposure senstivity.

##### Parameters:

Name | Type | Description
--- | --- | ---
`iso` | string | sets the exposure sensitivity to ep.

Source:
  - codePlugin.js, line 638

#### setExposureTime(ep)

This method is used to set the exposure time when Manual exposure mode is enabled.

##### Parameters:

Name | Type | Description
--- | --- | ---
`ep` | long | sets the exposure time to ep.

Source:
  - codePlugin.js, line 650

#### setFocus(focus) → {boolean}

This method sets the focus mode.

##### Parameters:

Name | Type | Description
--- | --- | ---
`focus` | Focus | Focus mode is set to focus.

Source:
  - codePlugin.js, line 663

##### Returns:

true if focus is set successfully.

Type
  boolean

#### setFocusDistance(distance)

This method is used to set the focus distance when fixed focus mode is enabled.

##### Parameters:

Name | Type | Description
--- | --- | ---
`distance` | float | sets the focus distance to distance.

Source:
  - codePlugin.js, line 675

#### setNumberOfBarcodesToDecode(num)

By default the number of barcodes to decode is 1 and the maximum is 20 at once. Call this function to change the amount of barcoes to decode between 1 and 20.

##### Parameters:

Name | Type | Description
--- | --- | ---
`num` | int |

Source:
  - codePlugin.js, line 687

#### setSymbologyParameters(type)

Set's the Symbolgy Parameter.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | SymbologyType | The SymbologyType that you want returned as a string.

Source:
  - codePlugin.js, line 781

#### setTorch(on)

This method turns the camera's torch on or off, if the camera supports it. if hasTorch() returns false, then the camera does not have a torch.

##### Parameters:

Name | Type | Description
--- | --- | ---
`on` | boolean | whether to turn on torch.

Source:
  - codePlugin.js, line 699

#### setWhiteBalance(enable, mBalance)

This method is used to set the white balance mode to the camera when white balance customization is enabled.

##### Parameters:

Name | Type | Description
--- | --- | ---
`enable` | boolean | is true then thsi feature is enabled.
`mBalance` | string | sets the white balance mode if enable is true.

Source:
  - codePlugin.js, line 712

#### startCameraPreview()

Starts the camera preview. This method opens the camera device if it is not already open.

Source:
  - codePlugin.js, line 723

#### startDecoding()

Starts the decoder's search for a valid barcode. Camera preview will be started if it has not already been started.

Source:
  - codePlugin.js, line 734

#### stopCameraPreview()

Stops the camera preview.

Source:
  - codePlugin.js, line 745

#### stopDecoding()

Stops the decoder's barcode search, but not the camera preview. To stop the camera preview, call stopCameraPreview().

Source:
  - codePlugin.js, line 756

#### stringFromSymbologyType(type) → {string}

This method translates a SymbologyType type to a String.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | SymbologyType | The SymbologyType that you want returned as a string.

Source:
  - codePlugin.js, line 769

##### Returns:

a string representing the SymbologyType passed to the method.

Type
  string