Omnibus commited on
Commit
ea00ccb
1 Parent(s): 704d03b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -22
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
- return "QR Code not Detected \nTry using 'Detect by Color'"
14
-
15
- def detect_color(im,col):
16
- #qr_img=Image.open(im).convert("RGBA")
17
- qr_img=Image.open(im)
18
- datas = qr_img.getdata()
19
- newData = []
20
- h1 = col.strip("#")
21
- rgb_tup = tuple(int(h1[i:i+2], 16) for i in (0, 2, 4))
22
- for item in datas:
23
- if item[0] == rgb_tup[0] and item[1] == rgb_tup[1] and item[2] == rgb_tup[2]:
24
- newData.append((0,0,0))
25
- else:
26
- newData.append(255,255,255)
27
- qr_img.putdata(newData)
28
- qr_img.save(f'conv_im.png')
29
- img = cv2.imread('conv_im.png')
30
- try:
31
- results = zxingcpp.read_barcodes(img)
32
- return results[0].text
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