Skip to content

Different Marker Ordering with findChessboardCornersSBWithMeta and CALIB_CB_LARGER Flag #26830

@IHni3

Description

@IHni3

System Information

OpenCV Version: 4.11
Operating System: Ubuntu 24.04
Compiler: Clang 18.1.3

But the bug is logical, so it happens in every configuration.

Detailed description

The function findChessboardCornersSBWithMeta returns different marker ordering behavior depending on the minimum pattern size and the CALIB_CB_LARGER flag.

Expected Behavior:
The order of detected markers should be consistent regardless of the minimum pattern size setting when the CALIB_CB_LARGER flag is used.

Actual Behavior:
When the minimum pattern size is set to 5x5 and a 7x7 chessboard is found, the marker order differs from the case where the minimum pattern size is set to 7x7.

Illustration:

  • Case 1: Minimum pattern size = 5x5, detected pattern = 7x7 (incorrect ordering)
    Image
  • Case 2: Minimum pattern size = 7x7, detected pattern = 7x7 (correct ordering)
    Image

Error Cause:
The source code in src/chessboard.cpp around line 3724 calls iter_boards->normalizeOrientation(false); only when the found pattern size matches the minimum pattern size. This function call seems to be responsible for correcting some kind of marker ordering.

Possible Fix:
By moving the normalizeOrientation call outside the if block, it will be executed regardless of whether the found pattern size matches the minimum pattern size. This should ensure consistent marker ordering.

iter_boards->normalizeOrientation(false);
if (iter_boards->getSize() == parameters.chessboard_size || iter_boards->getSize() == chessboard_size2) {
  // ... rest of the code
}

Steps to reproduce

A Python code example demonstrating the issue can be found here: https://gist.github.com/IHni3/dc5b5a546e44c1582789317d4a8816aa

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions