use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class CommonTriangulationChecks method createScene.
public void createScene() {
worldPoint = new Point3D_F64(0.1, -0.2, 4);
motionWorldToCamera = new ArrayList<>();
obsPts = new ArrayList<>();
essential = new ArrayList<>();
Point3D_F64 cameraPoint = new Point3D_F64();
for (int i = 0; i < N; i++) {
// random motion from world to frame 'i'
Se3_F64 tranWtoI = new Se3_F64();
if (i > 0) {
tranWtoI.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, rand.nextGaussian() * 0.01, rand.nextGaussian() * 0.05, rand.nextGaussian() * 0.1, null));
tranWtoI.getT().set(0.2 + rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.01);
}
DMatrixRMaj E = MultiViewOps.createEssential(tranWtoI.getR(), tranWtoI.getT());
SePointOps_F64.transform(tranWtoI, worldPoint, cameraPoint);
Point2D_F64 o = new Point2D_F64(cameraPoint.x / cameraPoint.z, cameraPoint.y / cameraPoint.z);
obsPts.add(o);
motionWorldToCamera.add(tranWtoI);
essential.add(E);
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestPixelDepthLinear method depth2View.
@Test
public void depth2View() {
// define the camera's motion
Se3_F64 motion1 = new Se3_F64();
motion1.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
motion1.getT().set(0.1, -0.1, 0.01);
// compute the point's location in each camera's view
Point3D_F64 A = new Point3D_F64(2, 3, 2);
Point3D_F64 B = SePointOps_F64.transform(motion1, A, null);
// projected points
Point2D_F64 x1 = new Point2D_F64(A.x / A.z, A.y / A.z);
Point2D_F64 x2 = new Point2D_F64(B.x / B.z, B.y / B.z);
PixelDepthLinear alg = new PixelDepthLinear();
double depth = alg.depth2View(x1, x2, motion1);
// see if the origin point was recomputed
assertEquals(x1.x * depth, A.x, 1e-8);
assertEquals(x1.y * depth, A.y, 1e-8);
assertEquals(depth, A.z, 1e-8);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestPixelDepthLinear method depthNView.
@Test
public void depthNView() {
// define the camera's motion
Se3_F64 motion1 = new Se3_F64();
motion1.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
motion1.getT().set(0.1, -0.1, 0.01);
Se3_F64 motion2 = new Se3_F64();
motion2.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, -0.15, -0.3, 0.08, null));
motion2.getT().set(-0.2, -0.15, 0.2);
// compute the point's location in each camera's view
Point3D_F64 A = new Point3D_F64(2, 3, 2);
Point3D_F64 B = SePointOps_F64.transform(motion1, A, null);
Point3D_F64 C = SePointOps_F64.transform(motion2, A, null);
// projected points
Point2D_F64 x1 = new Point2D_F64(A.x / A.z, A.y / A.z);
Point2D_F64 x2 = new Point2D_F64(B.x / B.z, B.y / B.z);
Point2D_F64 x3 = new Point2D_F64(C.x / C.z, C.y / C.z);
// setup data structures
List<Se3_F64> listMotion = new ArrayList<>();
List<Point2D_F64> listPoint = new ArrayList<>();
listMotion.add(motion1);
listMotion.add(motion2);
listPoint.add(x1);
listPoint.add(x2);
listPoint.add(x3);
PixelDepthLinear alg = new PixelDepthLinear();
double depth = alg.depthNView(listPoint, listMotion);
// see if the origin point was recomputed
assertEquals(x1.x * depth, A.x, 1e-8);
assertEquals(x1.y * depth, A.y, 1e-8);
assertEquals(depth, A.z, 1e-8);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class CommonHomographyInducedPlane method checkHomography.
public void checkHomography(DMatrixRMaj H) {
Point2D_F64 found = new Point2D_F64();
GeometryMath_F64.mult(H, p4.p1, found);
assertTrue(found.isIdentical(p4.p2, 1e-8));
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestHomographyDirectLinearTransform method checkHomography.
/**
* Create a set of points perfectly on a plane and provide perfect observations of them
*
* @param N Number of observed points.
* @param isPixels Pixel or calibrated coordinates
* @param alg Algorithm being evaluated
*/
private void checkHomography(int N, boolean isPixels, HomographyDirectLinearTransform alg) {
createScene(N, isPixels);
// compute essential
assertTrue(alg.process(pairs, solution));
// validate by testing essential properties
// sanity check, F is not zero
assertTrue(NormOps_DDRM.normF(solution) > 0.001);
// see if it follows the epipolar constraint
for (AssociatedPair p : pairs) {
Point2D_F64 a = GeometryMath_F64.mult(solution, p.p1, new Point2D_F64());
double diff = a.distance(p.p2);
assertEquals(0, diff, 1e-8);
}
}
Aggregations