An educational QR encoder and decoder implemented in Python. Rather than delegating the format to a QR library, the project works through finder-pattern detection, matrix extraction, masking, bitstream parsing, and Reed-Solomon correction directly.
- Load and threshold a QR image with OpenCV.
- Detect finder patterns and infer module size.
- Extract and orient the QR matrix.
- Read format information and remove the data mask.
- Traverse the data region in QR zig-zag order.
- Apply Reed-Solomon correction where supported.
- Decode numeric, alphanumeric, byte, or Kanji mode data.
- Encode the input message and character count.
- Add terminator and padding bits.
- Generate Reed-Solomon correction codewords.
- Place functional patterns and message bits in the matrix.
- Evaluate mask candidates and apply the best-scoring mask.
- Render the final matrix as an image.
| File | Responsibility |
|---|---|
read.py |
finder-pattern detection, module extraction, and orientation |
mask.py |
format parsing, mask removal/application, and penalty scoring |
decode.py |
data traversal and message decoding |
correction.py |
error-correction level parsing and Reed-Solomon recovery |
matrix_to_photo.py |
message encoding, matrix construction, and rendering |
utils.py |
version, alignment, timing, and reserved-area helpers |
git clone https://github.com/Radu028/qr-toolkit.git
cd qr-toolkit
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python __main__.pyChoose 0 to decode an image from the current directory or 1 to generate a QR image from a message.
This is a learning-oriented implementation of the QR pipeline, not a drop-in replacement for a production QR library. Images with heavy perspective distortion or unsupported format combinations may require preprocessing.
- Ionuț-Adelin Bâcă
- Radu-Stefan Popa
- Iulia-Maria Popescu