NEWSMRZ Scanner is now part of barKoder.What it means for you →

DOCUMENTATION

Linux

Desktop and server

Documentation / Desktop and server

On this page

One shared library with a C API, for servers, containers and devices. OpenCV, the fallback reader and the C++ runtime are linked in and hidden, so it needs nothing else.

Needs: x86_64 or aarch64, glibc 2.17 or later (any distribution since 2014).

The package

mrzscanner-linux-<arch>-2.5.0.tar.gz, under Downloads in the portal:

lib/libmrzscanner.so the library
include/mrzscanner.h the C API, documented in the header
tessdata/mrz.traineddata the fallback reader's model: pass this folder to mrz_scanner_create
example/scan.c a complete example (PGM / PPM images)

Use

#include "mrzscanner.h"

mrz_register_license("MRZ2...", "com.example.app", "", 4);      /* 4: desktop / server */
mrz_status status;
mrz_scanner *scanner = mrz_scanner_create("/opt/mrzscanner/tessdata/", &status);
mrz_image image = {pixels, width, height, 0, MRZ_PIXEL_RGB8};   /* or BGR8, RGBA8, BGRA8, GRAY8 */
mrz_result *result = NULL;
if (mrz_scan_image(scanner, &image, NULL, &result) == MRZ_OK) {
    puts(mrz_result_text(result));       /* the MRZ lines */
    puts(mrz_result_json(result));       /* the parsed fields */
}
mrz_result_free(result);
mrz_scanner_destroy(scanner);

Build:

cc app.c -I include -L lib -lmrzscanner -Wl,-rpath,'$ORIGIN/lib'

Good to know

  • The folder passed to mrz_scanner_create must be named tessdata and end with a slash.
  • A scanner is used by one thread at a time: create one per thread.
  • For a camera stream, call mrz_scan_frame on consecutive frames: a read is returned once it was confirmed over several frames. See C API reference.
  • From Python, use the mrzscanner package: the same library.

Updated Oct 24, 2026 ยท Questions? Ask us