use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class MonocularPlaneVisualOdometryScaleInput method setCalibration.
@Override
public void setCalibration(MonoPlaneParameters param) {
scaleParameter.intrinsic = new CameraPinholeRadial(param.intrinsic);
scaleParameter.planeToCamera = param.planeToCamera.copy();
PerspectiveOps.scaleIntrinsic(scaleParameter.intrinsic, scaleFactor);
scaled.reshape(scaleParameter.intrinsic.width, scaleParameter.intrinsic.height);
alg.setCalibration(scaleParameter);
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class VisualizeSquareBinaryFiducial method process.
public void process(String nameImage, String nameIntrinsic) {
CameraPinholeRadial intrinsic = nameIntrinsic == null ? null : (CameraPinholeRadial) CalibrationIO.load(nameIntrinsic);
GrayF32 input = UtilImageIO.loadImage(nameImage, GrayF32.class);
GrayF32 undistorted = new GrayF32(input.width, input.height);
InputToBinary<GrayF32> inputToBinary = FactoryThresholdBinary.globalOtsu(0, 255, true, GrayF32.class);
Detector detector = new Detector(gridWidth, borderWidth, inputToBinary);
detector.setLengthSide(0.1);
if (intrinsic != null) {
CameraPinholeRadial paramUndist = new CameraPinholeRadial();
ImageDistort<GrayF32, GrayF32> undistorter = LensDistortionOps.changeCameraModel(AdjustmentType.EXPAND, BorderType.EXTENDED, intrinsic, new CameraPinhole(intrinsic), paramUndist, ImageType.single(GrayF32.class));
detector.configure(new LensDistortionRadialTangential(paramUndist), paramUndist.width, paramUndist.height, false);
undistorter.apply(input, undistorted);
detector.process(undistorted);
} else {
detector.process(input);
}
System.out.println("Total Found: " + detector.squares.size());
FastQueue<FoundFiducial> fiducials = detector.getFound();
int N = Math.min(20, detector.squares.size());
ListDisplayPanel squares = new ListDisplayPanel();
for (int i = 0; i < N; i++) {
squares.addImage(VisualizeBinaryData.renderBinary(detector.squares.get(i), false, null), " " + i);
squares.addImage(ConvertBufferedImage.convertTo(detector.squaresGray.get(i), null), " " + i);
}
BufferedImage output = new BufferedImage(input.width, input.height, BufferedImage.TYPE_INT_RGB);
ConvertBufferedImage.convertTo(input, output);
Graphics2D g2 = output.createGraphics();
g2.setColor(Color.RED);
g2.setStroke(new BasicStroke(2));
for (int i = 0; i < N; i++) {
VisualizeShapes.drawArrowSubPixel(fiducials.get(i).distortedPixels, 3, 1, g2);
}
ShowImages.showWindow(output, "Binary", true);
ShowImages.showWindow(squares, "Candidates", true);
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class ExampleMultiviewSceneReconstruction method main.
public static void main(String[] args) {
String directory = UtilIO.pathExample("sfm/chair");
CameraPinholeRadial intrinsic = CalibrationIO.load(new File(directory, "/intrinsic_DSC-HX5_3648x2736_to_640x480.yaml"));
List<BufferedImage> images = UtilImageIO.loadImages(directory, ".*jpg");
ExampleMultiviewSceneReconstruction example = new ExampleMultiviewSceneReconstruction();
long before = System.currentTimeMillis();
example.process(intrinsic, images);
long after = System.currentTimeMillis();
System.out.println("Elapsed time " + (after - before) / 1000.0 + " (s)");
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class TestZhang99OptimizationJacobian method compareToNumerical.
private void compareToNumerical(boolean assumeZeroSkew, boolean includeTangential) {
Zhang99AllParam param = GenericCalibrationGrid.createStandardParam(TestPinholeCalibrationZhang99.createStandard(assumeZeroSkew, includeTangential, 2, rand), 3, rand);
// give it larger values that will generate a larger derivative and pass the unit test
CameraPinholeRadial p = param.getIntrinsic().getCameraModel();
p.radial[0] = 0.2;
p.radial[1] = 0.25;
p.t1 = 0.05;
p.t2 = 0.07;
List<Point2D_F64> gridPts = CalibrationDetectorSquareGrid.createLayout(3, 2, 30, 30);
List<CalibrationObservation> observations = new ArrayList<>();
for (int i = 0; i < param.views.length; i++) {
observations.add(estimate(param, param.views[i], gridPts));
}
if (partial) {
for (int i = 0; i < observations.size(); i++) {
CalibrationObservation c = observations.get(i);
for (int j = 0; j < 5; j++) {
c.points.remove(3 * i);
}
}
}
double[] dataParam = new double[param.numParameters()];
param.convertToParam(dataParam);
Zhang99OptimizationFunction func = new Zhang99OptimizationFunction(param.copy(), gridPts, observations);
Zhang99OptimizationJacobian alg = new Zhang99OptimizationJacobian((CalibParamPinholeRadial) param.getIntrinsic(), observations, gridPts);
// Why does the tolerance need to be so crude? Is there a fundamental reason for this?
double tol = includeTangential ? 0.05 : 0.01;
// DerivativeChecker.jacobianPrintR(func, alg, dataParam, tol);
assertTrue(DerivativeChecker.jacobianR(func, alg, dataParam, tol));
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class GenericQrCodeDetectorChecks method rotation.
/**
* See if a clear well defined qr code can be detected while rating
*/
@Test
public void rotation() {
QrCodeDetector<GrayF32> detector = createDetector();
CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("calib/pinhole_radial.yaml"));
SimulatePlanarWorld simulator = new SimulatePlanarWorld();
simulator.setCamera(model);
simulator.resetScene();
Se3_F64 markerToWorld = new Se3_F64();
simulator.addTarget(markerToWorld, simulatedTargetWidth, generateMarker());
markerToWorld.T.set(0, 0, 0.5);
for (int i = 0; i < 30; i++) {
double roll = 2 * Math.PI * i / 30.0;
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, 0, roll, markerToWorld.R);
renderAndCheck(detector, simulator);
}
}
Aggregations