CultriX commited on
Commit
8102829
·
verified ·
1 Parent(s): aaf08f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import qrcode
2
- from pyzbar.pyzbar import decode
3
  from PIL import Image
4
  import gradio as gr
5
  import tempfile
@@ -23,13 +23,11 @@ def generate_qr(data):
23
  temp_file.close() # Close the file to flush contents to disk
24
  return temp_file.name
25
 
26
- # Function to read a QR code from an uploaded image
27
- def read_qr(img):
28
- decoded_data = decode(img)
29
- if decoded_data:
30
- return decoded_data[0].data.decode("utf-8")
31
- else:
32
- return "No QR code found."
33
 
34
  # Custom CSS styling as HTML for dark mode
35
  custom_css = """
 
1
  import qrcode
2
+ import cv2
3
  from PIL import Image
4
  import gradio as gr
5
  import tempfile
 
23
  temp_file.close() # Close the file to flush contents to disk
24
  return temp_file.name
25
 
26
+ # Function to read a QR code using OpenCV
27
+ def read_qr_with_opencv(img):
28
+ detector = cv2.QRCodeDetector()
29
+ data, _, _ = detector.detectAndDecode(img)
30
+ return data if data else "No QR code found."
 
 
31
 
32
  # Custom CSS styling as HTML for dark mode
33
  custom_css = """