Search in sources :

Example 6 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class BenchmarkAssociationSpeedSurf method createSet.

private FastQueue<TupleDesc_F64> createSet(String imageName) {
    try {
        BufferedImage image = ImageIO.read(new File(imageName));
        GrayF32 gray = ConvertBufferedImage.convertFrom(image, (GrayF32) null);
        FastQueue<TupleDesc_F64> ret = new FastQueue<>(10, TupleDesc_F64.class, false);
        detector.detect(gray);
        for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
            ret.add(detector.getDescription(i).copy());
        }
        return ret;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) FastQueue(org.ddogleg.struct.FastQueue) IOException(java.io.IOException) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint)

Example 7 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class TestPnPLepetitEPnP method selectControlPoints.

@Test
public void selectControlPoints() {
    List<Point3D_F64> worldPts = GeoTestingOps.randomPoints_F64(-1, 10, -5, 20, 0.1, 0.5, 30, rand);
    FastQueue<Point3D_F64> controlPts = new FastQueue<>(4, Point3D_F64.class, true);
    PnPLepetitEPnP alg = new PnPLepetitEPnP();
    alg.selectWorldControlPoints(worldPts, controlPts);
    // check that each row is unique
    for (int i = 0; i < 4; i++) {
        Point3D_F64 ci = controlPts.get(i);
        for (int j = i + 1; j < 4; j++) {
            Point3D_F64 cj = controlPts.get(j);
            double dx = ci.x - cj.x;
            double dy = ci.y - cj.y;
            double dz = ci.z - cj.z;
            double sum = Math.abs(dx) + Math.abs(dy) + Math.abs(dz);
            assertTrue(sum > 0.00001);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) FastQueue(org.ddogleg.struct.FastQueue) Test(org.junit.Test)

Example 8 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class TestPnPLepetitEPnP method selectWorldControlPoints_planar.

@Test
public void selectWorldControlPoints_planar() {
    List<Point3D_F64> worldPts = CommonHomographyChecks.createRandomPlane(rand, 3, 30);
    FastQueue<Point3D_F64> controlPts = new FastQueue<>(4, Point3D_F64.class, true);
    PnPLepetitEPnP alg = new PnPLepetitEPnP();
    alg.selectWorldControlPoints(worldPts, controlPts);
    assertEquals(3, alg.numControl);
    // check that each row is unique
    for (int i = 0; i < 3; i++) {
        Point3D_F64 ci = controlPts.get(i);
        for (int j = i + 1; j < 3; j++) {
            Point3D_F64 cj = controlPts.get(j);
            double dx = ci.x - cj.x;
            double dy = ci.y - cj.y;
            double dz = ci.z - cj.z;
            double sum = Math.abs(dx) + Math.abs(dy) + Math.abs(dz);
            assertTrue(sum > 0.00001);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) FastQueue(org.ddogleg.struct.FastQueue) Test(org.junit.Test)

Example 9 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class TestTldAdjustRegion method process.

@Test
public void process() {
    ScaleTranslate2D motion = new ScaleTranslate2D(1.5, 2, 3);
    FastQueue<AssociatedPair> pairs = new FastQueue<>(AssociatedPair.class, true);
    for (int i = 0; i < 200; i++) {
        AssociatedPair p = pairs.grow();
        p.p1.x = rand.nextGaussian() * 2;
        p.p1.y = rand.nextGaussian() * 2;
        p.p2.x = p.p1.x * motion.scale + motion.transX;
        p.p2.y = p.p1.y * motion.scale + motion.transY;
    }
    Rectangle2D_F64 rect = new Rectangle2D_F64(10, 20, 30, 40);
    TldAdjustRegion alg = new TldAdjustRegion(30);
    alg.init(300, 400);
    assertTrue(alg.process(pairs, rect));
    assertEquals(17, rect.p0.x, 1e-8);
    assertEquals(33, rect.p0.y, 1e-8);
    assertEquals(47, rect.p1.x, 1e-8);
    assertEquals(63, rect.p1.y, 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Rectangle2D_F64(georegression.struct.shapes.Rectangle2D_F64) FastQueue(org.ddogleg.struct.FastQueue) ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) Test(org.junit.Test)

Example 10 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class TestBinaryEllipseDetectorPixel method undistortContour_WithDistortion.

/**
 * Undistort the image when distortion model is provided
 */
@Test
public void undistortContour_WithDistortion() {
    List<Point2D_I32> input = new ArrayList<>();
    FastQueue<Point2D_F64> output = new FastQueue<>(Point2D_F64.class, true);
    for (int i = 0; i < 10; i++) {
        input.add(new Point2D_I32(i, i));
    }
    BinaryEllipseDetectorPixel alg = new BinaryEllipseDetectorPixel();
    alg.setLensDistortion(new PixelTransformAffine_F32(new Affine2D_F32(1, 0, 0, 1, 10.0f, 0)));
    alg.undistortContour(input, output);
    assertEquals(input.size(), output.size);
    for (int i = 0; i < input.size(); i++) {
        Point2D_I32 p = input.get(i);
        assertEquals(p.x + 10, output.get(i).x, 1e-8);
        assertEquals(p.y, output.get(i).y, 1e-8);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Affine2D_F32(georegression.struct.affine.Affine2D_F32) FastQueue(org.ddogleg.struct.FastQueue) ArrayList(java.util.ArrayList) Point2D_I32(georegression.struct.point.Point2D_I32) PixelTransformAffine_F32(boofcv.alg.distort.PixelTransformAffine_F32) Test(org.junit.Test)

Aggregations

FastQueue (org.ddogleg.struct.FastQueue)27 Test (org.junit.Test)17 Point3D_F64 (georegression.struct.point.Point3D_F64)9 GrayU16 (boofcv.struct.image.GrayU16)5 GrayU8 (boofcv.struct.image.GrayU8)5 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)5 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 FastQueueArray_I32 (boofcv.struct.FastQueueArray_I32)4 Point2D_F64 (georegression.struct.point.Point2D_F64)4 Point2D_I32 (georegression.struct.point.Point2D_I32)4 BufferedImage (java.awt.image.BufferedImage)4 ArrayList (java.util.ArrayList)4 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 BrightFeature (boofcv.struct.feature.BrightFeature)3 GrayS32 (boofcv.struct.image.GrayS32)3 File (java.io.File)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)2 Edge (boofcv.alg.segmentation.fh04.SegmentFelzenszwalbHuttenlocher04.Edge)2 PointCloudViewer (boofcv.gui.d3.PointCloudViewer)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2