Thanks to visit codestin.com
Credit goes to github.com

Skip to content

aruco board generateImage() cannot handle rotated markers #25884

@dcnieho

Description

@dcnieho

This function:

void Board::Impl::generateImage(Size outSize, OutputArray img, int marginSize, int borderBits) const {

can only handle boards where all markers are upright.
That is because the line
Size dst_sz(outCorners[2] - outCorners[0]); // assuming CCW order

doesn't just assume CCW order of the corner points, but also that outCorners[2] is to the right and below outCorners[0] by exactly sz distance units along both axes. For a rotated marker, this is not the case.

The solution is simple: compute the horizontal size of the marker (i.e. dst_sz.width) as the 2D distance between outCorners[0] and outCorners[1], and the vertical size (i.e., dst_sz.height) as the 2D distance between outCorners[1] and outCorners[2]. The rest of the logic already handles rotated markers correctly.

I have not implemented this in C++, but i have ported the function to Python and made this change, it works well. See here:
https://github.com/dcnieho/glassesTools/blob/0a03b5a2a6f6c093ef77c15decdc7bd3e570ef06/src/glassesTools/plane.py#L137, specifically line 166

Another note when working on this function anyway: the comments on line 128 and line 133 are non-sensical, 128 is for setting up the affine transform, and 133 should be something like // perform affine transformation (i.e. rotate marker).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions