use of boofcv.struct.distort.PixelTransform in project BoofCV by lessthanoptimal.
the class TestDepthSparse3D method basicTest.
@Test
void basicTest() {
GrayU16 depth = new GrayU16(w, h);
depth.set(5, 6, 1000);
CameraPinholeBrown param = new CameraPinholeBrown(1, 1, 0, 5, 10, w, h).fsetRadial(0, 0);
PixelTransform<Point2D_F32> v2d = new PixelTransform<Point2D_F32>() {
@Override
public void compute(int x, int y, Point2D_F32 output) {
output.x = x + 1;
output.y = y + 2;
}
@Override
public PixelTransform<Point2D_F32> copyConcurrent() {
return null;
}
};
DepthSparse3D<GrayU16> alg = new DepthSparse3D.I<>(2.1);
alg.configure(LensDistortionFactory.narrow(param), v2d);
alg.setDepthImage(depth);
assertTrue(alg.process(4, 4));
Point3D_F64 found = alg.getWorldPt();
Point2D_F64 norm = new Point2D_F64();
PerspectiveOps.convertPixelToNorm(param, new Point2D_F64(4, 4), norm);
double z = 1000 * 2.1;
assertEquals(z, found.z, 1e-8);
assertEquals(norm.x * z, found.x, 1e-8);
assertEquals(norm.y * z, found.y, 1e-8);
}
use of boofcv.struct.distort.PixelTransform in project BoofCV by lessthanoptimal.
the class FactoryStitchingTransform method createAffine_F64.
public static StitchingTransform<Affine2D_F64> createAffine_F64() {
return new StitchingTransform<>() {
final Affine2D_F32 input_F32 = new Affine2D_F32();
@Override
public PixelTransform<Point2D_F32> convertPixel(Affine2D_F64 input, @Nullable PixelTransform<Point2D_F32> output) {
ConvertFloatType.convert(input, input_F32);
if (output != null) {
((PixelTransformAffine_F32) output).setTo(input_F32);
} else {
PixelTransformAffine_F32 a = new PixelTransformAffine_F32();
a.setTo(input_F32);
output = a;
}
return output;
}
@Override
public Homography2D_F64 convertH(Affine2D_F64 input, @Nullable Homography2D_F64 output) {
if (output == null)
output = new Homography2D_F64();
output.setTo(input.a11, input.a12, input.tx, input.a21, input.a22, input.ty, 0, 0, 1);
return output;
}
};
}
Aggregations