Logo

dev-resources.site

for different kinds of informations.

Barcode Reading Problem in Flutter

Published at
8/16/2024
Categories
flutter
mobile
camera
barcode
Author
gguedes
Categories
4 categories in total
flutter
open
mobile
open
camera
open
barcode
open
Author
7 person written this
gguedes
open
Barcode Reading Problem in Flutter

A Little Background

Recently, I encountered a "problem" reported in an application. The barcode reader wasn't working correctly—the value it captured was different from what was on the document. In this article, I'll share the journey I took to understand and resolve this issue.

Spoiler: The problem was related to a specific rule in barcode generation set by FEBRABAN, the Brazilian Federation of Banks, so the issue might be more relevant to the Brazilian context, but it might still offer some valuable insights. Let's dive in!

The Problem

As mentioned, the value captured by the camera was always different from what was on the document. Up until that point, the issue seemed to be with the application, because when we manually entered the number, our backend worked just fine.

With the document below, we can simulate the problem.

slip_example_en

Reading Result:

Captured by the camera:

84620000001468501622024081048000000800872166
Enter fullscreen mode Exit fullscreen mode

The difference lies in the check digits. Take a look:

846200000012468501622020408104800003008008721667

For a while, I thought the issue was with the reader itself, or perhaps the quality of the device's camera. Interestingly, the reader worked with other documents, but not with this specific type. After various attempts, I accepted that the problem might be in the application and started digging deeper.

Hypotheses and Investigations

The package we were using for barcode reading was qr_mobile_vision. I experimented with alternatives like simple_barcode_scanner and flutter_barcode_scanner, but all of them had limitations in customizing the camera display, and they all suffered from the same reading issue. Not seeing an obvious solution, I decided to delve into the qr_mobile_vision package.

I discovered that qr_mobile_vision uses Firebase's ML Kit to read codes. After exploring the documentation and running tests, I identified that the barcode type for this document is ITF. Without enabling this type, the reader would not capture anything.

So I dug deeper and ended up finding a sample project from Google using ML Kit, but the same reading issue occurred. That's when I started to question whether the problem was actually with the reader.

A Light at the End of the Tunnel

As my research progressed, I started to consider that the issue might not be within our app. I investigated how these documents are generated and found the document "Layout Padrão de Arrecadação/Recebimento com Utilização do Código de Barras" (Standard Layout for Collection/Receipt Using Barcodes).

I learned something important:

Number Position | Number of Characters | Meaning
01 – 01 | 1 | Product Identification
02 – 02 | 1 | Segment Identification
03 – 03 | 1 | Identification of the Real Value or Reference
04 – 04 | 1 | General Check Digit (module 10 or 11)
05 – 15 | 11 | Value
16 – 19 | 4 | Company/Agency Identification
20 – 44 | 25 | Free Field for Company/Agency Use

I noticed that none of these fields mention check digits. In the following pages of this document, there's an explanation of how to calculate them, and that's where I cracked the case: The highlighted values above weren't read because they weren't present in the barcode, not due to an issue with the package, device, or operating system.

Solution

After discussing the root cause with the leadership, we agreed that the backend would receive the information as read by the camera and handle the verification logic on their side.

Conclusion

It was quite an adventure to reach the solution to this problem, but I learned a lot along the way. I hadn't found many resources on this specific issue in the Brazilian banking system at the time of writing this article, but I hope it helps anyone facing a similar challenge.

That's it, folks. Thanks for reading!

barcode Article's
30 articles in total
Favicon
Mixing Objective-C and C++ in macOS to Build a Camera-Based Barcode Scanner
Favicon
How to Implement Camera Preview with Windows Media Foundation API in C++
Favicon
Building a Lightweight C++ Camera Library for Barcode Scanning on Linux
Favicon
Building a Python Camera SDK and Using It for Multi-Barcode Scanning
Favicon
Decoding 1D/2D Barcodes from Multi-Page PDFs Using C++ and Node.js
Favicon
How to Build a macOS Barcode Scanner App Using SwiftUI and C++ Barcode SDK from Scratch
Favicon
How to Build a .NET MAUI Barcode Scanner Using IronBarcode
Favicon
How to Insert Barcodes into a PDF Document with HTML5 and JavaScript
Favicon
How to Build a Python Barcode Scanner for Windows, Linux, and macOS
Favicon
C# Barcode Libraries Compared for .NET Developers
Favicon
7 Ways RFID Technology Reduces Inventory Counting Time
Favicon
Revolutionizing Inventory Management: How RFID Technology Enhances Efficiency and Accuracy
Favicon
Barcode Reading Problem in Flutter
Favicon
Problema Leitura de Código Barras no Flutter
Favicon
How to Scan a Barcode in C#
Favicon
Mastering Parcel Scanning with C++: Barcode and OCR Text Extraction
Favicon
How to Read A Barcode in C#
Favicon
Web Parcel Management: Scan 1D Barcodes and Recognize Surrounding Text in Any Orientation
Favicon
Global Barcode Software Market is predicted to be valued at US$ 1.4 Billion by 2032
Favicon
Top 5 AI powered- Barcode Scanning Software companies
Favicon
[2024] Best Barcode Reader SDK: Scandit, Scanbot SDK, and Dynamsoft
Favicon
Building Windows Desktop Barcode Reader with Win32 API and Dynamsoft C++ Barcode SDK
Favicon
How to Generate QR Code in C# (Developer Tutorial)
Favicon
How to generate Barcodes in C#: Full tutorial
Favicon
How to Scan Barcode in C# (Developer Tutorial)
Favicon
Labeling Multiple Barcodes with Augmented Reality and Dynamsoft Barcode Reader
Favicon
Comparison of barcode scanner libraries
Favicon
Barcode Printer
Favicon
Java – How to Read Barcode from Word, Excel, PowerPoint and PDF
Favicon
How To Create Barcode Generator In Laravel 9

Featured ones: