Tutorial: How to Optimize Barcode Recognition Settings

Learning Objectives

In this tutorial, you’ll learn:

  • How to adjust checksum validation settings for different barcode types
  • Techniques for handling barcodes with Unicode encodings
  • Methods to process FNC symbols in Code 128 and GS1 Code 128 barcodes
  • Ways to customize Australia Post barcode recognition settings
  • How to apply various optimization settings for improved recognition accuracy

Prerequisites

Before starting this tutorial, make sure you have:

  • Completed the previous tutorials in this series
  • An active Aspose Cloud account with Client ID and Client Secret
  • A development environment with one of the supported languages (C#, Java, PHP, Python, Node.js, or Go)
  • Sample barcode images of different types for testing
  • Basic understanding of barcode standards and formats

Understanding Barcode Recognition Settings

Aspose.BarCode for Cloud provides various settings to optimize the barcode recognition process. These settings allow you to:

  • Control how checksums are validated
  • Handle special encoding formats like Unicode
  • Process special characters like FNC symbols
  • Customize recognition for specific barcode types like Australia Post

By properly configuring these settings, you can significantly improve recognition accuracy and handle complex barcode formats effectively.

Tutorial Scenario

In this tutorial, we’ll explore different barcode recognition settings through practical examples. We’ll learn how to:

  1. Configure checksum validation for different barcode types
  2. Handle barcodes with Unicode encodings
  3. Process barcodes with FNC symbols
  4. Customize Australia Post barcode recognition
  5. Combine multiple settings for optimal recognition

Step 1: Understanding Checksum Validation

Checksums are used in many barcode standards to ensure data integrity. Different barcode types have different checksum requirements:

  • Obligatory Checksum: Some barcode types (like Code 11, Code 39 MOD 43) require checksums
  • Optional Checksum: Others (like Standard Code 39, Interleaved 2 of 5) have optional checksums

Let’s explore how to configure checksum validation for both types.

Checksum Validation for Barcodes with Obligatory Checksum

For barcode types with obligatory checksums, you have the following options:

  • Default/On: Perform checksum validation (recommended)
  • Off: Skip checksum validation (may allow reading damaged barcodes, but with potential inaccuracies)

Using cURL

# Recognize barcode with checksum validation enabled
curl -v "https://api.aspose.cloud/v3.0/barcode/recognize?Type=Code11&ChecksumValidation=On&url=http://example.com/code11-barcode.png" \
     -X POST \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
     -H "Content-Type: application/json" \
     -H "Accept: application/json"

Using SDK (C# Example)

// Tutorial Code Example: Configuring checksum validation for Code 11 (obligatory checksum)
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Client;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.IO;

// Configure API credentials
var config = new Configuration
{
    ClientId = "YOUR_CLIENT_ID",
    ClientSecret = "YOUR_CLIENT_SECRET"
};

// Create API client
var apiClient = new ApiClient(config);
var barcodeApi = new BarcodeApi(apiClient);

// Specify local file path
string localFilePath = @"C:\path\to\code11-barcode.png";
byte[] fileBytes = File.ReadAllBytes(localFilePath);

try
{
    // Recognize with checksum validation enabled (for obligatory checksum)
    var responseWithValidation = barcodeApi.PostBarcodeRecognizeFromUrlOrContent(
        file: fileBytes,
        type: "Code11",
        checksumValidation: "On", // Enable checksum validation
        preset: null,
        rectX: null,
        rectY: null,
        rectWidth: null,
        rectHeight: null,
        stripFnc: null,
        timeout: null,
        medianSmoothingWindowSize: null,
        allowMedianSmoothing: null,
        allowDetectColorInverted: null,
        allowDataMatrixIndustrialBarcodes: null,
        allowQRMicroQR: null,
        allowOneDWipedBars: null,
        allowOneDFastBarcodes: null,
        australianPostEncodingTable: null,
        ignoreEndingFillingPatternsForCTable: null,
        url: null
    );

    Console.WriteLine("WITH CHECKSUM VALIDATION:");
    Console.WriteLine($"Recognition Status: {responseWithValidation.Status}");
    Console.WriteLine($"Number of barcodes found: {responseWithValidation.Barcodes.Count}");

    foreach (var barcode in responseWithValidation.Barcodes)
    {
        Console.WriteLine($"\nBarcode Value: {barcode.BarcodeValue}");
        Console.WriteLine($"Barcode Type: {barcode.BarcodeType}");
        if (!string.IsNullOrEmpty(barcode.Checksum))
        {
            Console.WriteLine($"Checksum: {barcode.Checksum}");
        }
    }

    // Now try without checksum validation
    var responseWithoutValidation = barcodeApi.PostBarcodeRecognizeFromUrlOrContent(
        file: fileBytes,
        type: "Code11",
        checksumValidation: "Off", // Disable checksum validation
        preset: null,
        rectX: null,
        rectY: null,
        rectWidth: null,
        rectHeight: null,
        stripFnc: null,
        timeout: null,
        medianSmoothingWindowSize: null,
        allowMedianSmoothing: null,
        allowDetectColorInverted: null,
        allowDataMatrixIndustrialBarcodes: null,
        allowQRMicroQR: null,
        allowOneDWipedBars: null,
        allowOneDFastBarcodes: null,
        australianPostEncodingTable: null,
        ignoreEndingFillingPatternsForCTable: null,
        url: null
    );

    Console.WriteLine("\nWITHOUT CHECKSUM VALIDATION:");
    Console.WriteLine($"Recognition Status: {responseWithoutValidation.Status}");
    Console.WriteLine($"Number of barcodes found: {responseWithoutValidation.Barcodes.Count}");

    foreach (var barcode in responseWithoutValidation.Barcodes)
    {
        Console.WriteLine($"\nBarcode Value: {barcode.BarcodeValue}");
        Console.WriteLine($"Barcode Type: {barcode.BarcodeType}");
    }
}
catch (Exception ex)
{
    Console.WriteLine($"Error: {ex.Message}");
}

Checksum Validation for Barcodes with Optional Checksum

For barcode types with optional checksums, you have the following options:

  • Default/Off: Skip checksum validation (default behavior)
  • On: Perform checksum validation (recommended for higher accuracy)

Using SDK (Python Example)

# Tutorial Code Example: Configuring checksum validation for Code 39 (optional checksum)
import aspose_barcode_cloud
from aspose_barcode_cloud.apis.barcode_api import BarcodeApi
from aspose_barcode_cloud.api_client import ApiClient
from aspose_barcode_cloud.configuration import Configuration

# Configure API credentials
configuration = Configuration(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET"
)

# Create API client
api_client = ApiClient(configuration)
barcode_api = BarcodeApi(api_client)

# URL of the Code 39 barcode image
url = "http://example.com/code39-barcode.png"

try:
    # First try with default settings (no checksum validation for Code 39)
    default_response = barcode_api.post_barcode_recognize_from_url_or_content(
        url=url,
        type="Code39Standard",
        checksum_validation="Default",  # Default behavior (no validation for optional checksums)
        preset=None,
        rect_x=None,
        rect_y=None,
        rect_width=None,
        rect_height=None,
        strip_fnc=None,
        timeout=None,
        median_smoothing_window_size=None,
        allow_median_smoothing=None,
        allow_detect_color_inverted=None,
        allow_data_matrix_industrial_barcodes=None,
        allow_qr_micro_qr=None,
        allow_one_d_wiped_bars=None,
        allow_one_d_fast_barcodes=None,
        australian_post_encoding_table=None,
        ignore_ending_filling_patterns_for_c_table=None,
        file=None
    )
    
    print("WITH DEFAULT SETTINGS (NO CHECKSUM VALIDATION):")
    print(f"Recognition Status: {default_response.status}")
    print(f"Total barcodes found: {len(default_response.barcodes)}")
    
    for i, barcode in enumerate(default_response.barcodes, 1):
        print(f"\nBarcode {i}:")
        print(f"  Value: {barcode.barcode_value}")
        print(f"  Type: {barcode.barcode_type}")
        if barcode.checksum:
            print(f"  Checksum: {barcode.checksum}")
    
    # Now try with checksum validation enabled
    validation_response = barcode_api.post_barcode_recognize_from_url_or_content(
        url=url,
        type="Code39Standard",
        checksum_validation="On",  # Enable checksum validation
        preset=None,
        rect_x=None,
        rect_y=None,
        rect_width=None,
        rect_height=None,
        strip_fnc=None,
        timeout=None,
        median_smoothing_window_size=None,
        allow_median_smoothing=None,
        allow_detect_color_inverted=None,
        allow_data_matrix_industrial_barcodes=None,
        allow_qr_micro_qr=None,
        allow_one_d_wiped_bars=None,
        allow_one_d_fast_barcodes=None,
        australian_post_encoding_table=None,
        ignore_ending_filling_patterns_for_c_table=None,
        file=None
    )
    
    print("\nWITH CHECKSUM VALIDATION ENABLED:")
    print(f"Recognition Status: {validation_response.status}")
    print(f"Total barcodes found: {len(validation_response.barcodes)}")
    
    for i, barcode in enumerate(validation_response.barcodes, 1):
        print(f"\nBarcode {i}:")
        print(f"  Value: {barcode.barcode_value}")
        print(f"  Type: {barcode.barcode_type}")
        if barcode.checksum:
            print(f"  Checksum: {barcode.checksum}")
            
except Exception as e:
    print(f"Error: {str(e)}")

Try It Yourself!

Find or create sample barcodes with both obligatory and optional checksums. Try recognizing them with different checksum validation settings and observe the differences in the results.

Step 2: Handling Barcodes with Unicode Encodings

2D barcode types like QR Code and Data Matrix can store text encoded in Unicode formats such as UTF-8 and UTF-16. Aspose.BarCode for Cloud provides settings to automatically detect and handle these encodings.

Using SDK (Java Example)

// Tutorial Code Example: Handling barcodes with Unicode encodings
import com.aspose.barcode.cloud.api.BarcodeApi;
import com.aspose.barcode.cloud.client.ApiClient;
import com.aspose.barcode.cloud.model.BarcodeResponseList;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class UnicodeBarcodeSample {

    public static void main(String[] args) {
        try {
            // Configure API credentials
            ApiClient apiClient = new ApiClient("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
            BarcodeApi barcodeApi = new BarcodeApi(apiClient);
            
            // Specify parameters
            String localFilePath = "/path/to/unicode-qrcode.png";
            String barcodeType = "QR";
            
            // Read image file bytes
            File file = new File(localFilePath);
            byte[] fileBytes = Files.readAllBytes(file.toPath());
            
            // First try with Unicode detection enabled (default)
            BarcodeResponseList responseWithUnicode = barcodeApi.postBarcodeRecognizeFromUrlOrContent(
                null, // url
                barcodeType,
                "Default", // checksumValidation
                null, // preset
                null, // rectX
                null, // rectY
                null, // rectWidth
                null, // rectHeight
                null, // stripFnc
                null, // timeout
                null, // medianSmoothingWindowSize
                null, // allowMedianSmoothing
                true, // allowDetectColorInverted (enable Unicode detection)
                null, // allowDataMatrixIndustrialBarcodes
                null, // allowQRMicroQR
                null, // allowOneDWipedBars
                null, // allowOneDFastBarcodes
                null, // australianPostEncodingTable
                null, // ignoreEndingFillingPatternsForCTable
                fileBytes // file
            );
            
            // Process results with Unicode detection
            System.out.println("WITH UNICODE DETECTION ENABLED:");
            System.out.println("Recognition Status: " + responseWithUnicode.getStatus());
            System.out.println("Number of barcodes found: " + responseWithUnicode.getBarcodes().size());
            
            responseWithUnicode.getBarcodes().forEach(barcode -> {
                System.out.println("\nBarcode Value: " + barcode.getBarcodeValue());
                System.out.println("Barcode Type: " + barcode.getBarcodeType());
            });
            
            // Now try with Unicode detection disabled
            BarcodeResponseList responseWithoutUnicode = barcodeApi.postBarcodeRecognizeFromUrlOrContent(
                null, // url
                barcodeType,
                "Default", // checksumValidation
                null, // preset
                null, // rectX
                null, // rectY
                null, // rectWidth
                null, // rectHeight
                null, // stripFnc
                null, // timeout
                null, // medianSmoothingWindowSize
                null, // allowMedianSmoothing
                false, // allowDetectColorInverted (disable Unicode detection)
                null, // allowDataMatrixIndustrialBarcodes
                null, // allowQRMicroQR
                null, // allowOneDWipedBars
                null, // allowOneDFastBarcodes
                null, // australianPostEncodingTable
                null, // ignoreEndingFillingPatternsForCTable
                fileBytes // file
            );
            
            // Process results without Unicode detection
            System.out.println("\nWITH UNICODE DETECTION DISABLED:");
            System.out.println("Recognition Status: " + responseWithoutUnicode.getStatus());
            System.out.println("Number of barcodes found: " + responseWithoutUnicode.getBarcodes().size());
            
            responseWithoutUnicode.getBarcodes().forEach(barcode -> {
                System.out.println("\nBarcode Value: " + barcode.getBarcodeValue());
                System.out.println("Barcode Type: " + barcode.getBarcodeType());
            });
            
        } catch (Exception e) {
            System.err.println("Error: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

Try It Yourself!

Create a QR Code with Unicode characters (like characters from different languages) and test the recognition with Unicode detection enabled and disabled. Compare the results to see how the setting affects the recognition of special characters.

Step 3: Processing FNC Symbols in Code 128 Barcodes

Function (FNC) symbols are special characters used in Code 128 and GS1 Code 128 barcodes for specific purposes. By default, Aspose.BarCode for Cloud processes these symbols as “<FNC#>” in the decoded text, but you can configure how these symbols are handled.

Using SDK (PHP Example)

<?php
// Tutorial Code Example: Processing FNC symbols in Code 128 barcodes

require_once(__DIR__ . '/vendor/autoload.php');

use Aspose\BarCode\Cloud\Api\BarcodeApi;
use Aspose\BarCode\Cloud\Api\Configuration;
use GuzzleHttp\Client;

// Configure API credentials
$config = new Configuration();
$config->setClientId('YOUR_CLIENT_ID');
$config->setClientSecret('YOUR_CLIENT_SECRET');

// Create API client
$apiClient = new Client();
$barcodeApi = new BarcodeApi($apiClient, $config);

try {
    // URL of the Code 128 barcode with FNC symbols
    $url = 'http://example.com/code128-with-fnc.png';
    $barcodeType = 'Code128';
    
    // First try with default FNC handling (keeping FNC symbols)
    $responseWithFNC = $barcodeApi->postBarcodeRecognizeFromUrlOrContent(
        $url,
        $barcodeType,
        'Default', // checksumValidation
        null, // preset
        null, // rectX
        null, // rectY
        null, // rectWidth
        null, // rectHeight
        false, // stripFnc - keep FNC symbols
        null, // timeout
        null, // medianSmoothingWindowSize
        null, // allowMedianSmoothing
        null, // allowDetectColorInverted
        null, // allowDataMatrixIndustrialBarcodes
        null, // allowQRMicroQR
        null, // allowOneDWipedBars
        null, // allowOneDFastBarcodes
        null, // australianPostEncodingTable
        null, // ignoreEndingFillingPatternsForCTable
        null  // file
    );
    
    // Process results with FNC symbols
    echo "WITH FNC SYMBOLS PRESERVED:\n";
    echo "Recognition Status: " . $responseWithFNC->getStatus() . "\n";
    echo "Number of barcodes found: " . count($responseWithFNC->getBarcodes()) . "\n";
    
    foreach ($responseWithFNC->getBarcodes() as $barcode) {
        echo "\nBarcode Value: " . $barcode->getBarcodeValue() . "\n";
        echo "Barcode Type: " . $barcode->getBarcodeType() . "\n";
    }
    
    // Now try with FNC symbols stripped
    $responseWithoutFNC = $barcodeApi->postBarcodeRecognizeFromUrlOrContent(
        $url,
        $barcodeType,
        'Default', // checksumValidation
        null, // preset
        null, // rectX
        null, // rectY
        null, // rectWidth
        null, // rectHeight
        true, // stripFnc - remove FNC symbols
        null, // timeout
        null, // medianSmoothingWindowSize
        null, // allowMedianSmoothing
        null, // allowDetectColorInverted
        null, // allowDataMatrixIndustrialBarcodes
        null, // allowQRMicroQR
        null, // allowOneDWipedBars
        null, // allowOneDFastBarcodes
        null, // australianPostEncodingTable
        null, // ignoreEndingFillingPatternsForCTable
        null  // file
    );
    
    // Process results without FNC symbols
    echo "\nWITH FNC SYMBOLS STRIPPED:\n";
    echo "Recognition Status: " . $responseWithoutFNC->getStatus() . "\n";
    echo "Number of barcodes found: " . count($responseWithoutFNC->getBarcodes()) . "\n";
    
    foreach ($responseWithoutFNC->getBarcodes() as $barcode) {
        echo "\nBarcode Value: " . $barcode->getBarcodeValue() . "\n";
        echo "Barcode Type: " . $barcode->getBarcodeType() . "\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Step 4: Customizing Australia Post Barcode Recognition

Australia Post barcodes have specific format control codes (FCC) and can contain customer information in different formats. Aspose.BarCode for Cloud provides settings to customize how this information is interpreted.

Using SDK (Python Example)

# Tutorial Code Example: Customizing Australia Post barcode recognition
import aspose_barcode_cloud
from aspose_barcode_cloud.apis.barcode_api import BarcodeApi
from aspose_barcode_cloud.api_client import ApiClient
from aspose_barcode_cloud.configuration import Configuration

# Configure API credentials
configuration = Configuration(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET"
)

# Create API client
api_client = ApiClient(configuration)
barcode_api = BarcodeApi(api_client)

# URL of the Australia Post barcode image
url = "http://example.com/australia-post-barcode.png"

try:
    # Try with CTable encoding (default)
    ctable_response = barcode_api.post_barcode_recognize_from_url_or_content(
        url=url,
        type="AustraliaPost",
        checksum_validation="Default",
        preset=None,
        rect_x=None,
        rect_y=None,
        rect_width=None,
        rect_height=None,
        strip_fnc=None,
        timeout=None,
        median_smoothing_window_size=None,
        allow_median_smoothing=None,
        allow_detect_color_inverted=None,
        allow_data_matrix_industrial_barcodes=None,
        allow_qr_micro_qr=None,
        allow_one_d_wiped_bars=None,
        allow_one_d_fast_barcodes=None,
        australian_post_encoding_table="CTable",  # Use CTable encoding
        ignore_ending_filling_patterns_for_c_table=False,  # Don't ignore filling patterns
        file=None
    )
    
    print("WITH CTABLE ENCODING:")
    print(f"Recognition Status: {ctable_response.status}")
    print(f"Total barcodes found: {len(ctable_response.barcodes)}")
    
    for i, barcode in enumerate(ctable_response.barcodes, 1):
        print(f"\nBarcode {i}:")
        print(f"  Value: {barcode.barcode_value}")
        print(f"  Type: {barcode.barcode_type}")
    
    # Try with NTable encoding
    ntable_response = barcode_api.post_barcode_recognize_from_url_or_content(
        url=url,
        type="AustraliaPost",
        checksum_validation="Default",
        preset=None,
        rect_x=None,
        rect_y=None,
        rect_width=None,
        rect_height=None,
        strip_fnc=None,
        timeout=None,
        median_smoothing_window_size=None,
        allow_median_smoothing=None,
        allow_detect_color_inverted=None,
        allow_data_matrix_industrial_barcodes=None,
        allow_qr_micro_qr=None,
        allow_one_d_wiped_bars=None,
        allow_one_d_fast_barcodes=None,
        australian_post_encoding_table="NTable",  # Use NTable encoding (numeric only)
        ignore_ending_filling_patterns_for_c_table=False,
        file=None
    )
    
    print("\nWITH NTABLE ENCODING:")
    print(f"Recognition Status: {ntable_response.status}")
    print(f"Total barcodes found: {len(ntable_response.barcodes)}")
    
    for i, barcode in enumerate(ntable_response.barcodes, 1):
        print(f"\nBarcode {i}:")
        print(f"  Value: {barcode.barcode_value}")
        print(f"  Type: {barcode.barcode_type}")
    
    # Try with CTable encoding and ignore filling patterns
    ctable_ignore_response = barcode_api.post_barcode_recognize_from_url_or_content(
        url=url,
        type="AustraliaPost",
        checksum_validation="Default",
        preset=None,
        rect_x=None,
        rect_y=None,
        rect_width=None,
        rect_height=None,
        strip_fnc=None,
        timeout=None,
        median_smoothing_window_size=None,
        allow_median_smoothing=None,
        allow_detect_color_inverted=None,
        allow_data_matrix_industrial_barcodes=None,
        allow_qr_micro_qr=None,
        allow_one_d_wiped_bars=None,
        allow_one_d_fast_barcodes=None,
        australian_post_encoding_table="CTable",  # Use CTable encoding
        ignore_ending_filling_patterns_for_c_table=True,  # Ignore filling patterns
        file=None
    )
    
    print("\nWITH CTABLE ENCODING AND IGNORE FILLING PATTERNS:")
    print(f"Recognition Status: {ctable_ignore_response.status}")
    print(f"Total barcodes found: {len(ctable_ignore_response.barcodes)}")
    
    for i, barcode in enumerate(ctable_ignore_response.barcodes, 1):
        print(f"\nBarcode {i}:")
        print(f"  Value: {barcode.barcode_value}")
        print(f"  Type: {barcode.barcode_type}")
        
except Exception as e:
    print(f"Error: {str(e)}")

Understanding Australia Post Encoding Tables

Australia Post barcodes can encode customer information in different formats:

Encoding TableSupported Symbols
CTableNumerical digits, English letters, space symbol, and #
NTableNumerical digits only
Other0, 1, 2, and 3 (corresponding to H, A, D, and T states)

Step 5: Combining Multiple Settings for Optimal Recognition

In real-world applications, you’ll often need to combine multiple settings to achieve optimal recognition results. Let’s create an example that demonstrates how to apply various settings together.

Using SDK (Node.js Example)

// Tutorial Code Example: Combining multiple recognition settings
const fs = require('fs');
const { Configuration, BarcodeApi } = require('aspose-barcode-cloud');

// Configure API credentials
const config = new Configuration({
    clientId: "YOUR_CLIENT_ID",
    clientSecret: "YOUR_CLIENT_SECRET"
});

// Create API client
const barcodeApi = new BarcodeApi(config);

// Function to recognize barcode with optimal settings
async function recognizeBarcodeWithOptimalSettings(filePath, barcodeType) {
    try {
        // Read file as buffer
        const fileBuffer = fs.readFileSync(filePath);
        
        // Apply optimal settings based on barcode type
        let checksumValidation = "Default";
        let stripFnc = false;
        let allowDetectColorInverted = true;
        let australianPostEncodingTable = null;
        let ignoreEndingFillingPatternsForCTable = null;
        
        // Customize settings based on barcode type
        switch(barcodeType) {
            case "Code128":
            case "GS1Code128":
                // For Code 128, we keep FNC symbols and validate checksums
                stripFnc = false;
                checksumValidation = "On";
                break;
                
            case "Code39Standard":
            case "Interleaved2of5":
                // For barcodes with optional checksums, we enable validation
                checksumValidation = "On";
                break;
                
            case "QR":
            case "DataMatrix":
                // For 2D barcodes, we enable color inversion detection
                allowDetectColorInverted = true;
                break;
                
            case "AustraliaPost":
                // For Australia Post barcodes, we use CTable and ignore filling patterns
                australianPostEncodingTable = "CTable";
                ignoreEndingFillingPatternsForCTable = true;
                break;
                
            default:
                // Default settings for other types
                break;
        }
        
        // Perform recognition with optimized settings
        const response = await barcodeApi.postBarcodeRecognizeFromUrlOrContent(
            null, // url
            barcodeType,
            checksumValidation,
            null, // preset
            null, // rectX
            null, // rectY
            null, // rectWidth
            null, // rectHeight
            stripFnc,
            null, // timeout
            null, // medianSmoothingWindowSize
            null, // allowMedianSmoothing
            allowDetectColorInverted,
            null, // allowDataMatrixIndustrialBarcodes
            null, // allowQRMicroQR
            null, // allowOneDWipedBars
            null, // allowOneDFastBarcodes
            australianPostEncodingTable,
            ignoreEndingFillingPatternsForCTable,
            fileBuffer // file
        );
        
        return response;
    } catch (error) {
        console.error(`Error recognizing ${barcodeType} barcode:`, error);
        throw error;
    }
}

// Process recognition results
function processResults(response) {
    console.log(`Recognition Status: ${response.status}`);
    console.log(`Total barcodes found: ${response.barcodes.length}`);
    
    response.barcodes.forEach((barcode, index) => {
        console.log(`\nBarcode ${index + 1}:`);
        console.log(`  Value: ${barcode.barcodeValue}`);
        console.log(`  Type: ${barcode.barcodeType}`);
        
        if (barcode.region) {
            console.log(`  Region: ${barcode.region.join(', ')}`);
        }
        
        if (barcode.checksum) {
            console.log(`  Checksum: ${barcode.checksum}`);
        }
    });
}

// Example usage
async function main() {
    try {
        // Example for Code 128 barcode
        console.log("RECOGNIZING CODE 128 BARCODE:");
        const code128Response = await recognizeBarcodeWithOptimalSettings(
            "./code128-sample.png", 
            "Code128"
        );
        processResults(code128Response);
        
        // Example for QR Code
        console.log("\nRECOGNIZING QR CODE:");
        const qrResponse = await recognizeBarcodeWithOptimalSettings(
            "./qrcode-sample.png", 
            "QR"
        );
        processResults(qrResponse);
        
        // Example for Australia Post barcode
        console.log("\nRECOGNIZING AUSTRALIA POST BARCODE:");
        const australiaPostResponse = await recognizeBarcodeWithOptimalSettings(
            "./australiapost-sample.png", 
            "AustraliaPost"
        );
        processResults(australiaPostResponse);
    } catch (error) {
        console.error("Error in main function:", error);
    }
}

// Run the example
main();

Troubleshooting Common Issues

Issue: Incorrect Barcode Recognition

If barcodes are not recognized correctly:

  • Try enabling checksum validation with checksumValidation = "On"
  • For 2D barcodes with special characters, ensure Unicode detection is enabled
  • Verify that the barcode type is correctly specified
  • Try different recognition settings based on the barcode type

Issue: Missing or Incorrect FNC Symbols

If FNC symbols in Code 128 barcodes are causing issues:

  • Use stripFnc = true to remove FNC symbols from the output
  • Use stripFnc = false to keep FNC symbols if they’re part of your data format

Issue: Problems with Australia Post Barcodes

If Australia Post barcodes are not recognized correctly:

  • Try different encoding tables (CTable, NTable, Other) depending on the content
  • Use ignoreEndingFillingPatternsForCTable = true if you’re getting extra “z” characters

What You’ve Learned

In this tutorial, you’ve learned:

  • How to configure checksum validation for different barcode types
  • Techniques for handling barcodes with Unicode encodings
  • Methods to process FNC symbols in Code 128 and GS1 Code 128 barcodes
  • Ways to customize Australia Post barcode recognition settings
  • How to combine multiple settings for optimal recognition results

Recognition Settings Summary Table

SettingPurposeOptionsBest Used For
Checksum ValidationControls how checksums are verifiedDefault, On, OffImproving accuracy or reading damaged barcodes
Unicode DetectionHandles special character encodingstrue, false2D barcodes with international characters
FNC Symbol HandlingControls processing of FNC characterstrue (strip), false (keep)Code 128 barcodes with function characters
Australia Post EncodingSets encoding for customer informationCTable, NTable, OtherAustralia Post barcodes with different content types

Next Steps

Ready to explore more about barcode recognition in the cloud? Check out the next tutorial in this series:

Tutorial: Decoding Barcode Properties and Metadata

Further Practice

To reinforce what you’ve learned, try these exercises:

  1. Create a program that automatically detects the best recognition settings based on barcode content
  2. Build a solution that processes different barcode types with type-specific optimizations
  3. Experiment with different combinations of settings to achieve the best accuracy for your specific use case

Helpful Resources

Feedback

Did you find this tutorial helpful? Do you have questions about optimizing barcode recognition settings? We’d love to hear from you! Please leave your questions and feedback in our support forum.