Removed hack for calibration boards in samples and tutorials.

This commit is contained in:
Alexander Smorkalov 2025-07-23 17:24:44 +03:00
parent 32bd8c9632
commit ac9d0e0d0d
2 changed files with 20 additions and 4 deletions

View File

@ -178,8 +178,19 @@ static bool runCalibration( vector<vector<Point2f> > imagePoints,
vector<vector<Point3f> > objectPoints(1);
calcChessboardCorners(boardSize, squareSize, objectPoints[0], patternType);
int offset = patternType != CHARUCOBOARD ? boardSize.width - 1: boardSize.width - 2;
objectPoints[0][offset].x = objectPoints[0][0].x + grid_width;
// Board imperfectness correction introduced in PR #12772
// The correction does not make sense for asymmetric and assymetric circles grids
if (patternType == CHESSBOARD)
{
int offset = boardSize.width - 1;
objectPoints[0][offset].x = objectPoints[0][0].x + grid_width;
}
else if (patternType == CHARUCOBOARD)
{
int offset = boardSize.width - 2;
objectPoints[0][offset].x = objectPoints[0][0].x + grid_width;
}
newObjPoints = objectPoints[0];
objectPoints.resize(imagePoints.size(),objectPoints[0]);

View File

@ -640,10 +640,15 @@ static bool runCalibration( Settings& s, Size& imageSize, Mat& cameraMatrix, Mat
vector<vector<Point3f> > objectPoints(1);
calcBoardCornerPositions(s.boardSize, s.squareSize, objectPoints[0], s.calibrationPattern);
if (s.calibrationPattern == Settings::Pattern::CHARUCOBOARD) {
// Board imperfectness correction introduced in PR #12772
// The correction does not make sense for asymmetric and assymetric circles grids
if (s.calibrationPattern == Settings::Pattern::CHARUCOBOARD)
{
objectPoints[0][s.boardSize.width - 2].x = objectPoints[0][0].x + grid_width;
}
else {
else if (s.calibrationPattern != Settings::Pattern::CHESSBOARD)
{
objectPoints[0][s.boardSize.width - 1].x = objectPoints[0][0].x + grid_width;
}
newObjPoints = objectPoints[0];