use of boofcv.alg.distort.pinhole.LensDistortionPinhole in project BoofCV by lessthanoptimal.
the class TestVisOdomBundleAdjustment method createPerfectScene.
private void createPerfectScene(VisOdomBundleAdjustment<BTrack> vsba) {
vsba.reset();
List<Point3D_F64> cloud = UtilPoint3D_F64.random(new Point3D_F64(0, 0, 1.5), -1.5, 1.5, -0.5, 0.5, -0.2, 0.2, 500, rand);
LensDistortionPinhole distortion = new LensDistortionPinhole(pinhole);
Point2Transform2_F64 n2n = distortion.distort_F64(false, false);
vsba.addCamera(pinhole);
// 3D point in view reference frame
Point3D_F64 Xv = new Point3D_F64();
// normalized image coordinate
Point2D_F64 n = new Point2D_F64();
// pixel coordinate
Point2D_F64 p = new Point2D_F64();
for (int i = 0; i < cloud.size(); i++) {
Point3D_F64 X = cloud.get(i);
vsba.addTrack(X.x, X.y, X.z, 1.0).hasBeenInlier = true;
}
for (int viewidx = 0; viewidx < 5; viewidx++) {
BFrame frame = vsba.addFrame(viewidx);
frame.frame_to_world.setTo(-1 + 2.0 * viewidx / 4.0, 0, 0, EulerType.XYZ, rand.nextGaussian() * 0.1, 0, 0);
// add visible features to each view
for (int i = 0; i < cloud.size(); i++) {
Point3D_F64 X = cloud.get(i);
frame.frame_to_world.transformReverse(X, Xv);
if (Xv.z <= 0)
continue;
n2n.compute(Xv.x / Xv.z, Xv.y / Xv.z, n);
PerspectiveOps.convertNormToPixel(pinhole, n.x, n.y, p);
if (!pinhole.isInside(p.x, p.y))
continue;
BTrack track = vsba.tracks.get(i);
vsba.addObservation(frame, track, p.x, p.y);
}
}
}
use of boofcv.alg.distort.pinhole.LensDistortionPinhole in project BoofCV by lessthanoptimal.
the class TestResolveSceneScaleAmbiguity method createPixelToNorm.
private List<Point2Transform2_F64> createPixelToNorm(int... viewIndexes) {
var ret = new ArrayList<Point2Transform2_F64>();
for (int viewIdx : viewIndexes) {
var pixel_to_norm = new LensDistortionPinhole(listCameras.get(viewIdx)).distort_F64(true, false);
ret.add(pixel_to_norm);
}
return ret;
}
Aggregations