---
title: "MLObjectDetector.AnnotationType.boundingBox(units:origin:anchor:)"
framework: createml
role: symbol
role_heading: Case
path: "createml/mlobjectdetector/annotationtype/boundingbox(units:origin:anchor:)"
---

# MLObjectDetector.AnnotationType.boundingBox(units:origin:anchor:)

An annotation type that defines a rectangle around an object within an image.

## Declaration

```swift
case boundingBox(units: MLBoundingBoxUnits = .pixel, origin: MLBoundingBoxCoordinatesOrigin = .topLeft, anchor: MLBoundingBoxAnchor = .center)
```

## Discussion

Discussion To use bounding box annotations, you must tell Create ML how to interpret your annotations. Use MLBoundingBoxUnits to specify the coordinate units of your bounding boxes. Use MLBoundingBoxAnchor to specify the location in the bounding box its coordinates refer to. Use MLBoundingBoxCoordinatesOrigin to specify the part of the image the annotations use as their origin. Formatting a Bounding Box JSON Annotation File The base of the JSON file must contain an array of the following JSON object structure.  |  |   |  |   |  |  Each JSON object in the annotation array must have the following JSON object structure.  |  |   |  |   |  |  The coordinate JSON object must have the following structure. The origin of the image is the upper-left corner. The x-values increase from left to right, and the y-values increase from the top to the bottom.  |  |   |  |   |  |   |  |   |  |  As an example, the following JSON file has correct structure with one image file ("cat and dog.png") in its base array, which has two annotations. // JSON file   [{     "imagefilename": "cat and dog.png",     "annotation":     [       {         "label": "cat",         "coordinates":         {           "y": 2.0,           "x": 3.9,           "height": 40.1,           "width": 20.0         }       }, {         "label": "dog",         "coordinates":         {           "y": 40.0,           "x": 38.9,           "height": 100.1,           "width": 70.0         }       }     ]   },   ... ] A typical annotation JSON file has many more objects in its base array, one for each image file.

## See Also

### Bounding box annotations

- [MLBoundingBoxUnits](createml/mlboundingboxunits.md)
- [MLBoundingBoxAnchor](createml/mlboundingboxanchor.md)
- [MLBoundingBoxCoordinatesOrigin](createml/mlboundingboxcoordinatesorigin.md)
