This step-by-step tutorial will guide you to build a complete application that analyzes a Code 39 barcode from an image and output the value, type, location and confidence to the terminal.
For this tutorial, you can use any text editor (vim, gedit, emacs, etc.).
| JavaScript |
Copy Code
|
|---|---|
const bx = require("barcode-js");
|
|
| JavaScript |
Copy Code
|
|---|---|
const filePath = "filePath/fileName.bmp";
const params = {
type: bx.BarcodeType.ALL
};
|
|
| JavaScript |
Copy Code
|
|---|---|
const analyzeBarcodes = async (filePath, params) => {
try {
const results = await bx.analyze(filePath, params);
console.log(JSON.stringify(results, ["type", "value", "confidence"], 2));
}
catch(err) {
console.error(`There was an error processing this image\n${err}`);
}
}
analyzeBarcodes(filePath, params);
|
|
|
Copy Code
|
|
|---|---|
$ node BXDemo |
|