public final class **BoundingBoxUtil** Helper class for converting values that represents bounding boxes into rectangles.

The class provides a static function to create bounding boxes as `https://developer.android.com/reference/android/graphics/RectF.html` from different types of configurations.

Generally, a bounding box could be represented by 4 float values, but the values could be
interpreted in many ways. We now support 3 `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.Type` of configurations, and the order of
elements in each type is configurable as well.

<br />

<br />

### Nested Classes

|---|---|---|---|
| enum | [BoundingBoxUtil.CoordinateType](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.CoordinateType) || Denotes if the coordinates are actual pixels or relative ratios. |
| enum | [BoundingBoxUtil.Type](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.Type) || Denotes how a bounding box is represented. |

### Public Methods

|---|---|
| static [List](https://developer.android.com/reference/java/util/List.html)\<RectF\> | [convert](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil#convert(org.tensorflow.lite.support.tensorbuffer.TensorBuffer,%20int[],%20int,%20org.tensorflow.lite.support.image.BoundingBoxUtil.Type,%20org.tensorflow.lite.support.image.BoundingBoxUtil.CoordinateType,%20int,%20int))([TensorBuffer](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/tensorbuffer/TensorBuffer) tensor, int\[\] valueIndex, int boundingBoxAxis, [BoundingBoxUtil.Type](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.Type) type, [BoundingBoxUtil.CoordinateType](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.CoordinateType) coordinateType, int height, int width) Creates a list of bounding boxes from a `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/tensorbuffer/TensorBuffer` which represents bounding boxes. |

### Inherited Methods

From class java.lang.Object

|---|---|
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Methods

#### public static [List](https://developer.android.com/reference/java/util/List.html)\<RectF\>
**convert**
([TensorBuffer](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/tensorbuffer/TensorBuffer) tensor, int\[\] valueIndex, int boundingBoxAxis, [BoundingBoxUtil.Type](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.Type) type, [BoundingBoxUtil.CoordinateType](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.CoordinateType) coordinateType, int height, int width)

Creates a list of bounding boxes from a `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/tensorbuffer/TensorBuffer` which represents bounding boxes.

##### Parameters

| tensor | holds the data representing some boxes. |
| valueIndex | denotes the order of the elements defined in each bounding box type. An empty index array represent the default order of each bounding box type. For example, to denote the default order of BOUNDARIES, {left, top, right, bottom}, the index should be {0, 1, 2, 3}. To denote the order {left, right, top, bottom}, the order should be {0, 2, 1, 3}. The index array can be applied to all bounding box types to adjust the order of their corresponding underlying elements. |
| boundingBoxAxis | specifies the index of the dimension that represents bounding box. The size of that dimension is required to be 4. Index here starts from 0. For example, if the tensor has shape 4x10, the axis for bounding boxes is likely to be 0. Negative axis is also supported: -1 gives the last axis and -2 gives the second, .etc. theFor shape 10x4, the axis is likely to be 1 (or -1, equivalently). |
| type | defines how values should be converted into boxes. See `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.Type` |
| coordinateType | defines how values are interpreted to coordinates. See `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.CoordinateType` |
| height | the height of the image which the boxes belong to. Only has effects when `coordinateType` is `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.CoordinateType#RATIO` |
| width | the width of the image which the boxes belong to. Only has effects when `coordinateType` is `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/image/BoundingBoxUtil.CoordinateType#RATIO` |
|---|---|

##### Returns

- A list of bounding boxes that the `tensor` represents. All dimensions except `boundingBoxAxis` will be collapsed with order kept. For example, given `tensor` with shape {1, 4, 10, 2} and `boundingBoxAxis = 1`, The result will be a list of 20 bounding boxes.

##### Throws

| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if size of bounding box dimension (set by `boundingBoxAxis`) is not 4. |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if `boundingBoxAxis` is not in `(-(D+1), D)` where `D` is the number of dimensions of the `tensor`. |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if `tensor` has data type other than `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/DataType#FLOAT32`. |
|---|---|