Exemplo n.º 1
0
def create_qr(data,
              gradient_pos=(0.5, 0.5),
              from_hex_color='#000000',
              to_hex_color='#000000'):
    qr = qrcode.QRCode(version=7, box_size=10, border=4)
    qr.add_data(data)
    qr.make(fit=True)
    return make_image(qr.modules,
                      gradient_pos=gradient_pos,
                      from_color=hex2rgb(from_hex_color),
                      to_color=hex2rgb(to_hex_color))
Exemplo n.º 2
0
def save_label(label, path):
    '''
    Function for ploting labels.
    '''
    colormap = [
        '#000000',
        '#0080FF',
        '#80FF80',
        '#FF8000',
        '#FF0000',
    ]
    assert (np.max(label) < len(colormap))
    colors = [hex2rgb(color, normalise=False) for color in colormap]
    w = png.Writer(label.shape[1], label.shape[0], palette=colors, bitdepth=4)
    with open(path, 'wb') as f:
        w.write(f, label)