ESP-Barcode-Scanner Component
Note
This document is automatically translated using AI. Please excuse any detailed errors. The official English version is still in progress.
esp_barcode_scanner is a lightweight barcode and QR-code detection and decoding component developed by Espressif. It is deeply optimized for Espressif chips, combining a high frame rate, a high recognition rate, and a zero false-read rate. It is suitable for payment terminals, smart access control, industrial scanners, and other embedded vision devices.
Contents
Features
Supported Symbologies
The component integrates Espressif’s own 1D and 2D detection and decoding engines. Symbologies can be trimmed statically in menuconfig to reduce flash and RAM use, and filtered at runtime with a dynamic mask:
Category |
Symbology |
Default |
Description |
|---|---|---|---|
2D code |
QR Code |
Enabled by default |
Conforms to ISO/IEC 18004 (GB/T 18284). Supports Version 1–40 and the L/M/Q/H error-correction levels. Optimized for WeChat and Alipay codes used in China that have a center logo or dotted styling |
2D code |
PDF417 |
Optional |
Conforms to ISO/IEC 15438. Supports multi-row stacked barcodes and error-correction recovery |
2D code |
Data Matrix (ECC200) |
Optional |
Conforms to ISO/IEC 16022. Supports square and rectangular ECC200 industrial traceability codes |
1D code |
Code 128 |
Enabled by default |
High-density full-ASCII alphanumeric 1D code |
1D code |
EAN-13 / EAN-8 |
Enabled by default |
International retail barcodes |
1D code |
UPC-A / UPC-E |
Enabled by default |
North American retail barcodes (12 digits / 8-digit compressed code) |
1D code |
Code 39 |
Optional |
Supports forced check-digit filtering and multi-confirmation to prevent false triggers |
1D code |
Code 93 |
Optional |
Compact alphanumeric 1D code |
1D code |
ITF (Interleaved 2 of 5) |
Optional |
Interleaved 2 of 5 code commonly used on logistics cartons. A minimum length threshold can be configured (6 digits by default) |
Core Features
High real-time performance and a low false-read rate: a two-stage flow locates the region first and then corrects and decodes it. This takes much less time than a blind full-image scan. A strict check keeps the false-read rate at zero in high-contrast, complex backgrounds such as blinds and grids.
Deep acceleration on Espressif chips: instruction-set acceleration is provided for the ESP32-S3, ESP32-S31, and ESP32-P4. On the ESP32-S31 and ESP32-P4 it can be enabled with
CONFIG_ESP_BARCODE_SCANNER_PIE=y. On the ESP32-S31 the recognition task must run on Core 1.Synchronous mode and dual-core pipeline mode: - Synchronous mode: one task performs both detection and decoding. Memory use is very low, which suits a single core or a resource-constrained device. - Dual-core asynchronous pipeline mode: on a multi-core chip, detection and decoding can be scheduled in parallel (detection on Core 1, decoding on Core 0), which further increases the throughput of continuous scanning on a video stream.
Video stream and complex-scene enhancement: - Multi-frame tracking and fused recognition improve the pass rate for blur, reflection, long distance, large tilt, and payment codes that contain a logo. - Failed recognition can be retried automatically, with a full-image fallback scan. A per-frame timeout can be configured so the camera preview stays smooth.
Input format:
GRAY8(Y-only grayscale) image input is supported and can connect directly to the grayscale output of a camera or ISP.Supported chips: ESP32-S3, ESP32-S31, and ESP32-P4.
Recognition Rate Compared with Open-Source Solutions
Open-Source QR and Barcode Libraries
Solution / library |
Symbology coverage |
Compliance and engineering notes |
|---|---|---|
esp_barcode_scanner (developed by Espressif) |
1D + QR + PDF417 + Data Matrix |
No third-party copyleft dependency. Commercial use on Espressif chips has no LGPL static-linking compliance burden. Deeply optimized for embedded memory and compute |
ZXing ( |
1D + QR + PDF417 + Data Matrix, and others |
Apache-2.0 license, commercially friendly (copyright and NOTICE statements must be retained). The C++ implementation has a large code size and higher heap and CPU cost, so integrating it directly on an MCU is heavy |
ZBar ( |
1D + QR (PDF417 and Data Matrix are not supported) |
LGPL-2.1 weak-copyleft license (watch the commercial compliance risk): when used in a statically linked MCU firmware that has no dynamic library, LGPL-2.1 requires the user to be given relinkable object files or source code |
quirc |
QR Code only (1D, PDF417, and Data Matrix are not supported) |
Permissive ISC license, commercially friendly. The implementation is lightweight, but it has no 1D capability, and its tolerance is weaker for strong tilt, a center portrait that occludes the code, and QR codes with complex distortion |
Measured Recognition Rate (Unified 480P Grayscale Images)
On a unified 480P grayscale test set of 2,001 positive samples + 87 negative samples (9 standard and real-world subsets in total), the measured recognition rates of esp_barcode_scanner, ZXing (zxing-cpp), and ZBar (0.23.92) are:
Engine |
Positive-sample recognition rate (2,001 images) |
Negative-sample zero-false-read pass rate (87 images) |
Notes |
|---|---|---|---|
esp_barcode_scanner |
71.5% (1,430 / 2,001) |
100.0% (87 / 87, 0 false reads) |
Highest overall recall, 0 false positives |
ZXing (zxing-cpp) |
63.6% (1,273 / 2,001) |
100.0% (87 / 87, 0 false reads) |
About 1/3 the speed of this engine |
ZBar (0.23.92) |
55.6% (1,112 / 2,001) |
98.9% (86 / 87, 1 false read) |
PDF417 and Data Matrix are not supported. One false positive on a high-texture negative sample |
Test set and scene |
Samples |
esp_barcode_scanner |
ZXing |
ZBar |
Status |
|---|---|---|---|---|---|
|
500 |
45.8% (229) |
40.4% (202) |
36.4% (182) |
PASS |
|
952 |
70.5% (671) |
59.0% (562) |
51.5% (490) |
PASS |
|
179 |
96.1% (172) |
92.7% (166) |
86.0% (154) |
PASS |
|
30 |
63.3% (19) |
56.7% (17) |
63.3% (19) |
PASS |
|
120 |
100.0% (120) |
100.0% (120) |
95.0% (114) |
PASS |
|
160 |
100.0% (160) |
95.6% (153) |
95.6% (153) |
PASS |
|
60 |
98.3% (59) |
88.3% (53) |
0.0% (0) (not supported) |
PASS |
|
47 |
100.0% (47, 0 false reads) |
100.0% (47) |
100.0% (47) |
PASS |
|
40 |
100.0% (40, 0 false reads) |
100.0% (40) |
97.5% (39, 1 false read) |
PASS |
Measured Frame Rate on Board at 480P (ESP32-S3 / ESP32-S31 / ESP32-P4)
All on-board frame rates were measured at 480P (640×480) with a single-Y (GRAY8) image. The test task ran on Core 1, and every image was detected and decoded stably at 100%.
Key High-Performance sdkconfig Settings
To use the chip’s compute and memory bandwidth, all three chips enable the following common optimizations, and each sets CPU, flash, PSRAM, and cache to a high-performance mode:
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_120M=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF=y
CONFIG_FREERTOS_HZ=1000
CONFIG_SPIRAM=y
CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_XIP_FROM_PSRAM=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=128
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y
CONFIG_SPI_FLASH_HPM_ENA=y
CONFIG_BOOTLOADER_FLASH_DC_AWARE=y
CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y
CONFIG_ESP32S3_INSTRUCTION_CACHE_8WAYS=y
CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_32B=y
CONFIG_ESP32S3_DATA_CACHE_64KB=y
CONFIG_ESP32S3_DATA_CACHE_8WAYS=y
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_SPEED_120M=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_320=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_SPEED_250M=y
CONFIG_ESP_BARCODE_SCANNER_PIE=y
CONFIG_ESP32P4_REV_MIN_301=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_400=y
CONFIG_SPI_FLASH_HPM_ENA=y
CONFIG_BOOTLOADER_FLASH_DC_AWARE=y
CONFIG_SPIRAM_MODE_HEX=y
CONFIG_SPIRAM_SPEED_250M=y
CONFIG_CACHE_L2_CACHE_256KB=y
CONFIG_CACHE_L2_CACHE_LINE_128B=y
CONFIG_ESP_BARCODE_SCANNER_PIE=y
Measured Frame Rate for 480P WeChat and Alipay QR Codes (Y-Only Input to a Decoded Result)
The table below is the measured end-to-end frame rate for 480P (640×480) Y-only (GRAY8) input, including image scaling, detection, correction, and full decoding. 2D QR only and the default 1D + 2D mixed symbology mode were tested separately:
480P sample |
ESP32-S3 (240MHz) (2D / 1D+2D) |
ESP32-S31 (320MHz) (2D / 1D+2D) |
ESP32-P4 (400MHz) (2D / 1D+2D) |
|---|---|---|---|
|
69.82 / 54.86 fps |
109.54 / 85.12 fps |
164.93 / 124.26 fps |
|
67.80 / 54.38 fps |
107.62 / 85.32 fps |
161.05 / 124.23 fps |
|
44.42 / 37.90 fps |
74.15 / 62.20 fps |
104.04 / 86.47 fps |
|
87.36 / 66.91 fps |
135.01 / 102.87 fps |
202.14 / 148.25 fps |
Average of 4 frames |
63.46 / 51.32 fps |
101.74 / 81.19 fps |
149.08 / 116.26 fps |
Tip
At 480P, prefer
GRAY8(Y-only grayscale) input for the best frame rate.When
CONFIG_ESP_BARCODE_SCANNER_PIE=yis enabled on the ESP32-S31, make sure the scan task runs on Core 1. To run it together with peripherals or the UI, enableCONFIG_ESP_BARCODE_SCANNER_PIPELINE=yso detection runs on Core 1 and decoding runs on Core 0.