Constructor
new BarCodeReader(image, rectangles, decodeTypes)
Initializes a new instance of the BarCodeReader
Parameters:
Name | Type | Description |
---|---|---|
image |
encoded as base64 string or path to image | |
rectangles |
array of object by type Rectangle | |
decodeTypes |
the array of objects by DecodeType |
- Source:
Example
//This sample shows how to detect Code39 and Code128 barcodes.
let reader = new BarCodeReader("test.png", null, [DecodeType.CODE_39, DecodeType.CODE_128]);
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode Type: " + result.getCodeTypeName());
console.log("BarCode CodeText: " + result.getCodeText());
});
Methods
containsAny()
Determines whether any of the given decode types is included into
Parameters:
Name | Type | Description |
---|---|---|
...decodeTypes |
Types to verify. |
Returns:
Type | Description |
---|---|
bool Value is a true if any types are included into. |
- Source:
exportToXml(xmlFile)
Exports BarCode properties to the xml-file specified
Parameters:
Name | Type | Description |
---|---|---|
xmlFile |
The name of the file |
Returns:
Type | Description |
---|---|
Whether or not export completed successfully. Returns True in case of success; False Otherwise |
- Source:
getBarCodeDecodeType() → {*}
Gets the decode type of the input barcode decoding
Returns:
Type | Description |
---|---|
* |
- Source:
getBarcodeSettings()
The main BarCode decoding parameters. Contains parameters which make influence on recognized data.
Returns:
Type | Description |
---|---|
The main BarCode decoding parameters |
- Source:
getFoundBarCodes()
Gets recognized BarCodeResult array
Returns:
Type | Description |
---|---|
recognized BarCodeResult array |
- Source:
Example
//This sample shows how to read barcodes with BarCodeReader
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
reader.readBarCodes();
for(let i = 0; reader.getFoundCount() > i; ++i)
console.log("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());
getFoundCount()
Gets recognized barcodes count
- Source:
Example
//This sample shows how to read barcodes with BarCodeReader
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
reader.readBarCodes();
for(let i = 0; reader.getFoundCount() > i; ++i)
console.log("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());
Value: The recognized barcodes count
getQualitySettings()
QualitySettings allows to configure recognition quality and speed manually.
You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality,
HighQuality, MaxBarCodes or you can manually configure separate options.
Default value of QualitySettings is NormalQuality.
You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality,
HighQuality, MaxBarCodes or you can manually configure separate options.
Default value of QualitySettings is NormalQuality.
Returns:
Type | Description |
---|---|
QualitySettings to configure recognition quality and speed. |
- Source:
Examples
//This sample shows how to use QualitySettings with BarCodeReader
let reader = new BarCodeReader("test.png", null, null);
//set high performance mode
reader.setQualitySettings(QualitySettings.getHighPerformance());
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
//normal quality mode is set by default
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
//set high performance mode
reader.setQualitySettings(QualitySettings.getHighPerformance());
//set separate options
reader.getQualitySettings().setAllowMedianSmoothing(true);
reader.getQualitySettings().setMedianSmoothingWindowSize(5);
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
getTimeout()
Gets the timeout of recognition process in milliseconds.
Returns:
Type | Description |
---|---|
The timeout. |
- Source:
Example
let reader = new BarCodeReader("test.png", null, null);
reader.setTimeout(5000);
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
readBarCodes()
Reads BarCodeResult from the image.
Returns:
Type | Description |
---|---|
Returns array of recognized {@code BarCodeResult}s on the image. If nothing is recognized, zero array is returned. |
- Source:
Example
//This sample shows how to read barcodes with BarCodeReader
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
reader.readBarCodes();
for(let i = 0; reader.getFoundCount() > i; ++i)
console.log("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());
setBarCodeImage(imageResource, …areas)
Sets bitmap image and areas for recognition.
Must be called before ReadBarCodes() method.
Must be called before ReadBarCodes() method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
imageResource |
The image for recognition. | ||
areas |
<repeatable> |
areas list for recognition |
- Source:
Throws:
BarcodeException
Example
//This sample shows how to detect Code39 and Code128 barcodes.
let bmp = "test.png";
let reader = new BarCodeReader();
reader.setBarCodeReadType([ DecodeType.CODE_39, DecodeType.CODE_128 ]);
var img = new Image();
img.src = 'path_to_image';
width = img.width;
height = img.height;
reader.setBarCodeImage(bmp, new Rectangle[] { new Rectangle(0, 0, width, height) });
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode Type: " + result.getCodeTypeName());
console.log("BarCode CodeText: " + result.getCodeText());
});
setBarCodeReadType(…types)
Sets SingleDecodeType type array for recognition.
Must be called before readBarCodes() method.
Must be called before readBarCodes() method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
types |
<repeatable> |
The SingleDecodeType type array to read. |
- Source:
Example
//This sample shows how to detect Code39 and Code128 barcodes.
let reader = new BarCodeReader();
reader.setBarCodeReadType([ DecodeType.CODE_39, DecodeType.CODE_128 ]);
reader.setBarCodeImage("test.png");
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode Type: " + result.getCodeTypeName());
console.log("BarCode CodeText: " + result.getCodeText());
});
setQualitySettings()
QualitySettings allows to configure recognition quality and speed manually.
You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality,
HighQuality, MaxBarCodes or you can manually configure separate options.
Default value of QualitySettings is NormalQuality.
You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality,
HighQuality, MaxBarCodes or you can manually configure separate options.
Default value of QualitySettings is NormalQuality.
- Source:
Examples
//This sample shows how to use QualitySettings with BarCodeReader
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
//set high performance mode
reader.setQualitySettings(QualitySettings.getHighPerformance());
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
//normal quality mode is set by default
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
//set high performance mode
reader.setQualitySettings(QualitySettings.getHighPerformance());
//set separate options
reader.getQualitySettings().setAllowMedianSmoothing(true);
reader.getQualitySettings().setMedianSmoothingWindowSize(5);
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
QualitySettings to configure recognition quality and speed.
setTimeout(value)
Sets the timeout of recognition process in milliseconds.
Parameters:
Name | Type | Description |
---|---|---|
value |
The timeout. |
- Source:
Example
let reader = new BarCodeReader("test.png", null, null);
reader.setTimeout(5000);
reader.readBarCodes().forEach(function(result, i, results)
{
console.log("BarCode CodeText: " + result.getCodeText());
});
(static) convertToString()
internal
- Source:
(static) importFromXml(xmlFile)
Exports BarCode properties to the xml-file specified
Parameters:
Name | Type | Description |
---|---|---|
xmlFile |
The name of the file |
Returns:
Type | Description |
---|---|
Whether or not export completed successfully. Returns True in case of success; False Otherwise |
- Source: