Search in sources :

Example 61 with DogArray

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

the class ViewPairwiseImageGraphApp method changeSelectedView.

private void changeSelectedView(int viewIdx) {
    gui.clear();
    if (viewIdx <= -1 || imageFiles == null || viewIdx >= imageFiles.size())
        return;
    PairwiseImageGraph.View pview = graph.nodes.get(viewIdx);
    var features = new DogArray<>(Point2D_F64::new);
    BufferedImage original = UtilIO.load(imageFiles.get(viewIdx));
    db.lookupPixelFeats(pview.id, features);
    gui.setMainImage(pview.id, original, features.toList());
    gui.setMainText("Connections: " + pview.connections.size + "\n" + "Features: " + pview.totalObservations + "\n");
    for (int i = 0; i < pview.connections.size; i++) {
        PairwiseImageGraph.Motion m = pview.connections.get(i);
        PairwiseImageGraph.View other = m.other(pview);
        BufferedImage otherImage = UtilIO.load(imageFiles.get(other.index));
        db.lookupPixelFeats(pview.id, features);
        gui.addRelatedImage(other.id, otherImage, features.toList());
        gui.setRelatedText(other.id, "3d=" + m.is3D + " inliers=" + m.inliers.size);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) PairwiseImageGraph(boofcv.alg.structure.PairwiseImageGraph) DogArray(org.ddogleg.struct.DogArray) BufferedImage(java.awt.image.BufferedImage)

Example 62 with DogArray

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

the class TestPlyCodec method encode_decode_3D_binary.

@Test
void encode_decode_3D_binary() throws IOException {
    List<Point3D_F64> expected = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        expected.add(new Point3D_F64(i * 123.45, i - 1.01, i + 2.34));
    }
    for (boolean asFloat : new boolean[] { true, false }) {
        DogArray<Point3D_F64> found = new DogArray<>(Point3D_F64::new);
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        PlyCodec.saveBinary(PointCloudReader.wrapF64(expected), ByteOrder.BIG_ENDIAN, false, asFloat, output);
        ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
        PlyCodec.read(input, PointCloudWriter.wrapF64(found));
        assertEquals(expected.size(), found.size);
        double tol = asFloat ? UtilEjml.TEST_F32 : UtilEjml.TEST_F64;
        for (int i = 0; i < found.size; i++) {
            assertEquals(0.0, found.get(i).distance(expected.get(i)), tol);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) ArrayList(java.util.ArrayList) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Example 63 with DogArray

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

the class TestPlyCodec method encode_decode_3DRGB_ascii.

@Test
void encode_decode_3DRGB_ascii() throws IOException {
    List<Point3dRgbI_F64> expected = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        int r = (10 * i) & 0xFF;
        int g = (28 * i) & 0xFF;
        int b = (58 * i) & 0xFF;
        int rgb = r << 16 | g << 16 | b;
        expected.add(new Point3dRgbI_F64(i * 123.45, i - 1.01, i + 2.34, rgb));
    }
    DogArray<Point3dRgbI_F64> found = new DogArray<>(Point3dRgbI_F64::new);
    Writer output = new StringWriter();
    PlyCodec.saveAscii(PointCloudReader.wrapF64RGB(expected), true, output);
    InputStream input = new ByteArrayInputStream(output.toString().getBytes(UTF_8));
    PlyCodec.read(input, PointCloudWriter.wrapF64RGB(found));
    assertEquals(expected.size(), found.size);
    for (int i = 0; i < found.size; i++) {
        assertEquals(0.0, found.get(i).distance(expected.get(i)), UtilEjml.TEST_F64);
    }
}
Also used : Point3dRgbI_F64(boofcv.struct.Point3dRgbI_F64) ArrayList(java.util.ArrayList) DogArray(org.ddogleg.struct.DogArray) PointCloudWriter(boofcv.alg.cloud.PointCloudWriter) Test(org.junit.jupiter.api.Test)

Example 64 with DogArray

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

the class TestPlyCodec method encode_decode_3D_ascii.

@Test
void encode_decode_3D_ascii() throws IOException {
    List<Point3D_F64> expected = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        expected.add(new Point3D_F64(i * 123.45, i - 1.01, i + 2.34));
    }
    DogArray<Point3D_F64> found = new DogArray<>(Point3D_F64::new);
    Writer output = new StringWriter();
    PlyCodec.saveAscii(PointCloudReader.wrapF64(expected), false, output);
    InputStream input = new ByteArrayInputStream(output.toString().getBytes(UTF_8));
    PlyCodec.read(input, PointCloudWriter.wrapF64(found));
    assertEquals(expected.size(), found.size);
    for (int i = 0; i < found.size; i++) {
        assertEquals(0.0, found.get(i).distance(expected.get(i)), UtilEjml.TEST_F64);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) ArrayList(java.util.ArrayList) DogArray(org.ddogleg.struct.DogArray) PointCloudWriter(boofcv.alg.cloud.PointCloudWriter) Test(org.junit.jupiter.api.Test)

Example 65 with DogArray

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

the class TestPointCloudIO method encode_decode_3D64F.

@Test
void encode_decode_3D64F() throws IOException {
    List<Point3D_F64> expected = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        expected.add(new Point3D_F64(i * 123.45, i - 1.01, i + 2.34));
    }
    Format[] formats = new Format[] { Format.PLY };
    for (Format f : formats) {
        DogArray<Point3D_F64> found = new DogArray<>(Point3D_F64::new);
        found.grow().setTo(1, 1, 1);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        PointCloudIO.save3D(f, PointCloudReader.wrapF64(expected), false, stream);
        InputStream input = new ByteArrayInputStream(stream.toByteArray());
        PointCloudIO.load3D64F(f, input, found);
        // make sure it cleared the points
        assertEquals(expected.size(), found.size);
        for (int i = 0; i < expected.size(); i++) {
            assertEquals(0.0, found.get(i).distance(expected.get(i)), UtilEjml.TEST_F64);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Format(boofcv.io.points.PointCloudIO.Format) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Aggregations

DogArray (org.ddogleg.struct.DogArray)79 Test (org.junit.jupiter.api.Test)48 ArrayList (java.util.ArrayList)27 Point3D_F64 (georegression.struct.point.Point3D_F64)18 DogArray_I32 (org.ddogleg.struct.DogArray_I32)17 Point2D_F64 (georegression.struct.point.Point2D_F64)16 GrayU8 (boofcv.struct.image.GrayU8)13 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)10 Point2D_I32 (georegression.struct.point.Point2D_I32)7 DMatrixRMaj (org.ejml.data.DMatrixRMaj)7 BufferedImage (java.awt.image.BufferedImage)6 Point3dRgbI_F64 (boofcv.struct.Point3dRgbI_F64)5 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)5 List (java.util.List)5 PositionPatternNode (boofcv.alg.fiducial.qrcode.PositionPatternNode)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 GrayF32 (boofcv.struct.image.GrayF32)4 PointCloudViewer (boofcv.visualize.PointCloudViewer)4 Se3_F64 (georegression.struct.se.Se3_F64)4 FactoryNearestNeighbor (org.ddogleg.nn.FactoryNearestNeighbor)4