[Python] How to generate charuco board with ids offset

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Charuco marker from Opencv in python. I was previously using Aruco board where I had the option to create a board with and id offset (e.g: offset of 40).

    from cv2 import aruco as ar
    ar_dict = ar.getPredefinedDictionary(ar.DICT_6X6_1000)
    board = ar.ar.GridBoard_create(markersX=sizeX, markersY=sizeY, markerLength=0.04, markerSeparation=0.01, dictionary=ar_dict, firstMarker=40)


    However, it looks like the option is not available for Charuco board. The closest solutions I found was proposed here in C++, However, the option is not working in python as the ids are not writable.

    board = ar.CharucoBoard_create(15, 7, 1, .8, ar_dict)
    board.ids += 10

    ---------------------------------------------------------------------------
    AttributeError Traceback (most recent call last)
    <ipython-input-11-410d8ac9fdda> in <module>
    ----> 1 board.ids += 10

    AttributeError: attribute 'ids' of 'cv2.aruco_Board' objects is not writable


    Does anyone know if there are other alternatives in python to add offset to the marker ids when creating a Charuco board object?

    Edit September 2021

    It looks like the option to set ids is now available in python with this commit: https://github.com/opencv/opencv_co...8019cb9963379a43271b15bea09259638e3dfa386bd4a. Running version of Opencv 4.5.3 the board ids can now be modified with success.

    from cv2 import aruco as ar
    ar_dict = ar.getPredefinedDictionary(ar.DICT_6X6_1000)
    board = ar.CharucoBoard_create(15, 7, 1, .8, ar_dict)
    board.ids += 10

    Continue reading...

Compartilhe esta Página