Update app.py
Browse files
app.py
CHANGED
@@ -549,7 +549,7 @@ def apply_mask(d, b):
|
|
549 |
cv2.imwrite(masks[frame_selected], mask) #d["background"]
|
550 |
return masks[frame_selected], depths, frames
|
551 |
|
552 |
-
def draw_mask(l, t,
|
553 |
global frames
|
554 |
global depths
|
555 |
global params
|
@@ -565,7 +565,7 @@ def draw_mask(l, t, th, v, d, evt: gr.EventData):
|
|
565 |
|
566 |
if len(edge) == 0 or params["fnum"] != frame_selected or params["l"] != l:
|
567 |
clrs = cv2.cvtColor(cv2.imread(frames[frame_selected]).astype(np.uint8), cv2.COLOR_BGR2HSV)
|
568 |
-
clrs = cv2.medianBlur(clrs,
|
569 |
if len(edge) > 0:
|
570 |
d["background"] = cv2.imread(depths[frame_selected]).astype(np.uint8)
|
571 |
|
@@ -978,9 +978,8 @@ with gr.Blocks(css=css, js=js) as demo:
|
|
978 |
levels = gr.Slider(label="Color levels", value=16, maximum=32, minimum=2, step=1)
|
979 |
tolerance = gr.Slider(label="Tolerance", value=1, maximum=7, minimum=0, step=1)
|
980 |
bsize = gr.Slider(label="Border size", value=15, maximum=256, minimum=1, step=2)
|
981 |
-
threshold = gr.Slider(label="Threshold", value=12, maximum=128, minimum=0, step=1)
|
982 |
mouse = gr.Textbox(elem_id="mouse", value="""[]""", interactive=False)
|
983 |
-
mouse.input(fn=draw_mask, show_progress="minimal", inputs=[levels, tolerance,
|
984 |
apply.click(fn=apply_mask, inputs=[output_mask, bsize], outputs=[output_mask, output_depth, output_frame])
|
985 |
reset.click(fn=reset_mask, inputs=None, outputs=[output_mask, output_depth])
|
986 |
|
|
|
549 |
cv2.imwrite(masks[frame_selected], mask) #d["background"]
|
550 |
return masks[frame_selected], depths, frames
|
551 |
|
552 |
+
def draw_mask(l, t, b, v, d, evt: gr.EventData):
|
553 |
global frames
|
554 |
global depths
|
555 |
global params
|
|
|
565 |
|
566 |
if len(edge) == 0 or params["fnum"] != frame_selected or params["l"] != l:
|
567 |
clrs = cv2.cvtColor(cv2.imread(frames[frame_selected]).astype(np.uint8), cv2.COLOR_BGR2HSV)
|
568 |
+
clrs = cv2.medianBlur(clrs, b)
|
569 |
if len(edge) > 0:
|
570 |
d["background"] = cv2.imread(depths[frame_selected]).astype(np.uint8)
|
571 |
|
|
|
978 |
levels = gr.Slider(label="Color levels", value=16, maximum=32, minimum=2, step=1)
|
979 |
tolerance = gr.Slider(label="Tolerance", value=1, maximum=7, minimum=0, step=1)
|
980 |
bsize = gr.Slider(label="Border size", value=15, maximum=256, minimum=1, step=2)
|
|
|
981 |
mouse = gr.Textbox(elem_id="mouse", value="""[]""", interactive=False)
|
982 |
+
mouse.input(fn=draw_mask, show_progress="minimal", inputs=[levels, tolerance, bsize, mouse, output_mask], outputs=[output_mask])
|
983 |
apply.click(fn=apply_mask, inputs=[output_mask, bsize], outputs=[output_mask, output_depth, output_frame])
|
984 |
reset.click(fn=reset_mask, inputs=None, outputs=[output_mask, output_depth])
|
985 |
|