acecalisto3 commited on
Commit
14b5221
·
verified ·
1 Parent(s): 46c1159

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +9 -16
app2.py CHANGED
@@ -5,10 +5,8 @@ import logging
5
  import mimetypes
6
  import time
7
  from PIL import Image
8
- import zbar
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 decode_qr_code(image_path: str) -> str:
357
- """Decode QR code from an image file and return resolution."""
358
- try:
359
- img = Image.open(image_path)
360
- decoded_objects = decode(img)
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: