I am trying to create QR code for the image , the result should be, after scanning the QR it should display image. The error message in QR generation is : Invalid version (was 41, expected 1 to 40)
the code is below, can anyone help to find the error in my code
the code is below, can anyone help to find the error in my code
import cv2
import numpy as np
import qrcode
import zlib
import base64
#Read The Image
img=cv2.imread("photo.jpg")
#encode the image to Numpy Array
_,imgencoded=cv2.imencode(".jpg",img,[cv2.IMWRITE_JPEG_QUALITY, 20] )
#Convert to bytecode
imgbc=imgencoded.tobytes()
# Compress the data
compressed_data = zlib.compress(imgbc)
# Encode compressed data as Base64
base64_data = base64.b64encode(compressed_data).decode('ascii')
#Generate QR code
qr=qrcode.QRCode(
version=None,
error_correction=qrcode.constants.ERROR_CORRECT_Q,
box_size=20,
border=4,
)
qr.add_data(base64_data)
qr.make(fit=True)
# Specify the filename and path where you want to save the QR code image
qr_image_path = 'E:/photo2.png'
# Create an image from the QR Code instance
qr_image = qr.make_image(fill='black', back_color='white')
# Save the QR code image
qr_image.save(qr_image_path)
print(f"QR Code image saved to {qr_image_path}")
Larz60+ write Jan-15-2025, 11:15 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Tags added this time. Please user BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Tags added this time. Please user BBCode tags on future posts.
