Barcode Xpress for Node.js v13.9 - Updated
Access Results
Developer Guide > How To > Access Results

analyze

The analyze() method returns a populated result containing a barcode results array of objects. Each element of the array contains the result of a single recognized barcode.

JavaScript

// Call bx.analyze to detect barcodes in the image.
// All detected barcodes will be returned to the
// result object array.
const bx = require('barcode-js');
const filePath = 'filePath/fileName.bmp';
const params = {
    type: bx.BarcodeType.CODE39  // Only search for type “code39” barcodes.
};

const analyzeBarcodes = async (filePath, params) => {
    try {
        // Find the barcodes in the document.
        const results = await bx.analyze(filePath, params);
        // We have the results, process them.
        results.forEach(item => {
            console.log("area: x=%d, y=%d, width=%d, height=%d", item.area.x, item.area.y, item.area.width, item.area.height);
            console.log("type: %s", item.type);
            console.log("value: %s", item.value);
            console.log("top-left corner: (%d, %d)", item.corners[0].x, item.corners[0].y);
            console.log("top-right corner: (%d, %d)", item.corners[1].x, item.corners[1].y);
            console.log("bottom-right corner: (%d, %d)", item.corners[2].x, item.corners[2].y);
            console.log("bottom-left corner: (%d, %d)", item.corners[3].x, item.corners[3].y);
            console.log("confidence: %d", item.confidence);
        });
    }
    catch(err) {
        console.error(`There was an error processing this image\n${err}`);
    }
}

analyzeBarcodes(filePath, params);

Is this page helpful?
Yes No
Thanks for your feedback.