# `BB.Message.Vision.Fiducials`
[🔗](https://github.com/beam-bots/bb_estimator_aruco/blob/main/lib/bb/message/vision/fiducials.ex#L5)

The fiducial markers found in one camera frame.

A reading, like `BB.Message.Sensor.LaserScan`: one message per frame
examined, whether or not anything was found in it. An empty `markers` list
says the detector looked and saw nothing, which a consumer tracking a marker
needs to know as much as it needs a sighting.

The envelope is the frame's: `frame_id` is the camera that captured it, and
`monotonic_time` and `wall_time` are when it was captured rather than when
detection finished, so an estimator downstream measures age from when the
scene was seen.

## Fields

- `markers` - one `BB.Message.Vision.Fiducials.Marker` per marker found
- `width`, `height` - the dimensions of the frame the markers were found in,
  in pixels, so that corners can be read without the frame itself

## Corners

Each corner is an `{x, y}` tuple of floats in pixel coordinates: `x`
rightwards and `y` downwards from the top-left of the frame, with whole
numbers at pixel centres, as OpenCV reports them. The four of a marker are
in the marker's own order - top-left, top-right, bottom-right, bottom-left
as the marker is printed - however it is rotated in the frame.

Every corner lies within the frame: from `-0.5` to `width - 0.5`
horizontally and `-0.5` to `height - 0.5` vertically, the frame's extent
when whole numbers are pixel centres. `c:BB.Message.validate/1` refuses a
message whose corners don't, with
`BB.Error.Invalid.Vision.CornerOutsideFrame`.

The same marker ID can appear more than once in a frame, if it was printed
more than once.

## Examples

    alias BB.Message.Vision.Fiducials
    alias BB.Message.Vision.Fiducials.Marker

    {:ok, msg} =
      Fiducials.new(:camera,
        width: 640,
        height: 480,
        markers: [
          %Marker{
            id: 7,
            corners: [{100.0, 50.0}, {159.0, 50.0}, {159.0, 109.0}, {100.0, 109.0}]
          }
        ]
      )

# `t`

```elixir
@type t() :: %BB.Message.Vision.Fiducials{
  height: pos_integer(),
  markers: [BB.Message.Vision.Fiducials.Marker.t()],
  width: pos_integer()
}
```

# `new`

```elixir
@spec new(atom(), keyword()) :: {:ok, BB.Message.t()} | {:error, term()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
