Commit
·
8e7b586
1
Parent(s):
74fa88b
KNN on water_mask
Browse files
app.py
CHANGED
@@ -479,7 +479,7 @@ def _pipeline(uid,img_path):
|
|
479 |
x1, y1, x2, y2 = map(int, [x1, y1, x2, y2])
|
480 |
x1 = max(0, min(x1, 639)); y1 = max(0, min(y1, 639))
|
481 |
x2 = max(0, min(x2, 639)); y2 = max(0, min(y2, 639))
|
482 |
-
box_mask = movable_mask[y1:y2, x1:x2] # ←
|
483 |
if box_mask.size == 0:
|
484 |
continue
|
485 |
if np.count_nonzero(box_mask) / box_mask.size >= 0.2:
|
@@ -493,7 +493,7 @@ def _pipeline(uid,img_path):
|
|
493 |
print(f"🧠 {len(centres)} garbage objects on water selected from {len(detections)} detections")
|
494 |
|
495 |
# 3- Robot initialization, position and navigation
|
496 |
-
# find all (y,x) within
|
497 |
ys, xs = np.where(water_mask)
|
498 |
if len(ys)==0:
|
499 |
# no travelable zone → bail out
|
@@ -509,7 +509,7 @@ def _pipeline(uid,img_path):
|
|
509 |
robot = Robot(SPRITE)
|
510 |
# Robot will be spawn on the closest movable mask to top-left
|
511 |
robot.pos = [spawn_x, spawn_y]
|
512 |
-
path = knn_path(robot.pos, centres,
|
513 |
|
514 |
# 4- Video synthesis
|
515 |
out_tmp=f"{OUTPUT_DIR}/{uid}_tmp.mp4"
|
|
|
479 |
x1, y1, x2, y2 = map(int, [x1, y1, x2, y2])
|
480 |
x1 = max(0, min(x1, 639)); y1 = max(0, min(y1, 639))
|
481 |
x2 = max(0, min(x2, 639)); y2 = max(0, min(y2, 639))
|
482 |
+
box_mask = movable_mask[y1:y2, x1:x2] # ← switch to movable_mask
|
483 |
if box_mask.size == 0:
|
484 |
continue
|
485 |
if np.count_nonzero(box_mask) / box_mask.size >= 0.2:
|
|
|
493 |
print(f"🧠 {len(centres)} garbage objects on water selected from {len(detections)} detections")
|
494 |
|
495 |
# 3- Robot initialization, position and navigation
|
496 |
+
# find all (y,x) within water-zone
|
497 |
ys, xs = np.where(water_mask)
|
498 |
if len(ys)==0:
|
499 |
# no travelable zone → bail out
|
|
|
509 |
robot = Robot(SPRITE)
|
510 |
# Robot will be spawn on the closest movable mask to top-left
|
511 |
robot.pos = [spawn_x, spawn_y]
|
512 |
+
path = knn_path(robot.pos, centres, water_mask)
|
513 |
|
514 |
# 4- Video synthesis
|
515 |
out_tmp=f"{OUTPUT_DIR}/{uid}_tmp.mp4"
|