# `BB.Estimator.ArUco`
[🔗](https://github.com/beam-bots/bb_estimator_aruco/blob/main/lib/bb/estimator/aruco.ex#L5)

Finds ArUco fiducial markers in camera frames, using OpenCV's detector
through `evision`.

Nest it inside a camera sensor, and it receives each frame the camera
captures:

    sensor :camera, {BB.Camera.V4L, device: "/dev/video0", width: 640, height: 480} do
      estimator :markers, {BB.Estimator.ArUco, dictionary: :dict_4x4_50}
    end

For every frame it publishes a `BB.Message.Vision.Fiducials` at its own path
- `[:sensor, ..., :camera, :markers]` above - including a frame in which it
found nothing, whose message has an empty `markers` list. The message
carries the frame's `frame_id` and capture time.

## Frames

It reads `{:raw, :I420}` frames, which every `bb_camera` driver produces.
Detection works on greyscale, and the first `width * height` bytes of an
I420 frame - its Y plane - are exactly that, so it detects on those bytes
directly and converts nothing.

A frame in any other format is ignored: nothing is published for it. A
camera's format is fixed for its stream, so in practice that means a driver
this estimator can't read, and nothing it publishes would ever be
different.

## Pace

Detection runs in the estimator's own process, on one of the VM's dirty CPU
schedulers. The camera hands it the newest frame each time it finishes the
last, so a detector slower than the camera skips frames rather than falling
behind.

## Dictionaries

A marker's ID only means something within the dictionary it was generated
from, and a marker from another dictionary is not detected at all. Print
markers from the dictionary you configure, with
`mix bb_estimator_aruco.gen.markers`.

# `dictionaries`

```elixir
@spec dictionaries() :: [atom()]
```

The dictionaries `:dictionary` accepts.

# `dictionary`

```elixir
@spec dictionary(atom()) :: Evision.ArUco.Dictionary.t()
```

The OpenCV dictionary a `:dictionary` option names, for generating markers
the estimator will detect:

    dictionary = BB.Estimator.ArUco.dictionary(:dict_4x4_50)
    image = Evision.ArUco.generateImageMarker(dictionary, 7, 200)

---

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