Class CalibrationManager#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

  • public QObject

Class Documentation#

class CalibrationManager : public QObject#

Runs a full checkerboard calibration pipeline using OpenCV.

Checkerboard calibration determines the intrinsic camera parameters (focal length, principal point, and lens distortion coefficients) needed to undistort frames and to triangulate 3-D positions across cameras.

Requires MOSAIC_HAVE_OPENCVis_available() returns false otherwise.

See also

CalibrationData, VideoFrame, CalibrationW

Workflow
CalibrationManager cal;
cal.set_board({9, 6, 25.0});          // 9×6 inner corners, 25 mm squares

connect(&cal, &CalibrationManager::corners_detected, this,
        [](int viewIdx, bool found, QImage preview) {
            // update a preview label in the UI
        });
connect(&cal, &CalibrationManager::calibration_done, this,
        [&](double rms, bool ok) {
            if (ok) settings.video.cameras[0].calibration = cal.result();
        });

// Feed frames as they arrive from VideoGrabber:
cal.feed_frame(frame);   // repeat until view_count() >= 10

cal.calibrate();         // async — emits calibration_done() when done

Public Functions

explicit CalibrationManager(QObject *parent = nullptr)#
~CalibrationManager() override#
void set_board(const BoardSpec &spec)#

Sets the checkerboard geometry used for detection and calibration.

Call before the first feed_frame(). Changing the spec after capturing views requires clear_views() to discard incompatible data.

Parameters:

spec – Board geometry (cols, rows, square size in mm).

bool feed_frame(const VideoFrame &frame)#

Runs corner detection on a single frame.

This is the main ingestion method. Call it each time a new frame arrives from VideoGrabber (or whenever the user clicks “Capture”). The method is synchronous and may take a few milliseconds per frame.

Emits corners_detected() with a preview image regardless of whether corners were found.

Parameters:

frame – A valid VideoFrame in BGR8 format.

Returns:

true if a complete checkerboard was detected and the view was accepted into the calibration set.

int view_count() const#
Returns:

The number of successfully detected views accumulated so far. At least 10 views are recommended before calling calibrate().

void clear_views()#

Clears all accumulated views and the last calibration result.

void calibrate()#

Runs cv::calibrateCamera() on a background thread.

Emits calibration_started(), calibration_progress(), and calibration_done() in sequence. The caller must wait for calibration_done() before reading result().

Requires at least 5 accepted views (10+ recommended).

CalibrationData result() const#
Returns:

The most recent calibration result. Only valid after calibration_done() has been emitted with success = true.

bool has_result() const#
Returns:

true if a valid calibration result is available.

Signals

void corners_detected(int viewIndex, bool found, QImage preview)#

Emitted after each call to feed_frame().

Parameters:
  • viewIndex – Running index of this detection attempt.

  • foundtrue if all corners were detected and the view was accepted.

  • preview – BGR frame with detected corners drawn on it (RGB for Qt).

void calibration_started()#

Emitted when calibrate() starts its background thread.

void calibration_progress(int percentage)#
Parameters:

percentage – Rough completion percentage (0–100).

void calibration_done(double rmsError, bool success)#

Emitted when calibration finishes.

Parameters:
  • rmsError – Mean reprojection error in pixels. Negative on failure.

  • successtrue if calibration converged successfully.

Public Static Functions

static bool is_available()#
Returns:

true when OpenCV is compiled in (MOSAIC_HAVE_OPENCV is defined).

struct BoardSpec#

Checkerboard geometry parameters.

Public Members

int cols = 9#

Number of inner corner columns.

int rows = 6#

Number of inner corner rows.

double squareSizeMm = 25.0#

Physical side length of one square, in mm.