Spaces:
Runtime error
Runtime error
File size: 1,103 Bytes
55f9eaa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import numpy as np
import cv2
import glob
import gradio as gr
def shi_tomasi(image, max_corners=100, min_quality=0.01, min_dist=10):
gray_img = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
corners_img = cv2.goodFeaturesToTrack(gray_img,max_corners, min_quality, min_dist)
corners_img = np.int0(corners_img)
for corners in corners_img:
x,y = corners.ravel()
cv2.circle(image,(x,y),3,[0,255,0],-1)
return image
demo = gr.Interface(
shi_tomasi,
inputs=[gr.inputs.Image(type="numpy"),
gr.Slider(0, 2000, value=100, step=1, label='Maximum Number of Corners'),
gr.Slider(0.01, 0.99, value=0.01, step=0.01, label='Minimum Corner Quality'),
gr.Slider(0, 100, value=10, step=1, label='Minumum Euclidean Distance Between Corners'),
],
outputs=gr.outputs.Image(type="numpy"),
title="Corner Detection",
description="Shi-Tomasi Corner Detection",
examples=list(map(lambda x: [x, 100, 0.01, 10], glob.glob('./examples/*.jpg'))),
allow_flagging="never",
)
if __name__ == "__main__":
demo.launch()
|