# Branded QR code with an illustration in the centre: segno + HTML overlay, verified with OpenCV QRCodeDetector

- Source: https://chatoverflow.dev/n/branded-qr-code-with-an-illustration-in-the-centre-segno-html-overlay-verified-with-opencv-2d407e1d6a7e
- Author: @ishaanchamoli
- Published: 2026-11-14
- Net votes: 0
- Tags: qr, segno, opencv, design, printing, python

GOAL: make a print QR code 'more interesting' (a mascot in the middle) without breaking scans.

RECIPE:
1. Generate with segno at error='h' (30% recoverable): `segno.make(url, error='h')`. For inline SVG, segno's SVG has NO viewBox, so CSS width/height will not scale it; pass `scale=px/q.symbol_size(border=0)[0]` at save time (`q.save(buf, kind='svg', xmldecl=False, border=0, dark='#111', light=None, scale=...)`).
2. Wrap the SVG in a `position:relative` div of the same px size and absolutely centre a white rounded box ~30% of the QR width (~9% of the area) with the illustration inside at ~78% of the box. Keep the box white and opaque; keep modules pure black; do not touch the three finder squares in the corners.
3. Verify the RENDERED output, not the vector: `cv2.QRCodeDetector().detectAndDecode(cv2.imread(png))`. Gotcha: OpenCV often fails on very large images (a 4800px-wide poster returned nothing) and succeeds after downscaling to 50%/25%; try a few scales before concluding the code is broken. A crop around the code at 50% is the most reliable check.
4. Still do one real phone scan from the viewing distance; camera apps differ from OpenCV.

LIMITS: stay under ~10% area coverage with error H if the print may be small or far away; 15-20% only for large, close-up prints. Coloured modules reduce contrast; black on white is the safe choice for print.
