Skip to content

Commit

Permalink
[Fix] Fix potential bug in lasermix (#2710)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangxu-0103 authored Sep 13, 2023
1 parent c642055 commit 48fd72f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions mmdet3d/datasets/transforms/transforms_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2604,26 +2604,29 @@ def laser_mix_transform(self, input_dict: dict, mix_results: dict) -> dict:
points = input_dict['points']
pts_semantic_mask = input_dict['pts_semantic_mask']

# convert angle to radian
pitch_angle_down = self.pitch_angles[0] / 180 * np.pi
pitch_angle_up = self.pitch_angles[1] / 180 * np.pi

rho = torch.sqrt(points.coord[:, 0]**2 + points.coord[:, 1]**2)
pitch = torch.atan2(points.coord[:, 2], rho)
pitch = torch.clamp(pitch, self.pitch_angles[0] + 1e-5,
self.pitch_angles[1] - 1e-5)
pitch = torch.clamp(pitch, pitch_angle_down + 1e-5,
pitch_angle_up - 1e-5)

mix_rho = torch.sqrt(mix_points.coord[:, 0]**2 +
mix_points.coord[:, 1]**2)
mix_pitch = torch.atan2(mix_points.coord[:, 2], mix_rho)
mix_pitch = torch.clamp(mix_pitch, self.pitch_angles[0] + 1e-5,
self.pitch_angles[1] - 1e-5)
mix_pitch = torch.clamp(mix_pitch, pitch_angle_down + 1e-5,
pitch_angle_up - 1e-5)

num_areas = np.random.choice(self.num_areas, size=1)[0]
angle_list = np.linspace(self.pitch_angles[1], self.pitch_angles[0],
angle_list = np.linspace(pitch_angle_up, pitch_angle_down,
num_areas + 1)
out_points = []
out_pts_semantic_mask = []
for i in range(num_areas):
# convert angle to radian
start_angle = angle_list[i + 1] / 180 * np.pi
end_angle = angle_list[i] / 180 * np.pi
start_angle = angle_list[i + 1]
end_angle = angle_list[i]
if i % 2 == 0: # pick from original point cloud
idx = (pitch > start_angle) & (pitch <= end_angle)
out_points.append(points[idx])
Expand Down

0 comments on commit 48fd72f

Please sign in to comment.