Nodes/comfyui_cv/CV QR Encode
ComfyUI Node

CV QR Encode

Generates a QR code from text with cv2.QRCodeEncoder (OpenCV's own encoder - no model files, no extra dependency). The output is a black-and-white IMAGE whose modules are 'module_size' pixels wide, upscaled with nearest-neighbour so the code stays crisp and scannable. OpenCV frames the symbol with only TWO quiet-zone modules where the spec asks for four, so 'quiet_zone' adds the missing white margin (default 2 = spec-compliant). 'version' fixes the symbol size (1 = 21x21 modules ... 40 = 177x177) - leave it at 0 to let OpenCV pick the smallest version that fits the payload at the chosen error-correction level. Set 'structure_number' above 1 to split a long message over that many codes in Structured Append mode: the output is then an IMAGE BATCH of the parts (white-padded to a common size) which 'CV QR Detect' reassembles into the full message when they are all visible in one image.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV QR Encode
    • qr_image
    • modules
    • version
    texthttps://opencv.org
    error_correctionM (~15% recovery)
    modeauto (pick the densest that fits)
    version0
    module_size8
    quiet_zone2
    structure_number1
    Categoryimage/CV/codes

    Inputs (7)

    NameTypeDefaultDescription
    textSTRINGhttps://opencv.orgPayload to encode. Must be representable in the chosen 'mode' (numeric = digits only, alphanumeric = 0-9 A-Z and $%*+-./: and space) and must fit the chosen version - otherwise the node reports the OpenCV error instead of writing a corrupt code.
    error_correctionCOMBOM (~15% recovery)Reed-Solomon error-correction level: how much of the code may be damaged/occluded and still decode. Higher levels leave less room for data (the symbol grows) but survive print wear, glare and logos pasted over the centre.
    modeCOMBOauto (pick the densest that fits)Payload encoding. 'auto' lets OpenCV choose the densest mode the text fits. numeric/alphanumeric pack more characters per module but restrict the alphabet; byte carries arbitrary bytes; ECI (UTF-8) tags the payload as UTF-8 for non-Latin text; kanji packs Shift-JIS.
    versionINT00–40Symbol version = size in modules (v = 21 + 4*(v-1) modules square). 0 = auto: the smallest version that fits. A fixed version keeps a set of codes the same physical size; too small for the payload is an error.
    module_sizeINT81–64Pixels per QR module in the output image (nearest-neighbour upscale). 1 = the raw bitmap (one pixel per module) - too small for most scanners; 6-12 is a good print/screen size.
    quiet_zoneINT20–16EXTRA white border in modules, added around the TWO quiet-zone modules OpenCV emits. The QR spec asks for four, so 2 (the default) is the spec-compliant margin; raise it when the code is composited onto a busy background.
    structure_numberINT11–16Structured Append: number of codes the message is split over (1 = a single code). The parts decode into one message only when a decoder sees all of them; 'CV QR Detect' writes the joined message on the first part.

    Outputs (3)

    NameTypeDescription
    qr_imageIMAGEThe QR code as an IMAGE (white background, black modules, 3 identical channels). A batch of 'structure_number' frames in Structured Append mode.
    modulesINTSide length of the encoder's bitmap in modules, its 2-module quiet zone included and the extra 'quiet_zone' excluded (version 1 = 25).
    versionINTQR version actually used (1-40), i.e. what 'auto' resolved to. 0 if the size is not a valid version.