gather(boxlist: BoxList, indices: ndarray, fields: Optional[List[str]] = None) BoxList[source]#

Gather boxes from BoxList according to indices and return new BoxList.

By default, gather returns boxes corresponding to the input index list, as well as all additional fields stored in the boxlist (indexing into the first dimension). However one can optionally only gather from a subset of fields.

  • boxlist (BoxList) – BoxList holding N boxes.

  • indices (np.ndarray) – A 1-d numpy array of type int.

  • fields (Optional[List[str]]) – List of fields to also gather from. If None, all fields are gathered from. Pass an empty fields list to only gather the box coordinates. Defaults to None.


a BoxList corresponding to the subset of the input BoxList

specified by indices

Return type



ValueError – If specified field is not contained in boxlist or if the indices are not of type int.