Dynamsoft / barcode-reader-javascript

Dynamsoft Barcode Reader JavaScript SDK for package managers. PDF417, QR Code, DataMatrix, MaxiCode and more are supported.
https://www.dynamsoft.com/barcode-reader/sdk-javascript/
Other
170 stars 110 forks source link

update runtime settings to set region defination #74

Closed bmabir17 closed 3 years ago

bmabir17 commented 3 years ago

For a particular reason i have to define the region defination as the code is defined in left most part of the image. tried the following code but the updateRuntimeSettings becomes null

scanner = scanner || await Dynamsoft.DBR.BarcodeScanner.createInstance();
let scanner_settings = await scanner.getRuntimeSettings();
console.log(scanner_settings);
scanner_settings.region.regionLeft=25;
await reader.updateRuntimeSettings(scanner_settings);

I tried the python sdk where i needed to set the runtime settings as follows

"RegionDefinition": {
      "BarcodeFormatIds": [
        "BF_ALL"
      ],
      "BarcodeFormatIds_2": [
        "BF2_POSTALCODE",
        "BF2_DOTCODE"
      ],
      "Bottom": 100,
      "ExpectedBarcodesCount": 0,
      "FormatSpecificationNameArray": null,
      "Left": 25,
      "MeasuredByPercentage": 1,
      "Name": "default",
      "Right": 32,
      "Top": 0
    },

Now i want the similar settings to be set on the js sdk

Keillion commented 3 years ago

@bmabir17

scanner_settings.region.regionLeft = 25;
scanner_settings.region.regionTop = 0;
scanner_settings.region.regionRight = 32;
scanner_settings.region.regionBottom = 100;
scanner_settings.region.regionMeasuredByPercentage = 1;
await reader.updateRuntimeSettings(scanner_settings);
Keillion commented 3 years ago

@bmabir17 I am a little puzzled why it was a scanner in the beginning, and then it became a reader.

bmabir17 commented 3 years ago

sorry that was my mistake :sweat_smile:

bmabir17 commented 3 years ago

This worked

scanner = scanner || await Dynamsoft.DBR.BarcodeScanner.createInstance();
let scanner_settings = await scanner.getRuntimeSettings();
console.log(scanner_settings);
scanner_settings.region.regionLeft = 25;
scanner_settings.region.regionTop = 0;
scanner_settings.region.regionRight = 32;
scanner_settings.region.regionBottom = 100;
scanner_settings.region.regionMeasuredByPercentage = 1;
await scanner.updateRuntimeSettings(scanner_settings);