use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestRemoveRadialNtoN_F32 method checkManual.
public void checkManual(float t1, float t2) {
/**/
double[] radial = new /**/
double[] { 0.12, -0.13 };
// undisorted normalized image coordinate
Point2D_F32 undistorted = new Point2D_F32(0.1f, -0.2f);
// manually compute the distortion
float x = undistorted.x, y = undistorted.y;
float r2 = x * x + y * y;
float mag = (float) radial[0] * r2 + (float) radial[1] * r2 * r2;
// distorted normalized image coordinate
float distX = undistorted.x * (1 + mag) + 2 * t1 * x * y + t2 * (r2 + 2 * x * x);
float distY = undistorted.y * (1 + mag) + t1 * (r2 + 2 * y * y) + 2 * t2 * x * y;
RemoveRadialNtoN_F32 alg = new RemoveRadialNtoN_F32().setDistortion(radial, t1, t2);
Point2D_F32 found = new Point2D_F32();
alg.compute(distX, distY, found);
assertEquals(undistorted.x, found.x, GrlConstants.TEST_SQ_F32);
assertEquals(undistorted.y, found.y, GrlConstants.TEST_SQ_F32);
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestFlipVertical_F32 method basicTest.
@Test
public void basicTest() {
FlipVertical_F32 alg = new FlipVertical_F32(100);
Point2D_F32 found = new Point2D_F32();
alg.compute(20, 30, found);
assertEquals(20, found.x, 1e-8);
assertEquals(100 - 30 - 1, found.y, 1e-8);
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class FeatureSpatialDiversity_F32 method computeCovarince.
private void computeCovarince() {
meanX = 0;
meanY = 0;
for (int i = 0; i < norm.size; i++) {
Point2D_F32 p = norm.get(i);
meanX += p.x;
meanY += p.y;
}
meanX /= norm.size;
meanY /= norm.size;
var.a11 = var.a12 = var.a22 = 0;
for (int i = 0; i < norm.size; i++) {
Point2D_F32 p = norm.get(i);
float dx = p.x - meanX;
float dy = p.y - meanY;
var.a11 += dx * dx;
var.a12 += dx * dy;
var.a22 += dy * dy;
}
CommonOps_FDF2.divide(var, norm.size - 1);
// System.out.printf(" covar %5.2f %5.2f %5.4f\n",var.a11,var.a22, var.a12);
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class CreateSyntheticOverheadViewPL 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(Planar<T> input, Planar<T> output) {
int N = input.getNumBands();
for (int i = 0; i < N; i++) {
this.output[i] = FactoryGImageGray.wrap(output.getBand(i), this.output[i]);
interp[i].setImage(input.getBand(i));
}
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) {
for (int k = 0; k < N; k++) {
this.output[k].set(indexOut, interp[k].get(p.x, p.y));
}
}
}
}
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class MultiCameraToEquirectangular method addCamera.
/**
* Adds a camera and attempts to compute the mask from the provided distortion model. if a pixel is rendered
* outside the bounds in the input image then it is masked out. If the forwards/backwards transform is too
* different then it is masked out.
*
* @param cameraToCommon Rigid body transform from this camera to the common frame the equirectangular image
* is in
* @param factory Distortion model
* @param width Input image width
* @param height Input image height
*/
public void addCamera(Se3_F32 cameraToCommon, LensDistortionWideFOV factory, int width, int height) {
Point2Transform3_F32 p2s = factory.undistortPtoS_F32();
Point3Transform2_F32 s2p = factory.distortStoP_F32();
EquiToCamera equiToCamera = new EquiToCamera(cameraToCommon.getR(), s2p);
GrayF32 equiMask = new GrayF32(equiWidth, equHeight);
PixelTransform2_F32 transformEquiToCam = new PixelTransformCached_F32(equiWidth, equHeight, new PointToPixelTransform_F32(equiToCamera));
Point3D_F32 p3b = new Point3D_F32();
Point2D_F32 p2 = new Point2D_F32();
for (int row = 0; row < equHeight; row++) {
for (int col = 0; col < equiWidth; col++) {
equiToCamera.compute(col, row, p2);
int camX = (int) (p2.x + 0.5f);
int camY = (int) (p2.y + 0.5f);
if (Double.isNaN(p2.x) || Double.isNaN(p2.y) || camX < 0 || camY < 0 || camX >= width || camY >= height)
continue;
p2s.compute(p2.x, p2.y, p3b);
if (Double.isNaN(p3b.x) || Double.isNaN(p3b.y) || Double.isNaN(p3b.z))
continue;
double angle = UtilVector3D_F32.acute(equiToCamera.unitCam, p3b);
if (angle < maskToleranceAngle) {
equiMask.set(col, row, 1);
}
}
}
cameras.add(new Camera(equiMask, transformEquiToCam));
}
Aggregations