raviix46 commited on
Commit
89a1d3e
·
verified ·
1 Parent(s): 948009d

Update tab/tab1to3_unified.py

Browse files
Files changed (1) hide show
  1. tab/tab1to3_unified.py +5 -6
tab/tab1to3_unified.py CHANGED
@@ -48,17 +48,16 @@ def generate_qr_image(data):
48
  # ---------------- QR Code Decoder ----------------
49
  def decode_qr_image(pil_img):
50
  img = cv2.cvtColor(np.array(pil_img), cv2.COLOR_RGB2BGR)
51
- decoded = decode(img)
52
- if decoded:
53
- content = decoded[0].data.decode("utf-8")
54
- lines = content.splitlines()
55
  key_line = next((line for line in lines if line.startswith("Key: ")), None)
56
  msg_line = next((line for line in lines if line.startswith("Message: ")), None)
57
  key = key_line.replace("Key: ", "") if key_line else ""
58
  msg = msg_line.replace("Message: ", "") if msg_line else ""
59
  return msg, key
60
- else:
61
- return "", ""
62
 
63
  # ---------------- Encryption ----------------
64
  def quantum_encrypt(message, qkd_key):
 
48
  # ---------------- QR Code Decoder ----------------
49
  def decode_qr_image(pil_img):
50
  img = cv2.cvtColor(np.array(pil_img), cv2.COLOR_RGB2BGR)
51
+ detector = cv2.QRCodeDetector()
52
+ data, _, _ = detector.detectAndDecode(img)
53
+ if data:
54
+ lines = data.splitlines()
55
  key_line = next((line for line in lines if line.startswith("Key: ")), None)
56
  msg_line = next((line for line in lines if line.startswith("Message: ")), None)
57
  key = key_line.replace("Key: ", "") if key_line else ""
58
  msg = msg_line.replace("Message: ", "") if msg_line else ""
59
  return msg, key
60
+ return "", ""
 
61
 
62
  # ---------------- Encryption ----------------
63
  def quantum_encrypt(message, qkd_key):