use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F64 method transformPixelToRect.
public static Point2Transform2_F64 transformPixelToRect(CameraPinholeRadial param, DMatrixRMaj rectify) {
Point2Transform2_F64 remove_p_to_p = narrow(param).undistort_F64(true, true);
PointTransformHomography_F64 rectifyDistort = new PointTransformHomography_F64(rectify);
return new SequencePoint2Transform2_F64(remove_p_to_p, rectifyDistort);
}
use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class TestStereoProcessingBase method compute3D.
@Test
public void compute3D() {
// point being viewed
Point3D_F64 X = new Point3D_F64(-0.01, 0.1, 3);
StereoParameters param = createStereoParam(width, height);
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param.left, (DMatrixRMaj) null);
// compute the view in pixels of the point in the left and right cameras
Point2D_F64 lensLeft = new Point2D_F64();
Point2D_F64 lensRight = new Point2D_F64();
SfmTestHelper.renderPointPixel(param, X, lensLeft, lensRight);
StereoProcessingBase<GrayU8> alg = new StereoProcessingBase<>(GrayU8.class);
alg.setCalibration(param);
// Rectify the points
Point2Transform2_F64 rectLeft = RectifyImageOps.transformPixelToRect(param.left, alg.getRect1());
Point2Transform2_F64 rectRight = RectifyImageOps.transformPixelToRect(param.right, alg.getRect2());
Point2D_F64 l = new Point2D_F64();
Point2D_F64 r = new Point2D_F64();
rectLeft.compute(lensLeft.x, lensLeft.y, l);
rectRight.compute(lensRight.x, lensRight.y, r);
// make sure I rectified it correctly
assertEquals(l.y, r.y, 1);
// find point in homogeneous coordinates
Point3D_F64 found = new Point3D_F64();
alg.computeHomo3D(l.x, l.y, found);
// disparity between the two images
double disparity = l.x - r.x;
found.x /= disparity;
found.y /= disparity;
found.z /= disparity;
assertTrue(found.isIdentical(X, 0.01));
}
use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class TestStereoSparse3D method checkGeometry.
/**
* Provide perfect image processing and validate the geometry
*/
@Test
public void checkGeometry() {
Dummy disparity = new Dummy();
StereoSparse3D alg = new StereoSparse3D(disparity, GrayF32.class);
alg.setCalibration(param);
Point3D_F64 X = new Point3D_F64(0.2, -0.34, 3);
// original pixel coordinates
Point2D_F64 x1 = PerspectiveOps.renderPixel(new Se3_F64(), K1, X);
Point2D_F64 x2 = PerspectiveOps.renderPixel(param.rightToLeft.invert(null), K2, X);
Point2Transform2_F64 pixelToRect1 = RectifyImageOps.transformPixelToRect(param.left, alg.rect1);
Point2Transform2_F64 pixelToRect2 = RectifyImageOps.transformPixelToRect(param.right, alg.rect2);
// rectified coordinates
Point2D_F64 r1 = new Point2D_F64();
Point2D_F64 r2 = new Point2D_F64();
pixelToRect1.compute(x1.x, x1.y, r1);
pixelToRect2.compute(x2.x, x2.y, r2);
// compute the true disparity
disparity.d = r1.x - r2.x;
assertTrue(alg.process(x1.x, x1.y));
double x = alg.getX() / alg.getW();
double y = alg.getY() / alg.getW();
double z = alg.getZ() / alg.getW();
assertEquals(X.x, x, 1e-8);
assertEquals(X.y, y, 1e-8);
assertEquals(X.z, z, 1e-8);
}
use of boofcv.struct.distort.Point2Transform2_F64 in project narchy by automenta.
the class ExampleStereoTwoViewsOneCamera method drawInliers.
/**
* Draw inliers for debugging purposes. Need to convert from normalized to pixel coordinates.
*/
public void drawInliers(CameraPinholeRadial intrinsic, List<AssociatedPair> normalized) {
Point2Transform2_F64 n_to_p = LensDistortionOps.narrow(intrinsic).distort_F64(false, true);
List<AssociatedPair> pixels = new ArrayList<>(normalized.size());
for (AssociatedPair n : normalized) {
AssociatedPair p = new AssociatedPair();
n_to_p.compute(n.p1.x, n.p1.y, p.p1);
n_to_p.compute(n.p2.x, n.p2.y, p.p2);
pixels.add(p);
}
// display the results
assocPanel.setAssociation(pixels);
assocPanel.setImages(ConvertBufferedImage.extractBuffered(distortedPrev), ConvertBufferedImage.extractBuffered(distortedNext));
assocPanel.repaint();
assocPanel.setSize(500, 100);
}
use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class PinholeRadialToEquirectangular_F64 method setPinhole.
/**
* Specifies the pinhole camera
* @param pinhole intrinsic parameters of pinhole camera
*/
public void setPinhole(CameraPinholeRadial pinhole) {
this.pinhole = pinhole;
declareVectors(pinhole.width, pinhole.height);
// computing the 3D ray through each pixel in the pinhole camera at it's canonical
// location
Point2Transform2_F64 pixelToNormalized = new LensDistortionRadialTangential(pinhole).undistort_F64(true, false);
Point2D_F64 norm = new Point2D_F64();
for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
pixelToNormalized.compute(pixelX, pixelY, norm);
Point3D_F64 v = vectors[pixelY * pinhole.width + pixelX];
v.set(norm.x, norm.y, 1);
}
}
}
Aggregations