mouse_click / app.py
Marthee's picture
Update app.py
c30a851
raw
history blame contribute delete
924 Bytes
import gradio as gr
import os
from colormap import rgb2hex
import pandas as pd
from flask import Flask, request, render_template_string
import math
import statistics
from statistics import mode
from PIL import Image
import extcolors
import cv2
import numpy as np
import fitz
import pypdfium2 as pdfium
def mouse_callback(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN:
print("Left button down at ({}, {})".format(x, y))
elif event == cv2.EVENT_RBUTTONDOWN:
print("Right button down at ({}, {})".format(x, y))
# Create a function to handle user input
def handle_image(image):
# Display the image
cv2.imshow("Image", image)
cv2.setMouseCallback("Image", mouse_callback)
cv2.waitKey(0)
cv2.destroyAllWindows()
# Define the Gradio interface without inputs
iface = gr.Interface(fn=handle_image, inputs=None, outputs="image")
# Launch the interface
iface.launch()