Skip to content

[Feature] expose charuco detection parameters#37

Merged
Robertleoj merged 5 commits into
Robertleoj:mainfrom
JRombouts:feat_expose_charuco_detection_parameters
Jun 24, 2026
Merged

[Feature] expose charuco detection parameters#37
Robertleoj merged 5 commits into
Robertleoj:mainfrom
JRombouts:feat_expose_charuco_detection_parameters

Conversation

@JRombouts

Copy link
Copy Markdown
Contributor

This allows you to configure various parts, but will use default
settings from OpenCV if not passed.

Note: This changes the default behavior to minMarkers = 2 (opencv
default). In my experience, the extra detections with minMarkers = 1
are not high quality.

For our data this seems to work well:

detector_april = cv2.aruco.DetectorParameters()
detector_april.cornerRefinementMethod = cv2.aruco.CORNER_REFINE_APRILTAG

charuco_best = cv2.aruco.CharucoParameters()
charuco_best.minMarkers = 2  # default, but explicit
charuco_best.tryRefineMarkers = True

# I have not done a lot here - so there might be better options
refine_parameters = cv2.aruco.RefineParameters()

Note: these are RGB cameras, non-fisheye

I exhaustively tried many different combinations and then used 5-fold
cross-validation in the calibrations to see which methods tend to work
best (though I guess this will really depend on the
camera/environment/board) in general.

Note that the direct results from the calibration can't be directly
compared as the different settings will lead to different numbers of
outliers - and you can improve the score by rejecting more outliers
(read: overfitting).

Builds on #36

JRombouts and others added 5 commits June 18, 2026 14:03
Note that:

In [1]: import numpy as np
In [2]: a = np.array([[1]])
In [3]: a.squeeze()
Out[3]: array(1) # and a.squeeze().shape == ()

This breaks in Frame postinit (shape[0] access)

We want:

In [4]: a.squeeze(1).shape
Out[4]: (1,)
This allows you to configure various parts,  but will use default
settings from OpenCV if not passed.

Note: This changes the default behavior to `minMarkers = 2` (opencv
default). In my experience, the extra detections with `minMarkers = 1`
are not high quality.

For our data this seems to work well:

```python
detector_april = cv2.aruco.DetectorParameters()
detector_april.cornerRefinementMethod = cv2.aruco.CORNER_REFINE_APRILTAG

charuco_best = cv2.aruco.CharucoParameters()
charuco_best.minMarkers = 2  # default, but explicit
charuco_best.tryRefineMarkers = True

# I have not done a lot here - so there might be better options
refine_parameters = cv2.aruco.RefineParameters()
```

Note: these are RGB cameras, non-fisheye

I exhaustively tried many different combinations and then used 5-fold
cross-validation in the calibrations to see which methods tend to work
best (though I guess this will really depend on the
camera/environment/board) in general.

Note that the direct results from the calibration can't be directly
compared as the different settings will lead to different numbers of
outliers - and you can improve the score by rejecting more outliers
(read: overfitting).
@Robertleoj

Copy link
Copy Markdown
Owner

Thanks for the PR!

I'm going to leave the minMarker = 1 default. I've seen that while many of the extra detections close to the edge are not high quality, there are also many that are good quality, and the bad ones are mostly filtered out as outliers.

@Robertleoj
Robertleoj merged commit 83615e7 into Robertleoj:main Jun 24, 2026
4 checks passed
@JRombouts

Copy link
Copy Markdown
Contributor Author

Yeah, I figured you might want to have it like that. Now at least it is easy to configure :)

Comment thread src/lensboy/common_targets/charuco.py Outdated
) -> Frame | None:

charuco_params = (
cv2.arcuo.CharucoParameters()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants