use of georegression.struct.point.Point4D_F64 in project BoofCV by lessthanoptimal.
the class GeneralCheckTriangulateRefineProjective method perfectInput.
@Test
void perfectInput() {
createScene();
Point4D_F64 initial = convertH(worldPoint);
Point4D_F64 found = new Point4D_F64();
triangulate(obsPixels, cameraMatrices, initial, found);
assertEquals(worldPoint.x, convertH(found).x, 1e-8);
}
use of georegression.struct.point.Point4D_F64 in project BoofCV by lessthanoptimal.
the class GeneralCheckTriangulate2ViewsProjective method triangulate.
/**
* See if it can triangulate perfect observations
*/
@Test
void triangulate() {
Point3D_F64 world = new Point3D_F64(0.5, -0.1, 4);
Se3_F64 worldToA = new Se3_F64();
Se3_F64 worldToB = new Se3_F64();
worldToB.getT().setTo(2, 0.1, -0.5);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, 0.05, 0, worldToB.getR());
Point3D_F64 pointA = SePointOps_F64.transform(worldToA, world, null);
Point2D_F64 viewA = new Point2D_F64();
viewA.x = pointA.x / pointA.z;
viewA.y = pointA.y / pointA.z;
Point3D_F64 pointB = SePointOps_F64.transform(worldToB, world, null);
Point2D_F64 viewB = new Point2D_F64();
viewB.x = pointB.x / pointB.z;
viewB.y = pointB.y / pointB.z;
Triangulate2ViewsProjective alg = createAlg();
Point4D_F64 found = new Point4D_F64();
DMatrixRMaj P1 = new DMatrixRMaj(3, 4);
CommonOps_DDRM.setIdentity(P1);
DMatrixRMaj P2 = PerspectiveOps.convertToMatrix(worldToB, null);
alg.triangulate(viewA, viewB, P1, P2, found);
assertEquals(found.x / found.w, world.x, 1e-8);
assertEquals(found.y / found.w, world.y, 1e-8);
assertEquals(found.z / found.w, world.z, 1e-8);
}
use of georegression.struct.point.Point4D_F64 in project BoofCV by lessthanoptimal.
the class TestPruneStructureFromSceneProjective method createRestOfScene.
private void createRestOfScene() {
observations = new SceneObservations();
observations.initialize(structure.views.size);
Point4D_F64 X = new Point4D_F64();
Point3D_F64 xx = new Point3D_F64();
Point2D_F64 x = new Point2D_F64();
for (int viewIdx = 0; viewIdx < structure.views.size; viewIdx++) {
SceneStructureProjective.View vs = structure.views.data[viewIdx];
DMatrixRMaj P = vs.worldToView;
int width = vs.width;
int height = vs.height;
SceneObservations.View vo = observations.views.data[viewIdx];
for (int pointIdx = 0; pointIdx < structure.points.size; pointIdx++) {
SceneStructureCommon.Point ps = structure.points.data[pointIdx];
ps.get(X);
GeometryMath_F64.mult(P, X, xx);
// behind the camera. I think...
if (Math.signum(X.w) * xx.z < 0)
continue;
x.x = xx.x / xx.z;
x.y = xx.y / xx.z;
if (x.x >= 0 && x.x <= width && x.y >= 0 && x.y <= height) {
ps.views.add(viewIdx);
vo.add(pointIdx, (float) x.x, (float) x.y);
}
}
}
}
use of georegression.struct.point.Point4D_F64 in project BoofCV by lessthanoptimal.
the class TestCompatibleProjectiveHomography method checkWorldPointsH.
private void checkWorldPointsH(DMatrixRMaj H, double tol) {
Point4D_F64 found = new Point4D_F64();
for (int i = 0; i < triples.size(); i++) {
Point4D_F64 X = worldPts.get(i);
Point4D_F64 Xb = sceneB.get(i);
GeometryMath_F64.mult(H, Xb, found);
X.scale(1.0 / X.norm());
found.scale(1.0 / found.norm());
double error = X.distance(found);
found.scale(-1);
error = Math.min(error, X.distance(found));
assertEquals(0.0, error, tol);
}
}
use of georegression.struct.point.Point4D_F64 in project BoofCV by lessthanoptimal.
the class CommonHomographyChecks method createRandomPlaneH.
/**
* Create a random set of points which line on the x-y plane at distance 'd'
*/
public static List<Point4D_F64> createRandomPlaneH(Random rand, double d, int N) {
List<Point4D_F64> ret = new ArrayList<>();
for (int i = 0; i < N; i++) {
double x = (rand.nextDouble() - 0.5) * 2;
double y = (rand.nextDouble() - 0.5) * 2;
// make it more interesting by not having the same W for all the point
double scale = rand.nextDouble() + 0.1;
if (rand.nextBoolean())
scale *= -1;
ret.add(new Point4D_F64(scale * x, scale * y, scale * d, scale));
}
return ret;
}
Aggregations