|
Input: |
|
G: horizontal or vertical occupancy map |
|
b: background value |
|
Output: |
|
obL: obstacle bounding box (position, size: [px, py, sx, sy]) list |
1: |
procedure Obstacle Detection(G,b) |
2: |
L ← G
|
▹ initialization: Label |
3: |
(W,H) ← L.size() |
▹ initialization: Width, Height |
4: |
childList, labelSet, label
←
empty
|
5: |
for
w, h in W, H
do
|
▹ label it |
6: |
if
L(w, h) ! = b
then
|
7: |
update label
|
8: |
L(w, h) ← label
|
9: |
append L(w, h) to childList if its top/left exists
|
10: |
for
w, h in W, H
do
|
▹ label updating |
11: |
if
L(w, h) ! = b
then
|
12: |
if
L(w, h) in childList
then
|
13: |
update it as its father
|
14: |
else
|
15: |
add it in labelSet
|
16: |
for
label in labelSet
do
|
▹ get result |
17: |
ob ← bounding_box(label)
|
|
18: |
append ob to obL
|
|
19: |
return
obL
|
|