# plane_validation

Python API: `depthai_nodes.node.support_plane_calibrator.plane_validation`

The level test shared by the candidate search and plane verification.

## Functions

### gravity_angle_deg

```python
def gravity_angle_deg(plane_eq: np.ndarray, gravity: np.ndarray) -> float:
```

Return the angle between a plane normal and the direction opposing gravity.

Parameters

 * `plane_eq` (`np.ndarray`): Plane `(a, b, c, d)` with a unit normal `(a, b, c)`.
 * `gravity` (`np.ndarray`): Raw accelerometer vector; only its direction is used.

Returns

 * `float`: The angle in degrees, from 0 to 180.

### is_valid_horizontal_plane

```python
def is_valid_horizontal_plane(plane_eq: np.ndarray, gravity: np.ndarray, config: PlaneCalibrationConfig) -> bool:
```

Check that a plane is horizontal and lies below the camera (the level test).

Parameters

 * `plane_eq` (`np.ndarray`): Plane `(a, b, c, d)` with a unit normal `(a, b, c)`, oriented with
   [orient_along_gravity](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/support_plane_calibrator/plane_validation.md).
 * `gravity` (`np.ndarray`): Raw accelerometer vector; only its direction is used.
 * `config` (`PlaneCalibrationConfig`): Supplies the largest angle between the normal and the direction opposing gravity, and the
   camera height range.

Returns

 * `bool`: `True` if the normal is within the angle and the camera height `-d` is not negative and within the configured range.
   `False` if `gravity` is the zero vector.

### orient_along_gravity

```python
def orient_along_gravity(plane_eq: np.ndarray, gravity: np.ndarray) -> np.ndarray:
```

Return the plane equation with its normal pointing away from `gravity`.

The accelerometer vector points up, so the oriented normal points down, away from a camera above the plane. RANSAC and saved
planes may give either sign; orienting them first makes
[is_valid_horizontal_plane](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/support_plane_calibrator/plane_validation.md)
depend only on the plane.

Parameters

 * `plane_eq` (`np.ndarray`): Plane `(a, b, c, d)`.
 * `gravity` (`np.ndarray`): Raw accelerometer vector.

Returns

 * `np.ndarray`: `plane_eq` if its normal already points away from `gravity`, otherwise the negated equation.
