Add cameralensmodel enum (#1126)

Preparing for future lens models like splined stereo
This commit is contained in:
Matt
2024-01-06 23:17:55 -07:00
committed by GitHub
parent bf5e8dc81b
commit 60220f38e6
3 changed files with 47 additions and 4 deletions

View File

@@ -54,6 +54,9 @@ public class CameraCalibrationCoefficients implements Releasable {
@JsonProperty("calobjectSpacing")
public final double calobjectSpacing;
@JsonProperty("lensmodel")
public final CameraLensModel lensmodel;
@JsonIgnore private final double[] intrinsicsArr = new double[9];
@JsonIgnore private final double[] distCoeffsArr = new double[5];
@@ -83,13 +86,15 @@ public class CameraCalibrationCoefficients implements Releasable {
@JsonProperty("calobjectWarp") double[] calobjectWarp,
@JsonProperty("observations") List<BoardObservation> observations,
@JsonProperty("calobjectSize") Size calobjectSize,
@JsonProperty("calobjectSpacing") double calobjectSpacing) {
@JsonProperty("calobjectSpacing") double calobjectSpacing,
@JsonProperty("lensmodel") CameraLensModel lensmodel) {
this.resolution = resolution;
this.cameraIntrinsics = cameraIntrinsics;
this.distCoeffs = distCoeffs;
this.calobjectWarp = calobjectWarp;
this.calobjectSize = calobjectSize;
this.calobjectSpacing = calobjectSpacing;
this.lensmodel = lensmodel;
// Legacy migration just to make sure that observations is at worst empty and never null
if (observations == null) {
@@ -174,7 +179,8 @@ public class CameraCalibrationCoefficients implements Releasable {
new double[0],
List.of(),
new Size(0, 0),
0);
0,
CameraLensModel.LENSMODEL_OPENCV);
}
@Override

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.photonvision.vision.calibration;
/**
* What kind of camera lens model our intrinsics are modeling. For more info see:
* https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html
* https://mrcal.secretsauce.net/lensmodels.html#org4e95788
*/
public enum CameraLensModel {
/** OpenCV[4,5,8,12]-based model */
LENSMODEL_OPENCV,
/** Mrcal steriographic lens model. See LENSMODEL_STEREOGRAPHIC in the mrcal docs */
LENSMODEL_STERIOGRAPHIC,
/**
* Mrcal splined-steriographic lens model. See LENSMODEL_SPLINED_STEREOGRAPHIC_ in the mrcal docs
*/
LENSMODEL_SPLINED_STERIOGRAPHIC
}

View File

@@ -35,6 +35,7 @@ import org.photonvision.mrcal.MrCalJNI.MrCalResult;
import org.photonvision.mrcal.MrCalJNILoader;
import org.photonvision.vision.calibration.BoardObservation;
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
import org.photonvision.vision.calibration.CameraLensModel;
import org.photonvision.vision.calibration.JsonImageMat;
import org.photonvision.vision.calibration.JsonMatOfDouble;
import org.photonvision.vision.pipe.CVPipe;
@@ -158,7 +159,8 @@ public class Calibrate3dPipe
new double[0],
observations,
new Size(params.boardWidth, params.boardHeight),
params.squareSize);
params.squareSize,
CameraLensModel.LENSMODEL_OPENCV);
}
protected CameraCalibrationCoefficients calibrateMrcal(
@@ -240,7 +242,8 @@ public class Calibrate3dPipe
new double[] {result.warp_x, result.warp_y},
observations,
new Size(params.boardWidth, params.boardHeight),
params.squareSize);
params.squareSize,
CameraLensModel.LENSMODEL_OPENCV);
}
private List<BoardObservation> createObservations(