Update app.py
Browse files
app.py
CHANGED
@@ -592,10 +592,6 @@ def draw_mask(l, t, b, v, d, evt: gr.EventData):
|
|
592 |
|
593 |
params["fnum"] = frame_selected
|
594 |
params["l"] = l
|
595 |
-
|
596 |
-
mask = cv2.imread(masks[frame_selected], cv2.IMREAD_GRAYSCALE).astype(np.uint8) + 128
|
597 |
-
mask[mask==128] = 0
|
598 |
-
d["layers"][0] = cv2.cvtColor(mask, cv2.COLOR_GRAY2RGBA)
|
599 |
|
600 |
edge = bg.copy()
|
601 |
else:
|
@@ -604,6 +600,10 @@ def draw_mask(l, t, b, v, d, evt: gr.EventData):
|
|
604 |
x = points[len(points)-1][0]
|
605 |
y = points[len(points)-1][1]
|
606 |
|
|
|
|
|
|
|
|
|
607 |
sel = cv2.floodFill(mask, None, (x, y), 1, 2, 2, (4 | cv2.FLOODFILL_FIXED_RANGE))[2] #(4 | cv2.FLOODFILL_FIXED_RANGE | cv2.FLOODFILL_MASK_ONLY | 255 << 8)
|
608 |
# 255 << 8 tells to fill with the value 255)
|
609 |
sel = sel[1:sel.shape[0]-1, 1:sel.shape[1]-1]
|
|
|
592 |
|
593 |
params["fnum"] = frame_selected
|
594 |
params["l"] = l
|
|
|
|
|
|
|
|
|
595 |
|
596 |
edge = bg.copy()
|
597 |
else:
|
|
|
600 |
x = points[len(points)-1][0]
|
601 |
y = points[len(points)-1][1]
|
602 |
|
603 |
+
mask = cv2.imread(masks[frame_selected], cv2.IMREAD_GRAYSCALE).astype(np.uint8) + 128
|
604 |
+
mask[mask==128] = 0
|
605 |
+
d["layers"][0] = cv2.cvtColor(mask, cv2.COLOR_GRAY2RGBA)
|
606 |
+
|
607 |
sel = cv2.floodFill(mask, None, (x, y), 1, 2, 2, (4 | cv2.FLOODFILL_FIXED_RANGE))[2] #(4 | cv2.FLOODFILL_FIXED_RANGE | cv2.FLOODFILL_MASK_ONLY | 255 << 8)
|
608 |
# 255 << 8 tells to fill with the value 255)
|
609 |
sel = sel[1:sel.shape[0]-1, 1:sel.shape[1]-1]
|