Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,4 +13,27 @@ import extcolors
|
|
| 13 |
import cv2
|
| 14 |
import numpy as np
|
| 15 |
import fitz
|
| 16 |
-
import pypdfium2 as pdfium
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
import cv2
|
| 14 |
import numpy as np
|
| 15 |
import fitz
|
| 16 |
+
import pypdfium2 as pdfium
|
| 17 |
+
|
| 18 |
+
def mouse_callback(event, x, y, flags, param):
|
| 19 |
+
if event == cv2.EVENT_LBUTTONDOWN:
|
| 20 |
+
print("Left button down at ({}, {})".format(x, y))
|
| 21 |
+
elif event == cv2.EVENT_RBUTTONDOWN:
|
| 22 |
+
print("Right button down at ({}, {})".format(x, y))
|
| 23 |
+
|
| 24 |
+
# Create a function to handle user input
|
| 25 |
+
def handle_image(image):
|
| 26 |
+
# Display the image
|
| 27 |
+
cv2_imshow(image)
|
| 28 |
+
|
| 29 |
+
# Set the mouse callback
|
| 30 |
+
cv2.setMouseCallback("output", mouse_callback)
|
| 31 |
+
|
| 32 |
+
# Wait for the user to click on the image
|
| 33 |
+
cv2.waitKey(0)
|
| 34 |
+
|
| 35 |
+
# Create a Gradio interface
|
| 36 |
+
iface = gr.Interface(fn=handle_image, inputs="image", outputs=None)
|
| 37 |
+
|
| 38 |
+
# Launch the interface
|
| 39 |
+
iface.launch()
|