Skip to content

Commit 0973452

Browse files
committed
Updated fov_estimator for filtering out isolated points
1 parent 4d7bac4 commit 0973452

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

avstack/modules/perception/fov_estimator.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from avstack.geometry import GlobalOrigin3D, Polygon
1313
from avstack.modules import BaseModule
1414
from avstack.utils.decorators import apply_hooks
15+
from collections import defaultdict
16+
1517

1618

1719
class _LidarFovEstimator(BaseModule):
@@ -97,6 +99,8 @@ def __call__(
9799
z_min=self.z_min,
98100
z_max=self.z_max,
99101
)
102+
103+
self._eliminate_isolated_pts(pc_bev, 10, 30)
100104

101105
# center the lidar data
102106
if centering:
@@ -152,6 +156,24 @@ def _estimate_fov_from_polar_lidar(
152156
) -> "Polygon":
153157
"""To be implemented in subclass"""
154158
raise NotImplementedError
159+
160+
def _eliminate_isolated_pts(self, pc_bev, m_away, num_pts):
161+
ptMap = defaultdict(int)
162+
usable_pts = []
163+
for p1 in pc_bev.data.x:
164+
p1x, p1y = p1[0], p1[1]
165+
for p2 in pc_bev.data.x:
166+
p2x, p2y = p2[0], p2[1]
167+
if p1x == p2x and p1y == p2y:
168+
continue
169+
dis = np.linalg.norm([p1x - p2x, p1y - p2y])
170+
if (dis < m_away):
171+
ptMap[(p1x, p1y)] += 1
172+
if (ptMap[(p1x, p1y)] == num_pts):
173+
usable_pts.append([p1x, p1y])
174+
break
175+
usable_pts = np.array(usable_pts)
176+
pc_bev.data.x = usable_pts
155177

156178

157179
@MODELS.register_module()

0 commit comments

Comments
 (0)