Search in sources :

Example 6 with LensDistortionRadialTangential

use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.

the class TestSquareBinary_to_FiducialDetector method loadDistortion.

@Override
public LensDistortionNarrowFOV loadDistortion(boolean distorted) {
    CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("intrinsic_binary.yaml"));
    if (!distorted) {
        model.radial = null;
        model.t1 = model.t2 = 0;
    }
    return new LensDistortionRadialTangential(model);
}
Also used : LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial)

Example 7 with LensDistortionRadialTangential

use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.

the class TestSquareImage_to_FiducialDetector method loadDistortion.

@Override
public LensDistortionNarrowFOV loadDistortion(boolean distorted) {
    CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("intrinsic_image.yaml"));
    if (!distorted) {
        model.radial = null;
        model.t1 = model.t2 = 0;
    }
    return new LensDistortionRadialTangential(model);
}
Also used : LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial)

Example 8 with LensDistortionRadialTangential

use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.

the class SimulatePlanarWorld method setCamera.

public void setCamera(CameraPinholeRadial model) {
    output.reshape(model.width, model.height);
    depthMap.reshape(model.width, model.height);
    LensDistortionNarrowFOV factory = new LensDistortionRadialTangential(model);
    pixelTo3 = new NarrowPixelToSphere_F64(factory.undistort_F64(true, false));
    sphereToPixel = new SphereToNarrowPixel_F64(factory.distort_F64(false, true));
    computeProjectionTable(model);
}
Also used : LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) NarrowPixelToSphere_F64(boofcv.alg.distort.NarrowPixelToSphere_F64) LensDistortionNarrowFOV(boofcv.alg.distort.LensDistortionNarrowFOV) SphereToNarrowPixel_F64(boofcv.alg.distort.SphereToNarrowPixel_F64)

Example 9 with LensDistortionRadialTangential

use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.

the class FiducialDetection method process.

private void process() {
    if (detector == null) {
        System.err.println("Need to specify which fiducial you wish to detect");
        System.exit(1);
    }
    if (outputPath != null) {
        try {
            outputFile = new PrintStream(outputPath);
            outputFile.println("# Results from fiducial detection ");
            outputFile.println("# These comments should include the data source and the algorithm used, but I'm busy.");
            outputFile.println("# ");
            outputFile.println("# <frame #> <number of fiducials> <fiducial id> <X> <Y> <Z> <Q1> <Q2> <Q3> <Q4> ...");
            outputFile.println("# ");
            outputFile.println("# The special Euclidean transform saved each fiducial is from fiducial to camera");
            outputFile.println("# (X,Y,Z) is the translation and (Q1,Q2,Q3,Q4) specifies a quaternion");
            outputFile.println("# ");
        } catch (FileNotFoundException e) {
            System.err.println("Failed to open output file.");
            System.err.println(e.getMessage());
            System.exit(1);
        }
    }
    MediaManager media = DefaultMediaManager.INSTANCE;
    CameraPinholeRadial intrinsic = intrinsicPath == null ? null : (CameraPinholeRadial) CalibrationIO.load(intrinsicPath);
    SimpleImageSequence<GrayU8> sequence = null;
    long pause = 0;
    BufferedImage buffered = null;
    if (inputType == InputType.VIDEO || inputType == InputType.WEBCAM) {
        if (inputType == InputType.WEBCAM) {
            String device = getCameraDeviceString();
            sequence = media.openCamera(device, desiredWidth, desiredHeight, ImageType.single(GrayU8.class));
        } else {
            // just assume 30ms is appropriate.  Should let the use specify this number
            pause = 30;
            sequence = media.openVideo(filePath, ImageType.single(GrayU8.class));
            sequence.setLoop(true);
        }
        intrinsic = handleIntrinsic(intrinsic, sequence.getNextWidth(), sequence.getNextHeight());
    } else {
        buffered = UtilImageIO.loadImage(filePath);
        if (buffered == null) {
            System.err.println("Can't find image or it can't be read.  " + filePath);
            System.exit(1);
        }
        intrinsic = handleIntrinsic(intrinsic, buffered.getWidth(), buffered.getHeight());
    }
    ImagePanel gui = new ImagePanel();
    gui.setPreferredSize(new Dimension(intrinsic.width, intrinsic.height));
    ShowImages.showWindow(gui, "Fiducial Detector", true);
    detector.setLensDistortion(new LensDistortionRadialTangential(intrinsic), intrinsic.width, intrinsic.height);
    if (sequence != null) {
        processStream(intrinsic, sequence, gui, pause);
    } else {
        processImage(intrinsic, buffered, gui);
    }
}
Also used : PrintStream(java.io.PrintStream) LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) MediaManager(boofcv.io.MediaManager) DefaultMediaManager(boofcv.io.wrapper.DefaultMediaManager) FileNotFoundException(java.io.FileNotFoundException) GrayU8(boofcv.struct.image.GrayU8) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) ImagePanel(boofcv.gui.image.ImagePanel)

Example 10 with LensDistortionRadialTangential

use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.

the class PinholeRadialToEquirectangular_F64 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_F64 pixelToNormalized = new LensDistortionRadialTangential(pinhole).undistort_F64(true, false);
    Point2D_F64 norm = new Point2D_F64();
    for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
        for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
            pixelToNormalized.compute(pixelX, pixelY, norm);
            Point3D_F64 v = vectors[pixelY * pinhole.width + pixelX];
            v.set(norm.x, norm.y, 1);
        }
    }
}
Also used : LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64)

Aggregations

LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)15 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)9 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)6 BufferedImage (java.awt.image.BufferedImage)6 GrayF32 (boofcv.struct.image.GrayF32)5 Point2D_F64 (georegression.struct.point.Point2D_F64)5 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)4 File (java.io.File)4 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)3 GrayU8 (boofcv.struct.image.GrayU8)3 Se3_F64 (georegression.struct.se.Se3_F64)3 FoundFiducial (boofcv.alg.fiducial.square.FoundFiducial)2 ConfigFiducialBinary (boofcv.factory.fiducial.ConfigFiducialBinary)2 ConfigFiducialImage (boofcv.factory.fiducial.ConfigFiducialImage)2 ConfigPolygonDetector (boofcv.factory.shape.ConfigPolygonDetector)2 FactoryShapeDetector (boofcv.factory.shape.FactoryShapeDetector)2 ListDisplayPanel (boofcv.gui.ListDisplayPanel)2 ImagePanel (boofcv.gui.image.ImagePanel)2 CameraPinhole (boofcv.struct.calib.CameraPinhole)2 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)2