Skip to content

Commit 48fd72f

Browse files
authored
[Fix] Fix potential bug in lasermix (#2710)
1 parent c642055 commit 48fd72f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

mmdet3d/datasets/transforms/transforms_3d.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,26 +2604,29 @@ def laser_mix_transform(self, input_dict: dict, mix_results: dict) -> dict:
26042604
points = input_dict['points']
26052605
pts_semantic_mask = input_dict['pts_semantic_mask']
26062606

2607+
# convert angle to radian
2608+
pitch_angle_down = self.pitch_angles[0] / 180 * np.pi
2609+
pitch_angle_up = self.pitch_angles[1] / 180 * np.pi
2610+
26072611
rho = torch.sqrt(points.coord[:, 0]**2 + points.coord[:, 1]**2)
26082612
pitch = torch.atan2(points.coord[:, 2], rho)
2609-
pitch = torch.clamp(pitch, self.pitch_angles[0] + 1e-5,
2610-
self.pitch_angles[1] - 1e-5)
2613+
pitch = torch.clamp(pitch, pitch_angle_down + 1e-5,
2614+
pitch_angle_up - 1e-5)
26112615

26122616
mix_rho = torch.sqrt(mix_points.coord[:, 0]**2 +
26132617
mix_points.coord[:, 1]**2)
26142618
mix_pitch = torch.atan2(mix_points.coord[:, 2], mix_rho)
2615-
mix_pitch = torch.clamp(mix_pitch, self.pitch_angles[0] + 1e-5,
2616-
self.pitch_angles[1] - 1e-5)
2619+
mix_pitch = torch.clamp(mix_pitch, pitch_angle_down + 1e-5,
2620+
pitch_angle_up - 1e-5)
26172621

26182622
num_areas = np.random.choice(self.num_areas, size=1)[0]
2619-
angle_list = np.linspace(self.pitch_angles[1], self.pitch_angles[0],
2623+
angle_list = np.linspace(pitch_angle_up, pitch_angle_down,
26202624
num_areas + 1)
26212625
out_points = []
26222626
out_pts_semantic_mask = []
26232627
for i in range(num_areas):
2624-
# convert angle to radian
2625-
start_angle = angle_list[i + 1] / 180 * np.pi
2626-
end_angle = angle_list[i] / 180 * np.pi
2628+
start_angle = angle_list[i + 1]
2629+
end_angle = angle_list[i]
26272630
if i % 2 == 0: # pick from original point cloud
26282631
idx = (pitch > start_angle) & (pitch <= end_angle)
26292632
out_points.append(points[idx])

0 commit comments

Comments
 (0)