2

For performance reasons, I'd like to use an aruco dictionary that only contains a specific set of 20 aruco markers. The 20 markers I need in my custom dictionary are already chosen and come from the pre-defined dictionary DICT_6X6_250.

I've been reading the docs here: https://docs.opencv.org/master/d5/dae/tutorial_aruco_detection.html

Under the "Manual Dictionary Generation" section, it gives some hints, but a critical detail is missing:
How do you obtain the marker bits for a given marker id in a pre-definted dictionary?

If I could get the corresponding marker bits for a given marker Id in the pre-defined dictionary, then I could add those markers to my custom dictionary. I can't figure out why there isn't an API for this (something like Mat Dictionary::getMarkerBitsById(int markerId) ) which makes me think maybe I'm missing something fundamental.

Any help appreciated!

tmalik777
  • 21
  • 2

1 Answers1

0

I'm currently using OpenCV's Java bindings in Kotlin, but the method should work in any language.

fun getDict() : Dictionary {
    val base = Aruco.getPredefinedDictionary(Aruco.DICT_4X4_50)
    val dict = Aruco.custom_dictionary(4, 4)
    val tmp = ByteArray(16)
    listOf(8, 0, 4, 19).forEachIndexed { index, id ->
        base._bytesList.row(id)[0, 0, tmp]
        dict._bytesList.put(index, 0, tmp)
    }
    return dict
}

In the given code, I create a custom dictionary only containing the markers with the ids 8, 0, 4, 19. I simply access the _bytesList of my base dictionary, copy a row into a temporary ByteArray and finally put it into my custom dictionary.

I also tried copying a row directly into the new location, but it always only copied part of the marker. It seems like the Mat returned by base._bytesList.row(id) has a wrong size.

LeWimbes
  • 517
  • 1
  • 10
  • 25