opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.46k stars 5.77k forks source link

Aruco: Charuco board markers are imprecise #592

Closed TomasRiker closed 8 years ago

TomasRiker commented 8 years ago

The Charuco board code uses several image scaling and warping steps to create the final board image. Along the way, pixel precision gets lost. Creating a Charuco board with just as many pixels as are needed to place all markers will show that some markers are one row/column too small. Also with really large image sizes, the differences between the markers' square sizes are noticeable.

andrewseddon commented 8 years ago

./example_aruco_create_board_charuco --bb=1 -d=15 -h=30 --ml=7 --si=false --sl=11 -w=30 -m=0 charuco.bmp

Generates a marker showing this. Note the uneven spacing around the bottom right of the image. Issue can be seen in higher resolutions also.

charuco

sergarrido commented 8 years ago

I think the problem is that marker pixel lenght (--ml parameter) is not appropiate for the selected dictionary (-d parameter). The dictionary (-d 15) is DICT_7X7_1000, which means the internal binary pattern will be composed by 7x7 bits. Also, you are choosing a marker border width of one bit (-bb 1). So you need at least a marker lenght of 9x9 pixels to represent the markers correctly (--ml 9).

Probably some workaround or automatic detection of this situation should be added to the library.

andrewseddon commented 8 years ago

@sergarrido Thanks for spotting, unfortunately getting the same problem after correcting --ml and --sl

./example_aruco_create_board_charuco --bb=1 -d=15 -h=32 --ml=9 --si=false --sl=15 -w=32 -m=0 out_7.bmp

gives

out_7

sergarrido commented 8 years ago

I see. I thought the problem was only in the inner patterns of the markers. I didnt notice the markers' displacement wrt the chess squares.

Yes, it seems to be a bug. Probably related to incorrect float truncation.