use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestSequencePointTransform_F32 method simpleTest.
@Test
public void simpleTest() {
Point2Transform2_F32 a = new Point2Transform2_F32() {
@Override
public void compute(float x, float y, Point2D_F32 out) {
out.x = x + 1;
out.y = y + 2;
}
};
SequencePoint2Transform2_F32 alg = new SequencePoint2Transform2_F32(a, a);
Point2D_F32 p = new Point2D_F32();
alg.compute(3, 4, p);
assertEquals(5, p.x, 1e-8);
assertEquals(8, p.y, 1e-8);
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class CreateSyntheticOverheadView method configure.
/**
* Specifies camera configurations.
* @param intrinsic Intrinsic camera parameters
* @param planeToCamera Transform from the plane to the camera. This is the extrinsic parameters.
* @param centerX X-coordinate of camera center in the overhead image in world units.
* @param centerY Y-coordinate of camera center in the overhead image in world units.
* @param cellSize Size of each cell in the overhead image in world units.
* @param overheadWidth Number of columns in overhead image
* @param overheadHeight Number of rows in overhead image
*/
public void configure(CameraPinholeRadial intrinsic, Se3_F64 planeToCamera, double centerX, double centerY, double cellSize, int overheadWidth, int overheadHeight) {
this.overheadWidth = overheadWidth;
this.overheadHeight = overheadHeight;
Point2Transform2_F64 normToPixel = LensDistortionOps.narrow(intrinsic).distort_F64(false, true);
// Declare storage for precomputed pixel locations
int overheadPixels = overheadHeight * overheadWidth;
if (mapPixels == null || mapPixels.length < overheadPixels) {
mapPixels = new Point2D_F32[overheadPixels];
}
points.reset();
// -------- storage for intermediate results
Point2D_F64 pixel = new Point2D_F64();
// coordinate on the plane
Point3D_F64 pt_plane = new Point3D_F64();
// coordinate in camera reference frame
Point3D_F64 pt_cam = new Point3D_F64();
int indexOut = 0;
for (int i = 0; i < overheadHeight; i++) {
pt_plane.x = -(i * cellSize - centerY);
for (int j = 0; j < overheadWidth; j++, indexOut++) {
pt_plane.z = j * cellSize - centerX;
// plane to camera reference frame
SePointOps_F64.transform(planeToCamera, pt_plane, pt_cam);
// can't see behind the camera
if (pt_cam.z > 0) {
// compute normalized then convert to pixels
normToPixel.compute(pt_cam.x / pt_cam.z, pt_cam.y / pt_cam.z, pixel);
float x = (float) pixel.x;
float y = (float) pixel.y;
// make sure it's in the image
if (BoofMiscOps.checkInside(intrinsic.width, intrinsic.height, x, y)) {
Point2D_F32 p = points.grow();
p.set(x, y);
mapPixels[indexOut] = p;
} else {
mapPixels[indexOut] = null;
}
}
}
}
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class CreateSyntheticOverheadViewS method process.
/**
* Computes overhead view of input image. All pixels in input image are assumed to be on the ground plane.
*
* @param input (Input) Camera image.
* @param output (Output) Image containing overhead view.
*/
public void process(T input, T output) {
this.output = FactoryGImageGray.wrap(output, this.output);
interp.setImage(input);
int indexMap = 0;
for (int i = 0; i < output.height; i++) {
int indexOut = output.startIndex + i * output.stride;
for (int j = 0; j < output.width; j++, indexOut++, indexMap++) {
Point2D_F32 p = mapPixels[indexMap];
if (p != null) {
this.output.set(indexOut, interp.get(p.x, p.y));
}
}
}
}
Aggregations