thewfool
thewfool

Reputation: 31

Aruco Marker Tracking With Multiple Markers From the Same Dictionary

I'm using ChAruCo marker tracking from OpenCV Contrib. I'd like to track multiple boards, but the mechanism to create the marker boards is not as I would expect.

What I picture is having one dictionary (Say, DICT_4X4_50) to create many markers using distinct ID ranges from the dictionary.
CharucoBoard::create() accepts the dictionary and uses markers 0-X to create the board. I'd like to add an offset to the beginning of the range.

If I can create the boards, cv::aruco::detectMarkers() outputs IDs which can determine which board is in view. Is this supported, and if not, how should I go about tracking more than one target?

Upvotes: 2

Views: 2070

Answers (1)

PeterT
PeterT

Reputation: 8294

You can simply add an offset to the elements in the vector ids in the Board class. I can't tell you whether this is "supported", but we used it for non charuco boards and it worked fine. Since the charuco board indices nearestMarkerIdx are indices into the ids vector this should work out fine.

cv::Ptr<cv::aruco::CharucoBoard> board1 =  cv::aruco::CharucoBoard::create(3, 5, 0.32f, 0.08f, dictionary);
cv::Ptr<cv::aruco::CharucoBoard> board2 = cv::aruco::CharucoBoard::create(3, 5, 0.32f, 0.08f, dictionary);
int id_offset_board2 = board1->ids.size();
for(auto& id: board2->ids)
{
    id += id_offset_board2;
}

Upvotes: 3

Related Questions