Expand description
Pure-Rust port of OpenCV’s cv::findChessboardCorners (the classic
contour-based detector, not findChessboardCornersSB).
This is the largest of the OpenCV routines being replaced. It is built bottom-up:
- binarization primitives ([
binarize]) — histogram equalization (CALIB_CB_NORMALIZE_IMAGE) and adaptive-mean thresholding (CALIB_CB_ADAPTIVE_THRESH) — done, bit-exact vs OpenCV, - quad generation from contours — done, all cross-checked vs OpenCV:
contour finding (
find_contours, Suzuki-Abe), polygon approximation (approx_poly_dp, Douglas-Peucker), and the convex-4-gon area filter (find_quads, withcontour_area/is_contour_convex), - linking quads into a board graph and ordering corners — done
(synthetic tests): neighbor linking (
link_quads), connected components (connected_components), consistent corner ordering (order_all_corners), board-lattice propagation (assign_grid), and row-major inner-corner readout (ordered_inner_corners), - board validation (size, monotonicity) and corner extraction — done
(synthetic tests):
check_board_monotonyandextract_board.
The stages are wired together in find_chessboard_corners, which on the
OpenCV left*.jpg samples recovers OpenCV’s corner positions to <=0.17px on
all 13 frames. Incomplete boards
are filled at the lattice level (see extract_board). The only behavior
not replicated is OpenCV’s exact output corner order, which is pose-dependent
and not required for the pure-Rust calibrator.
The detector flags requested by the strand-braid C++ wrapper are
CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE | CALIB_CB_FAST_CHECK.
Structs§
- Contour
- A traced border.
- Linked
Quad - A quad participating in the board graph.
- Quad
- A candidate quadrilateral: four ordered corner pixels
(x, y).
Functions§
- adaptive_
threshold_ mean - Port of OpenCV
adaptiveThresholdwithADAPTIVE_THRESH_MEAN_CandTHRESH_BINARY. - approx_
poly_ dp - Approximate a polygonal curve with the Douglas–Peucker algorithm.
- assign_
grid - Propagate integer board-lattice coordinates across one connected component.
- check_
board_ monotony - Port of OpenCV
icvCheckBoardMonotony. - connected_
components - Group quads into connected components following the neighbor links. Returns each component as a list of quad indices.
- contour_
area - Polygon area via the shoelace formula, matching OpenCV
contourArea(absolute value, integer-exact for integer input). - corner_
lattice - Every lattice point referenced by at least one quad corner, mapped to its averaged position and the number of referencing quad corners.
- equalize_
hist - Port of OpenCV
equalizeHistfor 8-bit single-channel images. - extract_
board - Validate and extract a
pattern_w x pattern_hboard from a lattice-assigned connected component. - find_
chessboard_ corners - Detect a
pattern_w x pattern_h(inner corners) chessboard in a grayscale image. Returns the inner corners row-major, orNoneif no board is found. - find_
contours - Find all borders in a binary image.
- find_
quads - Extract candidate quads from contours, mirroring OpenCV’s per-contour logic
in
generateQuads: approximate withapproxPolyDPat accuracy levels 1..=7 until four vertices remain, then keep convex quads with area>= min_area. - inner_
corner_ lattice - Inner board corners with their lattice coordinates (unordered).
- is_
contour_ convex - Whether a polygon is convex, matching OpenCV
isContourConvex. - link_
quads - Build
LinkedQuads from detected quads and link neighboring corners. - order_
all_ corners - Order the corners of every quad in place.
- order_
quad_ corners - Reorder a quad’s corners into a consistent rotational order (by angle about
the centroid), permuting the
neighborslinks the same way so eachneighbors[i]still refers tocorners[i]. - ordered_
inner_ corners - Read out the inner board corners from an assigned grid, sorted row-major (by lattice row then column).
Type Aliases§
- Quad
Grid - Integer lattice coordinate of each of a quad’s four corners.