Search in sources :

Example 6 with Point3D_F32

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 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));
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) GrayF32(boofcv.struct.image.GrayF32) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform3_F32(boofcv.struct.distort.Point2Transform3_F32) Point3Transform2_F32(boofcv.struct.distort.Point3Transform2_F32) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32) PixelTransformCached_F32(boofcv.alg.distort.PixelTransformCached_F32)

Example 7 with Point3D_F32

use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.

the class PinholeRadialToEquirectangular_F32 method setPinhole.

/**
 * Specifies the pinhole camera
 * @param pinhole intrinsic parameters of pinhole camera
 */
public void setPinhole(CameraPinholeRadial pinhole) {
    this.pinhole = pinhole;
    declareVectors(pinhole.width, pinhole.height);
    // computing the 3D ray through each pixel in the pinhole camera at it's canonical
    // location
    Point2Transform2_F32 pixelToNormalized = new LensDistortionRadialTangential(pinhole).undistort_F32(true, false);
    Point2D_F32 norm = new Point2D_F32();
    for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
        for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
            pixelToNormalized.compute(pixelX, pixelY, norm);
            Point3D_F32 v = vectors[pixelY * pinhole.width + pixelX];
            v.set(norm.x, norm.y, 1);
        }
    }
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 8 with Point3D_F32

use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.

the class PinholeToEquirectangular_F32 method setPinhole.

/**
 * Specifies the pinhole camera
 * @param pinhole intrinsic parameters of pinhole camera
 */
public void setPinhole(CameraPinhole pinhole) {
    this.pinhole = pinhole;
    declareVectors(pinhole.width, pinhole.height);
    // computing the 3D ray through each pixel in the pinhole camera at it's canonical
    // location
    PinholePtoN_F32 pixelToNormalized = new PinholePtoN_F32();
    pixelToNormalized.set(pinhole.fx, pinhole.fy, pinhole.skew, pinhole.cx, pinhole.cy);
    Point2D_F32 norm = new Point2D_F32();
    for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
        for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
            pixelToNormalized.compute(pixelX, pixelY, norm);
            Point3D_F32 v = vectors[pixelY * pinhole.width + pixelX];
            v.set(norm.x, norm.y, 1);
        }
    }
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) PinholePtoN_F32(boofcv.alg.distort.pinhole.PinholePtoN_F32) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 9 with Point3D_F32

use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.

the class EquirectangularDistortBase_F32 method declareVectors.

/**
 * Declares storage for precomputed pointing vectors to output image
 *
 * @param width output image width
 * @param height output image height
 */
protected void declareVectors(int width, int height) {
    this.outWidth = width;
    if (vectors.length < width * height) {
        Point3D_F32[] tmp = new Point3D_F32[width * height];
        System.arraycopy(vectors, 0, tmp, 0, vectors.length);
        for (int i = vectors.length; i < tmp.length; i++) {
            tmp[i] = new Point3D_F32();
        }
        vectors = tmp;
    }
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32)

Example 10 with Point3D_F32

use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.

the class EquirectangularDistortBase_F32 method compute.

/**
 * Input is in pinhole camera pixel coordinates.  Output is in equirectangular coordinates
 *
 * @param x Pixel x-coordinate in rendered pinhole camera
 * @param y Pixel y-coordinate in rendered pinhole camera
 */
@Override
public void compute(int x, int y) {
    // grab precomputed normalized image coordinate at canonical location
    Point3D_F32 v = vectors[y * outWidth + x];
    // move to requested orientation
    // TODO make faster by not using an array based matrix
    GeometryMath_F32.mult(R, v, n);
    // compute pixel coordinate
    tools.normToEquiFV(n.x, n.y, n.z, out);
    distX = out.x;
    distY = out.y;
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32)

Aggregations

Point3D_F32 (georegression.struct.point.Point3D_F32)18 Point2D_F32 (georegression.struct.point.Point2D_F32)10 Point2Transform3_F32 (boofcv.struct.distort.Point2Transform3_F32)4 Test (org.junit.Test)4 Point3Transform2_F32 (boofcv.struct.distort.Point3Transform2_F32)3 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)2 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)2 CameraUniversalOmni (boofcv.struct.calib.CameraUniversalOmni)2 GrayF32 (boofcv.struct.image.GrayF32)2 UtilVector3D_F32 (georegression.geometry.UtilVector3D_F32)2 Vector3D_F32 (georegression.struct.point.Vector3D_F32)2 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)1 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)1 PixelTransform2_F32 (boofcv.struct.distort.PixelTransform2_F32)1 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)1 Rodrigues_F32 (georegression.struct.so.Rodrigues_F32)1 ArrayList (java.util.ArrayList)1 FMatrixRMaj (org.ejml.data.FMatrixRMaj)1