Spaces:
Running
Running
Update app2.py
Browse files
app2.py
CHANGED
@@ -5,10 +5,8 @@ import logging
|
|
5 |
import mimetypes
|
6 |
import time
|
7 |
from PIL import Image
|
8 |
-
import
|
9 |
-
from pyzbar import scripts
|
10 |
import io
|
11 |
-
from selenium import webdriver
|
12 |
from selenium.webdriver.common.by import By
|
13 |
import concurrent.futures
|
14 |
import string
|
@@ -31,6 +29,8 @@ import nest_asyncio
|
|
31 |
nest_asyncio.apply()
|
32 |
import aiohttp
|
33 |
|
|
|
|
|
34 |
# Setup logging
|
35 |
logging.basicConfig(
|
36 |
level=logging.INFO,
|
@@ -353,19 +353,12 @@ def generate_qr_code(data: Union[str, Dict], combined: bool = True) -> List[str]
|
|
353 |
logger.error(f"QR generation error: {e}")
|
354 |
return []
|
355 |
|
356 |
-
def
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
# Get image resolution
|
363 |
-
width, height = img.size
|
364 |
-
|
365 |
-
if decoded_objects:
|
366 |
-
decoded_data = decoded_objects[0].data.decode('utf-8')
|
367 |
-
logger.info(f"Decoded QR code data: {decoded_data} (Resolution: {width}x{height})")
|
368 |
-
return decoded_data, (width, height) # Return both data and resolution
|
369 |
|
370 |
raise ValueError("Unable to decode QR code")
|
371 |
except Exception as e:
|
|
|
5 |
import mimetypes
|
6 |
import time
|
7 |
from PIL import Image
|
8 |
+
from pyzbar.pyzbar import decode
|
|
|
9 |
import io
|
|
|
10 |
from selenium.webdriver.common.by import By
|
11 |
import concurrent.futures
|
12 |
import string
|
|
|
29 |
nest_asyncio.apply()
|
30 |
import aiohttp
|
31 |
|
32 |
+
|
33 |
+
|
34 |
# Setup logging
|
35 |
logging.basicConfig(
|
36 |
level=logging.INFO,
|
|
|
353 |
logger.error(f"QR generation error: {e}")
|
354 |
return []
|
355 |
|
356 |
+
def decode_qr(image):
|
357 |
+
decoded_objects = decode(image)
|
358 |
+
results = []
|
359 |
+
for obj in decoded_objects:
|
360 |
+
results.append(obj.data.decode('utf-8'))
|
361 |
+
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
raise ValueError("Unable to decode QR code")
|
364 |
except Exception as e:
|