View Source QRex (qrex v0.1.0)

QRex is a high-performance QR code detection and decoding library.

This module provides functionality to detect and decode QR codes from image data using Rust-based NIFs (Native Implemented Functions).

Usage

# Detect QR codes in an image
image_bytes = File.read!("qr_code.png")
{:ok, decoded_codes} = QRex.detect_qr_codes(image_bytes)

The library supports precompiled NIFs for various platforms and will automatically use the appropriate version for your system.

Error Handling

The detection function returns results in the following format:

  • {:ok, [{:ok, qr_code}, ...]} - Successful detection with decoded QR codes
  • {:ok, [{:error, reason}, ...]} - Successful detection with some decode errors
  • {:error, reason} - Failed to process the image

Environment Variables

  • RUSTLER_PRECOMPILATION_QREX_BUILD - Set to "1" or "true" to force building from source

Summary

Functions

Detects and decodes QR codes in the provided image data.

Functions

Link to this function

detect_qr_codes(image_bytes)

View Source
@spec detect_qr_codes(binary()) ::
  {:ok, ok: QRex.QRCode.t(), error: String.t()} | {:error, String.t()}

Detects and decodes QR codes in the provided image data.

Takes raw image bytes as input and attempts to locate and decode any QR codes present in the image.

Parameters

  • image_bytes - Binary data of the image file

Returns

  • {:ok, codes} where codes is a list of results:
    • {:ok, qr_code} for successfully decoded QR codes
    • {:error, reason} for QR codes that couldn't be decoded
  • {:error, reason} if image processing fails

Examples

iex> image_data = File.read!("test.png")
iex> {:ok, results} = QRex.detect_qr_codes(image_data)
iex> results
[{:ok, %QRex.QRCode{text: "Hello!", version: 1, ...}}]