Beam Bots Logo

bb_estimator_aruco

CI License: Apache 2.0 Hex version badge Hexdocs badge REUSE status Ask DeepWiki

A Beam Bots estimator that finds ArUco fiducial markers in camera frames, using OpenCV through evision.

Nest it inside any bb_camera camera:

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

For every frame it examines it publishes a BB.Message.Vision.Fiducials at [:sensor, :head, :camera, :markers]: each marker's ID and its four corners in pixels, stamped with the frame's capture time. A frame with no markers in it publishes an empty list.

BB.subscribe(MyRobot, [:sensor, :head, :camera, :markers])

receive do
  {:bb, _path, %BB.Message{payload: %BB.Message.Vision.Fiducials{markers: markers}}} ->
    Enum.map(markers, & &1.id)
end

Installation

def deps do
  [
    {:bb_estimator_aruco, "~> 0.1.0"}
  ]
end

evision downloads a precompiled OpenCV for your platform when it compiles.

Printing markers

Print markers from the dictionary the estimator is configured with; a marker from any other dictionary is not detected. mix bb_estimator_aruco.gen.markers writes them as PNGs, each with the white border the detector needs:

mix bb_estimator_aruco.gen.markers --dictionary dict_4x4_50 --ids 0..3,7 --output markers --sheet

That writes markers/dict_4x4_50_0.png and so on, plus markers/dict_4x4_50_sheet.png with all of them on one page. mix help bb_estimator_aruco.gen.markers lists the options for marker size, border width and the rest.