Skip to content

Calibrate Intrinsics ​

SUMMARY

calibrate() detects the calibration target in every input image and solves for the camera's intrinsic matrix and distortion coefficients via cv::calibrateCamera, dropping views whose own error is too high and refitting on the rest.

SUPPORTED TARGETS

Works with any target, ChessboardTarget, CharucoTarget, ArucoTarget, or ZividTarget, see All Supported Targets.

UNITS

Input images can be BGR, BGRA or grayscale ndarrays. reprojection_error and per_view_errors are RMS values in pixels.

The Skill ​

python
result = calibrator.calibrate(images)
SkillReturnsDescription
calibrate(images)IntrinsicResultDetect the target in every image, run cv::calibrateCamera, filter views by their per-view error and refit.

The Code ​

python
from telekinesis.axon import IntrinsicCalibrator, IntrinsicOptions
from telekinesis.axon.targets import CharucoTarget

target = CharucoTarget(squares_x=6, squares_y=9, square_length=0.012, marker_length=0.009)

options = IntrinsicOptions()
options.per_view_error_threshold = 0.8

calibrator = IntrinsicCalibrator(target, options)
result = calibrator.calibrate(images)

result.ok                     # bool
result.intrinsic_matrix       # (3, 3) np.ndarray
result.distortion_coefficients
result.reprojection_error     # RMS (px) over the views used in the final fit
result.successful_indices
result.low_view_error_indices

How Views Are Selected ​

  1. Detection. The target is detected in every image. Views where detection fails, or whose detected points are (nearly) collinear, such as a single row of ChArUco corners, are skipped, since they cannot constrain a pose. Their input indices are missing from successful_indices.
  2. Initial fit. cv::calibrateCamera runs on every detected view, giving one RMS error per view in per_view_errors.
  3. Per-view filter. Views with an error above IntrinsicOptions.per_view_error_threshold (default 1.0 px) are dropped. The remaining views are listed in low_view_error_indices.
  4. Refit. If any view was dropped, the intrinsics are fit again on the remaining views only. The returned intrinsic_matrix, distortion_coefficients and reprojection_error come from this final fit.

If fewer than 3 views are detected, or fewer than 3 pass the filter, the calibration fails with ok = False. Check detections, focus and board flatness, or relax per_view_error_threshold.

REPROJECTION ERROR IS A TRUE RMS

reprojection_error is the root-mean-square pixel error over every point of the views used in the final fit, the same quantity cv::calibrateCamera reports. Earlier Axon versions reported a value several times smaller for the same data, so compare against new runs rather than old thresholds.

IntrinsicResult ​

FieldTypeDescription
okboolFalse when detection or the solver failed, or fewer than 3 views passed per_view_error_threshold; other fields are then only partially populated.
intrinsic_matrix(3, 3) ndarrayCamera matrix from the final fit.
distortion_coefficientsndarrayDistortion coefficients from the final fit.
reprojection_errorfloatRMS reprojection error (px) over every point of the views used in the final fit (low_view_error_indices).
successful_indiceslist[int]Indices into the input image list with successful detections.
image_pointslist[ndarray]Detected image points per successful view, (N, 1, 2).
low_view_error_indiceslist[int]Positions into successful_indices whose per-view error is at or below per_view_error_threshold. The returned intrinsics are fit on exactly these views.
per_view_errorslist[float]Per-view RMS reprojection errors (px) from the initial fit over all successful views, the basis for the filter.
std_deviations_intrinsicsndarrayStandard deviations of the intrinsics from the final fit (fx, fy, cx, cy, k1, k2, p1, p2, k3, ...).
std_deviations_extrinsicsndarrayStandard deviations of the per-view extrinsics from the final fit.

To map a kept view back to an input image, index twice: images[result.successful_indices[i]] for each i in result.low_view_error_indices.

See IntrinsicCalibrator for theory and best practices, and IntrinsicCalibrator State to read back the last result.