Skip to main content
. Author manuscript; available in PMC: 2020 Mar 1.
Published in final edited form as: IEEE Trans Mob Comput. 2018 Jun 1;18(3):702–714. doi: 10.1109/TMC.2018.2842751

Algorithm 2.

Obstacle detection based on connected component labeling approach

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: LG 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