Use the homography matrix from Apriltag

This is just to share a piece of a code that might prove useful for someone.

If you want to use the homography matrix from a detected Apriltag (such as the ones from Apriltags.jl), in order to convert from pixel coordinates to the 1 to 10 indices of the bit array of a tag36h11 tag, this can help:

using StaticArrays, CoordinateTransformations

push1(x) = CoordinateTransformations.push(x, 1)

function get_transform(H)
    s = 3.5
    scale = inv(SDiagonal(s, s, 1))
    M = LinearMap(SMatrix{3,3, Float64}(H * scale))
    trans = Translation(-4.5, -4.5)
    return reverse ∘ PerspectiveMap() ∘ M ∘ push1 ∘ trans ∘ reverse

Where H is the homography matrix.