menpo/menpo — pull request #477 by jabooth (2014-10-14 11:49:33+00:00)
Title: WIP: BoundingBox

This PR adds a `BoundingBox` shape to Menpo. `BoundingBox` is a subclass of `PointCloud`. You build a `BoundingBox` by supplying an numpy array of shape `(2, n_dims)`, where `arr[0]` is the minimum values in all dimensions on the box, and `arr[1]` is the maximum value of all points on the box.
```python
bb = BoundingBox(np.array([[0, 0], [1, 1]]) # make a bounding box for (0,0) to (1,1)

bb.min() # returns np.array([0, 0])
bb.max() # returns np.array([1, 1])

bb.box() # returns a PointGraph with 4 points, filling in the other 2 vertices in the square.

bb.view() # views using it's PointGraph representation so it looks pretty
```

`BoundingBox` is the natural return type for a number of places in the menpo API.

```python
pc = PointCloud(np.random.rand(100, 2))
pc.bounds() # returns a BoundingBox
min_bounds = pc.bounds().min() # nice and clean
```

It will also be used by menpodetect and works great as a landmark type:

```python
from menpodetect import detect_frontal_faces
detect_frontal_faces(img) # attaches BoundingBox instances as Landmarks
img.view() # nice boxes around every face found
```

#### TODO
- merge in #470 and check
- add (skipable) checks to constructor (n_points = 2)
- tests
- box should only be supported for n_dims = 2 for now