qrio – Low-level QR code decoding

Provides the QRDecoder object used for decoding QR codes. For more information about working with QR codes, see this Learn guide.

Note

This module only handles decoding QR codes. If you are looking to generate a QR code, use the adafruit_miniqr library

Available on these boards
  • 0xCB Helios
  • 42. Keebs Frood
  • ATMegaZero ESP32-S2
  • Adafruit Camera
  • Adafruit Feather ESP32 V2
  • Adafruit Feather ESP32-S2 Reverse TFT
  • Adafruit Feather ESP32-S2 TFT
  • Adafruit Feather ESP32S2
  • Adafruit Feather RP2040
  • Adafruit Feather RP2040 Adalogger
  • Adafruit Feather RP2040 CAN
  • Adafruit Feather RP2040 DVI
  • Adafruit Feather RP2040 Prop-Maker
  • Adafruit Feather RP2040 RFM
  • Adafruit Feather RP2040 Scorpio
  • Adafruit Feather RP2040 ThinkInk
  • Adafruit Feather RP2040 USB Host
  • Adafruit Floppsy RP2040
  • Adafruit Grand Central M4 Express
  • Adafruit ItsyBitsy ESP32
  • Adafruit ItsyBitsy RP2040
  • Adafruit KB2040
  • Adafruit Macropad RP2040
  • Adafruit Metro ESP32S2
  • Adafruit Metro ESP32S3
  • Adafruit Metro RP2040
  • Adafruit QT Py ESP32 PICO
  • Adafruit QT Py ESP32S2
  • Adafruit QT Py RP2040
  • Adafruit QT2040 Trinkey
  • Adafruit-Qualia-S3-RGB666
  • Ai Thinker ESP32-CAM
  • Arduino Nano RP2040 Connect
  • Artisense Reference Design RD00
  • AutosportLabs-ESP32-CAN-X2
  • BBQ20KBD
  • BLING!
  • BLOK
  • BPI-Bit-S2
  • BPI-Leaf-S3
  • BPI-PicoW-S3
  • BlizzardS3
  • Bradán Lane STUDIO Explorer Badge
  • COSMO-Pico
  • Challenger NB RP2040 WiFi
  • Challenger RP2040 LTE
  • Challenger RP2040 LoRa
  • Challenger RP2040 SD/RTC
  • Challenger RP2040 SubGHz
  • Challenger RP2040 WiFi
  • Challenger RP2040 WiFi/BLE
  • CrumpS2
  • Cytron EDU PICO W
  • Cytron Maker Feather AIoT S3
  • Cytron Maker Nano RP2040
  • Cytron Maker Pi RP2040
  • Cytron Maker Uno RP2040
  • DFRobot FireBeetle 2 ESP32-S3
  • Datanoise PicoADK
  • Deneyap Kart
  • Deneyap Kart 1A
  • Deneyap Mini v2
  • E-Fidget
  • ELECFREAKS PICO:ED
  • ES3ink
  • ESP 12k NodeMCU
  • ESP32-S2-DevKitC-1-N4R2
  • ESP32-S2-DevKitC-1-N8R2
  • ESP32-S3-DevKitC-1-N32R8
  • ESP32-S3-DevKitC-1-N8R2
  • ESP32-S3-DevKitC-1-N8R8
  • ESP32-S3-DevKitC-1-N8R8-with-HACKTABLET
  • ESP32-S3-EYE
  • Electrolama minik
  • EncoderPad RP2040
  • Espressif ESP32-EYE
  • Espressif-ESP32-S3-LCD-EV-Board
  • FeatherS2
  • FeatherS2 Neo
  • FeatherS2 PreRelease
  • FeatherS3
  • FeatherS3 Neo
  • Fig Pi
  • Flipper Zero Wi-Fi Dev
  • Franzininho WIFI w/Wrover
  • Freenove ESP32-WROVER-DEV-CAM
  • Gravitech Cucumber R
  • Gravitech Cucumber RS
  • HEIA-FR Picomo V2
  • HMI-DevKit-1.1
  • Hack Club Sprig
  • Hardkernel Odroid Go
  • HexKyS2
  • IoTs2
  • Kaluga 1
  • LILYGO T-DECK
  • LILYGO T-DISPLAY
  • LILYGO T-DISPLAY S3 v1.2
  • LILYGO TEMBED ESP32S3
  • LILYGO TTGO T8 ESP32-S2
  • LILYGO TTGO T8 ESP32-S2 w/Display
  • Lilygo T-watch 2020 V3
  • M5Stack Core2
  • M5Stack CoreS3
  • M5Stack Timer Camera X
  • MakerFabs-ESP32-S3-Parallel-TFT-With-Touch-7inch
  • Maple Computing Elite-Pi
  • Melopero Shake RP2040
  • MicroDev microS2
  • NanoS3
  • Neuron
  • Oak Dev Tech BREAD2040
  • Oak Dev Tech Cast-Away RP2040
  • Oak Dev Tech PixelWing ESP32S2
  • Oak Dev Tech RPGA Feather
  • Pajenicko PicoPad
  • Pimoroni Badger 2040
  • Pimoroni Badger 2040 W
  • Pimoroni Inky Frame 5.7
  • Pimoroni Inky Frame 7.3
  • Pimoroni Interstate 75
  • Pimoroni Keybow 2040
  • Pimoroni Motor 2040
  • Pimoroni PGA2040
  • Pimoroni Pico DV Base W
  • Pimoroni Pico LiPo (16MB)
  • Pimoroni Pico LiPo (4MB)
  • Pimoroni Pico dv Base
  • Pimoroni PicoSystem
  • Pimoroni Plasma 2040
  • Pimoroni Plasma 2040W
  • Pimoroni Servo 2040
  • Pimoroni Tiny 2040 (2MB)
  • Pimoroni Tiny 2040 (8MB)
  • ProS3
  • PyKey 18 Numpad
  • PyKey 44 Ergo
  • PyKey 60
  • PyKey 87 TKL
  • RF.Guru RP2040
  • RP2.65-F
  • RP2040 Stamp
  • Raspberry Breadstick
  • Raspberry Pi Pico
  • Raspberry Pi Pico W
  • S2Mini
  • S2Pico
  • Saola 1 w/Wrover
  • Seeeduino XIAO RP2040
  • Silicognition LLC RP2040-Shim
  • SparkFun MicroMod RP2040 Processor
  • SparkFun Pro Micro RP2040
  • SparkFun Thing Plus - RP2040
  • Sunton-ESP32-8048S070
  • Targett Module Clip w/Wrover
  • TinyPICO
  • TinyPICO Nano
  • TinyS2
  • TinyS3
  • TinyWATCH S3
  • VCC-GND Studio YD RP2040
  • VCC-GND YD-ESP32-S3 (N16R8)
  • VCC-GND YD-ESP32-S3 (N8R8)
  • W5100S-EVB-Pico
  • W5500-EVB-Pico
  • Waveshare ESP32-S2-Pico
  • Waveshare ESP32-S2-Pico-LCD
  • Waveshare ESP32-S3-GEEK
  • Waveshare ESP32-S3-Pico
  • Waveshare ESP32-S3-Tiny
  • Waveshare RP2040-GEEK
  • Waveshare RP2040-LCD-0.96
  • Waveshare RP2040-LCD-1.28
  • Waveshare RP2040-Plus (16MB)
  • Waveshare RP2040-Plus (4MB)
  • Waveshare RP2040-TOUCH-LCD-1.28
  • Waveshare RP2040-Tiny
  • Waveshare RP2040-Zero
  • WeAct Studio Pico
  • WeAct Studio Pico 16MB
  • WisdPi Ardu2040M
  • WisdPi Tiny RP2040
  • nanoESP32-S2 w/Wrover
  • nullbits Bit-C PRO
  • splitkb.com Liatris
  • takayoshiotake Octave RP2040
  • uGame22

class qrio.PixelPolicy
EVERY_BYTE: PixelPolicy

The input buffer to QRDecoder.decode consists of greyscale values in every byte

EVEN_BYTES: PixelPolicy

The input buffer to QRDecoder.decode consists of greyscale values in positions 0, 2, …, and ignored bytes in positions 1, 3, …. This can decode directly from YUV images where the even bytes hold the Y (luminance) data.

ODD_BYTES: PixelPolicy

The input buffer to QRDecoder.decode consists of greyscale values in positions 1, 3, …, and ignored bytes in positions 0, 2, …. This can decode directly from YUV images where the odd bytes hold the Y (luminance) data

RGB565_SWAPPED: PixelPolicy

The input buffer to QRDecoder.decode consists of RGB565 values in byte-swapped order. Most cameras produce data in byte-swapped order. The green component is used.

RGB565: PixelPolicy

The input buffer to QRDecoder.decode consists of RGB565 values in native order. The green component is used.

class qrio.QRDecoder(width: int, height: int)

Construct a QRDecoder object

Parameters:
  • width (int) – The pixel width of the image to decode

  • height (int) – The pixel height of the image to decode

decode(buffer: circuitpython_typing.ReadableBuffer, pixel_policy: PixelPolicy = PixelPolicy.EVERY_BYTE) List[QRInfo]

Decode zero or more QR codes from the given image. The size of the buffer must be at least length``×``width bytes for EVERY_BYTE, and 2×``length``×``width`` bytes for EVEN_BYTES or ODD_BYTES.

find(buffer: circuitpython_typing.ReadableBuffer, pixel_policy: PixelPolicy = PixelPolicy.EVERY_BYTE) List[QRPosition]

Find all visible QR codes from the given image. The size of the buffer must be at least length``×``width bytes for EVERY_BYTE, and 2×``length``×``width`` bytes for EVEN_BYTES or ODD_BYTES.

width: int

The width of image the decoder expects

height: int

The height of image the decoder expects

class qrio.QRInfo

Information about a decoded QR code

payload: bytes

The content of the QR code

data_type: str | int

The encoding of the payload as a string (if a standard encoding) or int (if not standard)

class qrio.QRPosition

Information about a non-decoded QR code

top_left_x: int

X coordinate of the top left corner

top_left_y: int

Y coordinate of the top left corner

top_right_x: int

X coordinate of the top right corner

top_right_y: int

Y coordinate of the top right corner

bottom_right_x: int

X coordinate of the bottom right corner

bottom_right_y: int

Y coordinate of the bottom right corner

bottom_left_x: int

X coordinate of the bottom left corner

bottom_left_y: int

Y coordinate of the bottom left corner

size: int

The number of bits the code contains