use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class ImplPerspectiveOps_F32 method renderPixel.
public static Point2D_F32 renderPixel(FMatrixRMaj worldToCamera, Point3D_F32 X) {
FMatrixRMaj P = worldToCamera;
float x = P.data[0] * X.x + P.data[1] * X.y + P.data[2] * X.z + P.data[3];
float y = P.data[4] * X.x + P.data[5] * X.y + P.data[6] * X.z + P.data[7];
float z = P.data[8] * X.x + P.data[9] * X.y + P.data[10] * X.z + P.data[11];
Point2D_F32 pixel = new Point2D_F32();
pixel.x = x / z;
pixel.y = y / z;
return pixel;
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class ImplPerspectiveOps_F32 method convertPixelToNorm.
public static Point2D_F32 convertPixelToNorm(CameraModel param, Point2D_F32 pixel, Point2D_F32 norm) {
if (norm == null)
norm = new Point2D_F32();
Point2Transform2_F32 pixelToNorm = LensDistortionOps.narrow(param).distort_F32(true, false);
pixelToNorm.compute(pixel.x, pixel.y, norm);
return norm;
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class ImplPerspectiveOps_F32 method convertNormToPixel.
public static Point2D_F32 convertNormToPixel(CameraModel param, float x, float y, Point2D_F32 pixel) {
if (pixel == null)
pixel = new Point2D_F32();
Point2Transform2_F32 normToPixel = LensDistortionOps.narrow(param).distort_F32(false, true);
normToPixel.compute(x, y, pixel);
return pixel;
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestRectifyImageOps method transform_PixelToRect_and_RectToPixel_F32.
/**
* Transforms and then performs the inverse transform to distorted rectified pixel
*/
@Test
public void transform_PixelToRect_and_RectToPixel_F32() {
CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
FMatrixRMaj rect = new FMatrixRMaj(3, 3, true, 1.1f, 0, 0, 0, 2, 0, 0.1f, 0, 3);
Point2Transform2_F32 forward = RectifyImageOps.transformPixelToRect(param, rect);
Point2Transform2_F32 inverse = RectifyImageOps.transformRectToPixel(param, rect);
float x = 20, y = 30;
Point2D_F32 out = new Point2D_F32();
forward.compute(x, y, out);
// sanity check
assertTrue(Math.abs(x - out.x) > 1e-4);
assertTrue(Math.abs(y - out.y) > 1e-4);
inverse.compute(out.x, out.y, out);
assertEquals(x, out.x, 1e-4);
assertEquals(y, out.y, 1e-4);
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestUniOmniStoP_F32 method worldIsImageCenter.
/**
* A point in the world center should appear in the image center
*/
@Test
public void worldIsImageCenter() {
CameraUniversalOmni model = createModel(0.5f);
UniOmniStoP_F32 alg = new UniOmniStoP_F32();
alg.setModel(model);
Point2D_F32 found = new Point2D_F32(10, 10);
// directly forward on unit sphere
alg.compute(0, 0, 1, found);
assertEquals(320, found.x, GrlConstants.TEST_F32);
assertEquals(240, found.y, GrlConstants.TEST_F32);
}
Aggregations