use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.
the class ImplPerspectiveOps_F32 method renderPixel.
public static Point2D_F32 renderPixel(Se3_F32 worldToCamera, FMatrixRMaj K, Point3D_F32 X) {
Point3D_F32 X_cam = new Point3D_F32();
SePointOps_F32.transform(worldToCamera, X, X_cam);
// see if it's behind the camera
if (X_cam.z <= 0)
return null;
Point2D_F32 norm = new Point2D_F32(X_cam.x / X_cam.z, X_cam.y / X_cam.z);
if (K == null)
return norm;
// convert into pixel coordinates
return GeometryMath_F32.mult(K, norm, norm);
}
use of georegression.struct.point.Point3D_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 camMask Binary mask with invalid pixels marked as not zero. Pixels are in camera image frame.
*/
public void addCamera(Se3_F32 cameraToCommon, LensDistortionWideFOV factory, GrayU8 camMask) {
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);
PixelTransformCached_F32 transformEquiToCam = new PixelTransformCached_F32(equiWidth, equHeight, new PointToPixelTransform_F32(equiToCamera));
int width = camMask.width;
int height = camMask.height;
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);
if (UtilEjml.isUncountable(p2.x) || UtilEjml.isUncountable(p2.y)) {
// can't have it be an invalid number in the cache, but had to be invalid so that the mask
// could be set to zero. So set it to some valid value that won't cause it to blow up
transformEquiToCam.getPixel(col, row).set(-1, -1);
continue;
}
int camX = (int) (p2.x + 0.5f);
int camY = (int) (p2.y + 0.5f);
if (camX < 0 || camY < 0 || camX >= width || camY >= height)
continue;
if (camMask.unsafe_get(camX, camY) == 1) {
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));
}
use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.
the class DisplayFisheyeCalibrationPanel method setPinholeCenter.
public void setPinholeCenter(double pixelX, double pixelY) {
this.pixelX = pixelX;
this.pixelY = pixelY;
Point3D_F32 norm = new Point3D_F32();
fisheyeDistort.undistortPtoS_F32().compute((float) pixelX, (float) pixelY, norm);
Rodrigues_F32 rotation = new Rodrigues_F32();
Vector3D_F32 canonical = new Vector3D_F32(0, 0, 1);
rotation.theta = UtilVector3D_F32.acute(new Vector3D_F32(norm), canonical);
GeometryMath_F32.cross(canonical, norm, rotation.unitAxisRotation);
rotation.unitAxisRotation.normalize();
FMatrixRMaj R = ConvertRotation3D_F32.rodriguesToMatrix(rotation, null);
distorter.setRotationWideToNarrow(R);
distortImage.setModel(new PointToPixelTransform_F32(distorter));
}
use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.
the class TestPinholeRadialToEquirectangular_F32 method assertPointing.
private void assertPointing(PinholeRadialToEquirectangular_F32 alg, int x, int y, float nx, float ny, float nz) {
EquirectangularTools_F32 tools = new EquirectangularTools_F32();
tools.configure(equiWidth, equiHeight);
Point3D_F32 n = new Point3D_F32();
alg.compute(x, y);
tools.equiToNormFV(alg.distX, alg.distY, n);
assertEquals(nx, n.x, GrlConstants.TEST_F32);
assertEquals(ny, n.y, GrlConstants.TEST_F32);
assertEquals(nz, n.z, GrlConstants.TEST_F32);
}
use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.
the class TestPinholeToEquirectangular_F32 method assertPointing.
private void assertPointing(PinholeToEquirectangular_F32 alg, int x, int y, float nx, float ny, float nz) {
EquirectangularTools_F32 tools = new EquirectangularTools_F32();
tools.configure(equiWidth, equiHeight);
Point3D_F32 n = new Point3D_F32();
alg.compute(x, y);
tools.equiToNormFV(alg.distX, alg.distY, n);
assertEquals(nx, n.x, GrlConstants.TEST_F32);
assertEquals(ny, n.y, GrlConstants.TEST_F32);
assertEquals(nz, n.z, GrlConstants.TEST_F32);
}
Aggregations