Spaces:
Starting
Starting
Update app.py
Browse files
app.py
CHANGED
@@ -378,9 +378,6 @@ def draw_mask(l, c, t, v, d, evt: gr.EventData):
|
|
378 |
pts = np.array(points, np.int32)
|
379 |
pts = pts.reshape((-1,1,2))
|
380 |
|
381 |
-
x = points[len(points)-1][0]
|
382 |
-
y = points[len(points)-1][1]
|
383 |
-
|
384 |
scale = 1
|
385 |
delta = 0
|
386 |
ddepth = cv2.CV_16S
|
@@ -419,12 +416,15 @@ def draw_mask(l, c, t, v, d, evt: gr.EventData):
|
|
419 |
params["l"] = l
|
420 |
params["c"] = c
|
421 |
|
422 |
-
|
423 |
edge = bg.copy()
|
424 |
else:
|
425 |
bg = edge.copy()
|
|
|
|
|
|
|
426 |
|
427 |
-
mask = cv2.floodFill(bg, None, (x, y), 1,
|
428 |
# 255 << 8 tells to fill with the value 255)
|
429 |
mask = mask[1:mask.shape[0]-1, 1:mask.shape[1]-1]
|
430 |
|
@@ -536,6 +536,7 @@ with gr.Blocks(css=css) as demo:
|
|
536 |
for (var i=0; i<256; i++) {
|
537 |
pts += i+\",0 \";
|
538 |
}
|
|
|
539 |
document.getElementById(\"pl\").setAttribute(\"points\", pts.slice(0,-1));
|
540 |
var xold = 0;
|
541 |
var yold = 0;
|
|
|
378 |
pts = np.array(points, np.int32)
|
379 |
pts = pts.reshape((-1,1,2))
|
380 |
|
|
|
|
|
|
|
381 |
scale = 1
|
382 |
delta = 0
|
383 |
ddepth = cv2.CV_16S
|
|
|
416 |
params["l"] = l
|
417 |
params["c"] = c
|
418 |
|
419 |
+
d["layers"][0] = cv2.cvtColor(bg, cv2.COLOR_GRAY2RGBA)
|
420 |
edge = bg.copy()
|
421 |
else:
|
422 |
bg = edge.copy()
|
423 |
+
|
424 |
+
x = points[len(points)-1][0]
|
425 |
+
y = points[len(points)-1][1]
|
426 |
|
427 |
+
mask = cv2.floodFill(bg, None, (x, y), 1, 0, 0)[2] #, (4 | cv2.FLOODFILL_FIXED_RANGE | cv2.FLOODFILL_MASK_ONLY | 255 << 8)
|
428 |
# 255 << 8 tells to fill with the value 255)
|
429 |
mask = mask[1:mask.shape[0]-1, 1:mask.shape[1]-1]
|
430 |
|
|
|
536 |
for (var i=0; i<256; i++) {
|
537 |
pts += i+\",0 \";
|
538 |
}
|
539 |
+
alert(points);
|
540 |
document.getElementById(\"pl\").setAttribute(\"points\", pts.slice(0,-1));
|
541 |
var xold = 0;
|
542 |
var yold = 0;
|