Parse and filter point cloud data.
(
self,
pc,
color,
conf=None,
edge_color=[0.251, 0.702, 0.902],
set_border_color=False,
downsample_factor=1,
)
| 1050 | return pcs, step_list |
| 1051 | |
| 1052 | def parse_pc_data( |
| 1053 | self, |
| 1054 | pc, |
| 1055 | color, |
| 1056 | conf=None, |
| 1057 | edge_color=[0.251, 0.702, 0.902], |
| 1058 | set_border_color=False, |
| 1059 | downsample_factor=1, |
| 1060 | ): |
| 1061 | """Parse and filter point cloud data.""" |
| 1062 | pred_pts = pc.reshape(-1, 3) |
| 1063 | |
| 1064 | if set_border_color and edge_color is not None: |
| 1065 | color = self.set_color_border(color[0], color=edge_color) |
| 1066 | if np.isnan(color).any(): |
| 1067 | color = np.zeros((pred_pts.shape[0], 3)) |
| 1068 | color[:, 2] = 1 |
| 1069 | else: |
| 1070 | color = color.reshape(-1, 3) |
| 1071 | |
| 1072 | # Remove NaN / Inf points |
| 1073 | valid = np.isfinite(pred_pts).all(axis=1) |
| 1074 | if not valid.all(): |
| 1075 | pred_pts = pred_pts[valid] |
| 1076 | color = color[valid] |
| 1077 | if conf is not None: |
| 1078 | conf = conf.reshape(-1)[valid] |
| 1079 | |
| 1080 | # Confidence threshold filter |
| 1081 | if conf is not None: |
| 1082 | conf_flat = conf.reshape(-1) if conf.ndim > 1 else conf |
| 1083 | mask = conf_flat > self.vis_threshold |
| 1084 | pred_pts = pred_pts[mask] |
| 1085 | color = color[mask] |
| 1086 | |
| 1087 | if len(pred_pts) == 0: |
| 1088 | return pred_pts, color |
| 1089 | |
| 1090 | # Downsample |
| 1091 | if downsample_factor > 1 and len(pred_pts) > 0: |
| 1092 | indices = np.arange(0, len(pred_pts), downsample_factor) |
| 1093 | pred_pts = pred_pts[indices] |
| 1094 | color = color[indices] |
| 1095 | |
| 1096 | return pred_pts, color |
| 1097 | |
| 1098 | def add_pc(self, step): |
| 1099 | """Add point cloud for a frame.""" |
no test coverage detected