Search in sources :

Example 16 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class MonocularPlaneVisualOdometryScaleInput method setCalibration.

@Override
public void setCalibration(MonoPlaneParameters param) {
    scaleParameter.intrinsic = new CameraPinholeRadial(param.intrinsic);
    scaleParameter.planeToCamera = param.planeToCamera.copy();
    PerspectiveOps.scaleIntrinsic(scaleParameter.intrinsic, scaleFactor);
    scaled.reshape(scaleParameter.intrinsic.width, scaleParameter.intrinsic.height);
    alg.setCalibration(scaleParameter);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial)

Example 17 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class VisualizeSquareBinaryFiducial method process.

public void process(String nameImage, String nameIntrinsic) {
    CameraPinholeRadial intrinsic = nameIntrinsic == null ? null : (CameraPinholeRadial) CalibrationIO.load(nameIntrinsic);
    GrayF32 input = UtilImageIO.loadImage(nameImage, GrayF32.class);
    GrayF32 undistorted = new GrayF32(input.width, input.height);
    InputToBinary<GrayF32> inputToBinary = FactoryThresholdBinary.globalOtsu(0, 255, true, GrayF32.class);
    Detector detector = new Detector(gridWidth, borderWidth, inputToBinary);
    detector.setLengthSide(0.1);
    if (intrinsic != null) {
        CameraPinholeRadial paramUndist = new CameraPinholeRadial();
        ImageDistort<GrayF32, GrayF32> undistorter = LensDistortionOps.changeCameraModel(AdjustmentType.EXPAND, BorderType.EXTENDED, intrinsic, new CameraPinhole(intrinsic), paramUndist, ImageType.single(GrayF32.class));
        detector.configure(new LensDistortionRadialTangential(paramUndist), paramUndist.width, paramUndist.height, false);
        undistorter.apply(input, undistorted);
        detector.process(undistorted);
    } else {
        detector.process(input);
    }
    System.out.println("Total Found: " + detector.squares.size());
    FastQueue<FoundFiducial> fiducials = detector.getFound();
    int N = Math.min(20, detector.squares.size());
    ListDisplayPanel squares = new ListDisplayPanel();
    for (int i = 0; i < N; i++) {
        squares.addImage(VisualizeBinaryData.renderBinary(detector.squares.get(i), false, null), " " + i);
        squares.addImage(ConvertBufferedImage.convertTo(detector.squaresGray.get(i), null), " " + i);
    }
    BufferedImage output = new BufferedImage(input.width, input.height, BufferedImage.TYPE_INT_RGB);
    ConvertBufferedImage.convertTo(input, output);
    Graphics2D g2 = output.createGraphics();
    g2.setColor(Color.RED);
    g2.setStroke(new BasicStroke(2));
    for (int i = 0; i < N; i++) {
        VisualizeShapes.drawArrowSubPixel(fiducials.get(i).distortedPixels, 3, 1, g2);
    }
    ShowImages.showWindow(output, "Binary", true);
    ShowImages.showWindow(squares, "Candidates", true);
}
Also used : ListDisplayPanel(boofcv.gui.ListDisplayPanel) FoundFiducial(boofcv.alg.fiducial.square.FoundFiducial) CameraPinhole(boofcv.struct.calib.CameraPinhole) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) GrayF32(boofcv.struct.image.GrayF32) FactoryShapeDetector(boofcv.factory.shape.FactoryShapeDetector) ConfigPolygonDetector(boofcv.factory.shape.ConfigPolygonDetector) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial)

Example 18 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class ExampleMultiviewSceneReconstruction method main.

public static void main(String[] args) {
    String directory = UtilIO.pathExample("sfm/chair");
    CameraPinholeRadial intrinsic = CalibrationIO.load(new File(directory, "/intrinsic_DSC-HX5_3648x2736_to_640x480.yaml"));
    List<BufferedImage> images = UtilImageIO.loadImages(directory, ".*jpg");
    ExampleMultiviewSceneReconstruction example = new ExampleMultiviewSceneReconstruction();
    long before = System.currentTimeMillis();
    example.process(intrinsic, images);
    long after = System.currentTimeMillis();
    System.out.println("Elapsed time " + (after - before) / 1000.0 + " (s)");
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 19 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class TestZhang99OptimizationJacobian method compareToNumerical.

private void compareToNumerical(boolean assumeZeroSkew, boolean includeTangential) {
    Zhang99AllParam param = GenericCalibrationGrid.createStandardParam(TestPinholeCalibrationZhang99.createStandard(assumeZeroSkew, includeTangential, 2, rand), 3, rand);
    // give it larger values that will generate a larger derivative and pass the unit test
    CameraPinholeRadial p = param.getIntrinsic().getCameraModel();
    p.radial[0] = 0.2;
    p.radial[1] = 0.25;
    p.t1 = 0.05;
    p.t2 = 0.07;
    List<Point2D_F64> gridPts = CalibrationDetectorSquareGrid.createLayout(3, 2, 30, 30);
    List<CalibrationObservation> observations = new ArrayList<>();
    for (int i = 0; i < param.views.length; i++) {
        observations.add(estimate(param, param.views[i], gridPts));
    }
    if (partial) {
        for (int i = 0; i < observations.size(); i++) {
            CalibrationObservation c = observations.get(i);
            for (int j = 0; j < 5; j++) {
                c.points.remove(3 * i);
            }
        }
    }
    double[] dataParam = new double[param.numParameters()];
    param.convertToParam(dataParam);
    Zhang99OptimizationFunction func = new Zhang99OptimizationFunction(param.copy(), gridPts, observations);
    Zhang99OptimizationJacobian alg = new Zhang99OptimizationJacobian((CalibParamPinholeRadial) param.getIntrinsic(), observations, gridPts);
    // Why does the tolerance need to be so crude?  Is there a fundamental reason for this?
    double tol = includeTangential ? 0.05 : 0.01;
    // DerivativeChecker.jacobianPrintR(func, alg, dataParam, tol);
    assertTrue(DerivativeChecker.jacobianR(func, alg, dataParam, tol));
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList)

Example 20 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class GenericQrCodeDetectorChecks method rotation.

/**
 * See if a clear well defined qr code can be detected while rating
 */
@Test
public void rotation() {
    QrCodeDetector<GrayF32> detector = createDetector();
    CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("calib/pinhole_radial.yaml"));
    SimulatePlanarWorld simulator = new SimulatePlanarWorld();
    simulator.setCamera(model);
    simulator.resetScene();
    Se3_F64 markerToWorld = new Se3_F64();
    simulator.addTarget(markerToWorld, simulatedTargetWidth, generateMarker());
    markerToWorld.T.set(0, 0, 0.5);
    for (int i = 0; i < 30; i++) {
        double roll = 2 * Math.PI * i / 30.0;
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, 0, roll, markerToWorld.R);
        renderAndCheck(detector, simulator);
    }
}
Also used : SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) GrayF32(boofcv.struct.image.GrayF32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Aggregations

CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)81 Test (org.junit.Test)37 Se3_F64 (georegression.struct.se.Se3_F64)26 GrayF32 (boofcv.struct.image.GrayF32)19 Point2D_F64 (georegression.struct.point.Point2D_F64)16 File (java.io.File)15 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)12 BufferedImage (java.awt.image.BufferedImage)12 DMatrixRMaj (org.ejml.data.DMatrixRMaj)12 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)10 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)9 CameraPinhole (boofcv.struct.calib.CameraPinhole)9 Point3D_F64 (georegression.struct.point.Point3D_F64)8 ArrayList (java.util.ArrayList)7 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)6 StereoParameters (boofcv.struct.calib.StereoParameters)6 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)6 Point2D_F32 (georegression.struct.point.Point2D_F32)5 FMatrixRMaj (org.ejml.data.FMatrixRMaj)5 GrayU8 (boofcv.struct.image.GrayU8)4