# OpenCV 4.9.0 Bug: Markers in generated ChArUco board are not centered

**URL:** <https://forum.opencv.org/t/opencv-4-9-0-bug-markers-in-generated-charuco-board-are-not-centered/16029>\
**Category:** C++\
**Tags:** aruco, objdetect\
**Created:** [January 2, 2024, 8:05pm UTC](https://forum.opencv.org/t/opencv-4-9-0-bug-markers-in-generated-charuco-board-are-not-centered/16029 "2024-01-02T20:05:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/giri/32/9433_2.png) [@Giri](https://forum.opencv.org/u/Giri)\
**Post date:** [January 2, 2024, 8:05pm UTC](https://forum.opencv.org/t/opencv-4-9-0-bug-markers-in-generated-charuco-board-are-not-centered/16029/1 "2024-01-02T20:05:08Z")

</div>

I am using OpenCV 4.9.0 to generate a ChArUco board with the following configuration in python.

```auto
arucoDict = cv2.aruco.DICT_4X4_1000
boardSize = [2,7]
squareLength = 13
markerLength = 10
dictionary = cv2.aruco.getPredefinedDictionary(arucoDict)
board = cv2.aruco.CharucoBoard(boardSize, squareLength, markerLength, dictionary)
image = board.generateImage([200, 150],1,1);

```

But I see the ArUco markers in the generated ChArUco board are not centered like you can see in the bottom of the image below:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/7/70f7669aa8b41df0b62b0526aeaf1082e9186434.png)

I see that this issue does not exist in the older version of OpenCV 4.7.0.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [January 2, 2024, 8:09pm UTC](https://forum.opencv.org/t/opencv-4-9-0-bug-markers-in-generated-charuco-board-are-not-centered/16029/2 "2024-01-02T20:09:09Z")

</div>

v4.7 is outdated. update to 4.9 and see if it still happens.

if this is only reproducible on v4.7 and not later, then it’s already been fixed. I hope you’ll understand why any complaints against an obsolete version cannot be heard.

---

<div class="post-metadata">

**Author:** ![Giri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/giri/32/9433_2.png) [@Giri](https://forum.opencv.org/u/Giri)\
**Post date:** [January 2, 2024, 8:25pm UTC](https://forum.opencv.org/t/opencv-4-9-0-bug-markers-in-generated-charuco-board-are-not-centered/16029/3 "2024-01-02T20:25:26Z")

</div>

I tried v4.9 python version and the issue still exists!

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [January 3, 2024, 2:53pm UTC](https://forum.opencv.org/t/opencv-4-9-0-bug-markers-in-generated-charuco-board-are-not-centered/16029/4 "2024-01-03T14:53:16Z")

</div>

Just to be clear: are you claiming that essentially identical application code, in C++ and in Python, using APIs of the same OpenCV version, produces different results?

---

<div class="post-metadata">

**Author:** ![Giri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/giri/32/9433_2.png) [@Giri](https://forum.opencv.org/u/Giri)\
**Post date:** [January 3, 2024, 5:56pm UTC](https://forum.opencv.org/t/opencv-4-9-0-bug-markers-in-generated-charuco-board-are-not-centered/16029/5 "2024-01-03T17:56:08Z")

</div>

Sorry that is not what I meant. I have corrected my problem description.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [January 3, 2024, 8:45pm UTC](https://forum.opencv.org/t/opencv-4-9-0-bug-markers-in-generated-charuco-board-are-not-centered/16029/6 "2024-01-03T20:45:44Z")

</div>

note that this could be considered “cosmetic” because the markers themselves only serve to identify the squares. the actual corners are derived _not_ from any markers but from the saddle points of the checkerboard pattern.

it’s very ugly though and ought to be fixed.

the markers also appear to “creep” ever further away from their center positions… I wonder if any code will eventually touch and overlap with an adjacent square.

* * *

I see that you did already file a bug:

> <https://github.com/opencv/opencv/issues/24806>
>
> \### System Information
> 
> OpenCV Python version: 4.9.0
> Platform: Debian 11
> Pytho…n version: 3.9.2
> 
> \### Detailed description
> 
> Generating ChArUco board no longer produces accurate boards. The ArUco markers are not centered in the chessboard squares like shown below. There seems some kind of drift as the number of columns increases in this case. This was not a problem in OpenCV 4.6. 
> 
> !\[GenCharuco\](https://github.com/opencv/opencv/assets/17119312/3163a66f-7cb3-4aa0-bba1-6c1f58771913)
> 
> 
> 
> \### Steps to reproduce
> 
> arucoDict = cv2.aruco.DICT\_4X4\_1000
> boardSize = \[7,2\]
> squareLength = 13
> markerLength = 10
> dictionary = cv2.aruco.getPredefinedDictionary(arucoDict)
> board = cv2.aruco.CharucoBoard(boardSize, squareLength, markerLength, dictionary)
> image = board.generateImage(\[200, 150\],1,1);
> 
> \### Issue submission checklist
> 
> \- \[X\] I report the issue, it's not a question
> \- \[X\] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
> \- \[X\] I updated to the latest OpenCV version and the issue is still there
> \- \[X\] There is reproducer code and related data files (videos, images, onnx, etc)
