Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,28 +10,26 @@ def decode(im):
|
|
| 10 |
results = zxingcpp.read_barcodes(img)
|
| 11 |
return results[0].text
|
| 12 |
except Exception:
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
except Exception:
|
| 34 |
-
return "QR Code not Detected \nTry using 'Detect by Color'"
|
| 35 |
|
| 36 |
|
| 37 |
|
|
|
|
| 10 |
results = zxingcpp.read_barcodes(img)
|
| 11 |
return results[0].text
|
| 12 |
except Exception:
|
| 13 |
+
|
| 14 |
+
#qr_img=Image.open(im).convert("RGBA")
|
| 15 |
+
qr_img=Image.open(im)
|
| 16 |
+
datas = qr_img.getdata()
|
| 17 |
+
newData = []
|
| 18 |
+
h1 = col.strip("#")
|
| 19 |
+
rgb_tup = tuple(int(h1[i:i+2], 16) for i in (0, 2, 4))
|
| 20 |
+
for item in datas:
|
| 21 |
+
if item[0] == rgb_tup[0] and item[1] == rgb_tup[1] and item[2] == rgb_tup[2]:
|
| 22 |
+
newData.append((0,0,0))
|
| 23 |
+
else:
|
| 24 |
+
newData.append(255,255,255)
|
| 25 |
+
qr_img.putdata(newData)
|
| 26 |
+
qr_img.save(f'conv_im.png')
|
| 27 |
+
img = cv2.imread('conv_im.png')
|
| 28 |
+
try:
|
| 29 |
+
results = zxingcpp.read_barcodes(img)
|
| 30 |
+
return results[0].text
|
| 31 |
+
except Exception:
|
| 32 |
+
return "QR Code not Detected \nTry choosing the QR code color using the eyedropper in the Color Picker"
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
|