MCPcopy Index your code
hub / github.com/InternRobotics/EmbodiedScan / bbox3d2roi

Function bbox3d2roi

embodiedscan/structures/ops/transforms.py:27–47  ·  view source on GitHub ↗

Convert a list of bounding boxes to roi format. Args: bbox_list (list[torch.Tensor]): A list of bounding boxes corresponding to a batch of images. Returns: torch.Tensor: Region of interests in shape (n, c), where the channels are in order of [batch_i

(bbox_list)

Source from the content-addressed store, hash-verified

25
26
27def bbox3d2roi(bbox_list):
28 """Convert a list of bounding boxes to roi format.
29
30 Args:
31 bbox_list (list[torch.Tensor]): A list of bounding boxes
32 corresponding to a batch of images.
33
34 Returns:
35 torch.Tensor: Region of interests in shape (n, c), where
36 the channels are in order of [batch_ind, x, y ...].
37 """
38 rois_list = []
39 for img_id, bboxes in enumerate(bbox_list):
40 if bboxes.size(0) > 0:
41 img_inds = bboxes.new_full((bboxes.size(0), 1), img_id)
42 rois = torch.cat([img_inds, bboxes], dim=-1)
43 else:
44 rois = torch.zeros_like(bboxes)
45 rois_list.append(rois)
46 rois = torch.cat(rois_list, 0)
47 return rois
48
49
50# TODO delete this

Callers

nothing calls this directly

Calls 1

catMethod · 0.45

Tested by

no test coverage detected