use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class CommonAutoCalibrationChecks method renderRotateTwoAxis.
public void renderRotateTwoAxis(CameraPinhole camera) {
List<CameraPinhole> cameras = new ArrayList<>();
for (int i = 0; i < 11; i++) {
double yaw = Math.PI * i / 9.0;
double pitch = Math.PI * i / 20.0;
Se3_F64 cameraToWorld = new Se3_F64();
ConvertRotation3D_F64.eulerToMatrix(EulerType.YZX, yaw, 0, pitch, cameraToWorld.R);
listCameraToWorld.add(cameraToWorld);
cameras.add(camera);
}
render(cameras);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearRotationSingle method perfect.
@Test
void perfect() {
CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 450, 475, 0, 0);
renderRotationOnly(intrinsic);
performTest(intrinsic);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class CommonTriangulationChecks method createScene.
public void createScene(Point4D_F64 point) {
worldPointH = point.copy();
PerspectiveOps.homogenousTo3dPositiveZ(point, Double.MAX_VALUE, 1e-16, worldPoint);
motionWorldToCamera = new ArrayList<>();
obsNorm = new ArrayList<>();
obsPixels = new ArrayList<>();
essential = new ArrayList<>();
fundamental = new ArrayList<>();
cameraMatrices = new ArrayList<>();
CameraPinhole dummyIntrinsic = new CameraPinhole(1.0, 1.0, 0.0, 0.0, 0.0, 0, 0);
for (int i = 0; i < N; i++) {
// random motion from world to frame 'i'
Se3_F64 world_to_view = new Se3_F64();
if (i > 0) {
world_to_view.getR().setTo(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, rand.nextGaussian() * 0.01, rand.nextGaussian() * 0.05, rand.nextGaussian() * 0.1, null));
world_to_view.getT().setTo(0.2 + rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.01);
}
DMatrixRMaj E = MultiViewOps.createEssential(world_to_view.getR(), world_to_view.getT(), null);
DMatrixRMaj F = MultiViewOps.createFundamental(E, intrinsic);
Point2D_F64 norm = PerspectiveOps.renderPixel(world_to_view, dummyIntrinsic, worldPointH, null);
Point2D_F64 pixel = PerspectiveOps.renderPixel(world_to_view, intrinsic, worldPointH, null);
obsNorm.add(norm);
obsPixels.add(pixel);
motionWorldToCamera.add(world_to_view);
essential.add(E);
fundamental.add(F);
cameraMatrices.add(PerspectiveOps.createCameraMatrix(world_to_view.R, world_to_view.T, K, null));
}
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class CommonThreeViewSelfCalibration method simulateScene.
protected void simulateScene(double noiseSigma) {
List<CameraPinhole> cameras = BoofMiscOps.asList(cameraA, cameraB, cameraC);
cloud = new ArrayList<>();
observationsN = new ArrayList<>();
observations3 = new ArrayList<>();
observations2 = new ArrayList<>();
projective = new ArrayList<>();
cloud = UtilPoint3D_F64.random(-1, 1, numFeatures, rand);
BoofMiscOps.forIdx(list_world_to_cameras, (idx, world_to_camera) -> {
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(cameras.get(idx), (DMatrixRMaj) null);
projective.add(PerspectiveOps.createCameraMatrix(world_to_camera.R, world_to_camera.T, K, null));
});
for (Point3D_F64 X : cloud) {
AssociatedTriple a = new AssociatedTriple();
PerspectiveOps.renderPixel(list_world_to_cameras.get(0), cameraA, X, a.p1);
PerspectiveOps.renderPixel(list_world_to_cameras.get(1), cameraB, X, a.p2);
PerspectiveOps.renderPixel(list_world_to_cameras.get(2), cameraC, X, a.p3);
a.p1.x += rand.nextGaussian() * noiseSigma;
a.p1.y += rand.nextGaussian() * noiseSigma;
a.p2.x += rand.nextGaussian() * noiseSigma;
a.p2.y += rand.nextGaussian() * noiseSigma;
a.p3.x += rand.nextGaussian() * noiseSigma;
a.p3.y += rand.nextGaussian() * noiseSigma;
observations3.add(a);
observations2.add(new AssociatedPair(a.p1, a.p2));
observationsN.add(new AssociatedTupleN(a.p1, a.p2, a.p3));
}
// When input is noisy so will the trifocal tensor be
Estimate1ofTrifocalTensor estimator = FactoryMultiView.trifocal_1(null);
estimator.process(observations3, tensor);
// The method of creating a trifocal tensor was found to cause a unit test to fail due to numerical instability
// other less sensitive methods did pass using it though
// MultiViewOps.createTrifocal(projective.get(0),projective.get(1),projective.get(2),tensor);
MultiViewOps.trifocalToCameraMatrices(tensor, P2, P3);
MultiViewOps.trifocalToFundamental(tensor, F21, F31);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestRefineDualQuadraticAlgebraicError method setState.
private void setState(RefineDualQuadraticAlgebraicError alg, List<CameraPinhole> noisy, double px, double py, double pz) {
alg.initialize(noisy.size(), listP.size());
for (int i = 0; i < listP.size(); i++) {
alg.setProjective(i, listP.get(i));
}
for (int i = 0; i < noisy.size(); i++) {
CameraPinhole c = noisy.get(i);
alg.setCamera(i, c.fx, c.cx, c.cy, c.fy / c.fx);
}
alg.setPlaneAtInfinity(px, py, pz);
if (listP.size() == noisy.size()) {
for (int i = 0; i < listP.size(); i++) {
alg.setViewToCamera(i, i);
}
} else {
for (int i = 0; i < listP.size(); i++) {
alg.setViewToCamera(i, 0);
}
}
}
Aggregations