Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,16 +7,17 @@ import cv2
|
|
| 7 |
|
| 8 |
def decode(im,col,tol):
|
| 9 |
img = cv2.imread(f'{im}')
|
|
|
|
| 10 |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 11 |
blur = cv2.medianBlur(gray, 5)
|
| 12 |
sharpen_kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
|
| 13 |
sharpen = cv2.filter2D(blur, -1, sharpen_kernel)
|
| 14 |
-
|
| 15 |
|
| 16 |
|
| 17 |
try:
|
| 18 |
-
results = zxingcpp.read_barcodes(
|
| 19 |
-
return results[0].text
|
| 20 |
except Exception:
|
| 21 |
|
| 22 |
#qr_img=Image.open(im).convert("RGBA")
|
|
@@ -36,9 +37,9 @@ def decode(im,col,tol):
|
|
| 36 |
try:
|
| 37 |
results = zxingcpp.read_barcodes(img)
|
| 38 |
print (results[0].text)
|
| 39 |
-
return results[0].text
|
| 40 |
except Exception:
|
| 41 |
-
return "QR Code not Detected \nTry choosing the QR code color using the eyedropper in the Color Picker"
|
| 42 |
|
| 43 |
|
| 44 |
|
|
@@ -46,7 +47,7 @@ with gr.Blocks() as app:
|
|
| 46 |
with gr.Row():
|
| 47 |
with gr.Column():
|
| 48 |
in_im = gr.Image(label="QR Image to Decode",type='filepath')
|
| 49 |
-
out_im = gr.Image(type='filepath')
|
| 50 |
with gr.Column():
|
| 51 |
with gr.Row():
|
| 52 |
choose_color = gr.ColorPicker(label="Choose QR color (eyedropper)")
|
|
@@ -54,5 +55,5 @@ with gr.Blocks() as app:
|
|
| 54 |
dec_btn = gr.Button("Decode QR")
|
| 55 |
text_out = gr.Textbox(label="Decoded Text")
|
| 56 |
|
| 57 |
-
dec_btn.click(decode,[in_im,choose_color,color_tol],[text_out
|
| 58 |
app.queue(concurrency_count=10).launch()
|
|
|
|
| 7 |
|
| 8 |
def decode(im,col,tol):
|
| 9 |
img = cv2.imread(f'{im}')
|
| 10 |
+
'''
|
| 11 |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 12 |
blur = cv2.medianBlur(gray, 5)
|
| 13 |
sharpen_kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
|
| 14 |
sharpen = cv2.filter2D(blur, -1, sharpen_kernel)
|
| 15 |
+
'''
|
| 16 |
|
| 17 |
|
| 18 |
try:
|
| 19 |
+
results = zxingcpp.read_barcodes(img)
|
| 20 |
+
return results[0].text
|
| 21 |
except Exception:
|
| 22 |
|
| 23 |
#qr_img=Image.open(im).convert("RGBA")
|
|
|
|
| 37 |
try:
|
| 38 |
results = zxingcpp.read_barcodes(img)
|
| 39 |
print (results[0].text)
|
| 40 |
+
return results[0].text
|
| 41 |
except Exception:
|
| 42 |
+
return "QR Code not Detected \nTry choosing the QR code color using the eyedropper in the Color Picker"
|
| 43 |
|
| 44 |
|
| 45 |
|
|
|
|
| 47 |
with gr.Row():
|
| 48 |
with gr.Column():
|
| 49 |
in_im = gr.Image(label="QR Image to Decode",type='filepath')
|
| 50 |
+
#out_im = gr.Image(type='filepath')
|
| 51 |
with gr.Column():
|
| 52 |
with gr.Row():
|
| 53 |
choose_color = gr.ColorPicker(label="Choose QR color (eyedropper)")
|
|
|
|
| 55 |
dec_btn = gr.Button("Decode QR")
|
| 56 |
text_out = gr.Textbox(label="Decoded Text")
|
| 57 |
|
| 58 |
+
dec_btn.click(decode,[in_im,choose_color,color_tol],[text_out])
|
| 59 |
app.queue(concurrency_count=10).launch()
|