kaolin.metrics.pointcloud¶
API¶
-
kaolin.metrics.pointcloud.
chamfer_distance
(p1, p2, w1=1.0, w2=1.0)¶ Computes the chamfer distance between two pointclouds
Parameters: - p1 (torch.Tensor) – pointclouds of shape (B, N, 3)
- p2 (torch.Tensor) – pointclouds of shape (B, M, 3)
- w1 (float) – weighting of forward direction. Default: 1.
- w2 (float) – weighting of backward direction. Default: 1.
Returns: chamfer distance between two pointclouds p1 and p2 of shape (B)
Return type: Example
>>> p1 = torch.tensor([[[8.8977, 4.1709, 1.2839], ... [8.5640, 7.7767, 9.4214]], ... [[0.5431, 6.4495, 11.4914], ... [3.2126, 8.0865, 3.1018]]], device='cuda', dtype=torch.float) >>> p2 = torch.tensor([[[6.9340, 6.1152, 3.4435], ... [0.1032, 9.8181, 11.3350]], ... [[11.4006, 2.2154, 7.9589], ... [4.2586, 1.4133, 7.2606]]], device='cuda', dtype=torch.float) >>> chamfer_distance(p1, p2) tensor([ 72.5838, 151.0809], device='cuda:0')
-
kaolin.metrics.pointcloud.
f_score
(gt_points, pred_points, radius=0.01, eps=1e-08)¶ Computes the f-score of two sets of points, with a hit defined by two point existing within a defined radius of each other
Parameters: - gt_points (torch.Tensor) – ground truth pointclouds of shape (B, N, 3)
- pred_points (torch.Tensor) – predicted points pointclouds of shape (B, M, 3)
- radius (float) – radius from a point to define a hit Default: 0.01
- eps (float) – epsilon used to calculate f score.
Returns: computed f-score tensor of shape (B), which has the same dtype as input pred_points.
Return type: Example
>>> p1 = torch.tensor([[[8.8977, 4.1709, 1.2839], ... [8.5640, 7.7767, 9.4214]], ... [[0.5431, 6.4495, 11.4914], ... [3.2126, 8.0865, 3.1018]]], device='cuda', dtype=torch.float) >>> p2 = torch.tensor([[[9.4863, 4.2249, 0.1712], ... [8.1783, 8.5310, 8.5119]], ... [[-0.0020699, 6.4429, 12.3], ... [3.8386, 8.3585, 4.7662]]], device='cuda', dtype=torch.float) >>> f_score(p1, p2, radius=1) tensor([0.5000, 0.0000], device='cuda:0') >>> f_score(p1, p2, radius=1.5) tensor([1.0000, 0.5000], device='cuda:0')
-
kaolin.metrics.pointcloud.
sided_distance
(p1, p2)¶ For every point in p1 find the indices and euclidean distances of the closest point in p2.
Parameters: - p1 (torch.Tensor) – pointclouds of shape (B, N, 3)
- p2 (torch.Tensor) – pointclouds of shape (B, M, 3)
Returns: the indices and distances from points in p1 to the corresponding closest points in p2, both have shape of (B, N)
Return type: Example
>>> p1 = torch.tensor([[[5.9336, 4.9742, 8.1047]], ... [[4.1939, 3.3612, 9.5407]]], device='cuda', dtype=torch.float) >>> p2 = torch.tensor([[[1.6998, 0.7719, 2.9987], ... [0.1812, 8.9342, 10.0285]], ... [[10.0184, 0.3928, 5.2545], ... [4.2934, 11.2127, 4.5247]]], device='cuda', dtype=torch.float) >>> distance, idx = sided_distance(p1, p2) >>> distance tensor([[52.4727], [61.1077]], device='cuda:0') >>> idx tensor([[1], [0]], device='cuda:0')