Search in sources :

Example 6 with Point3dRgbI_F64

use of boofcv.struct.Point3dRgbI_F64 in project BoofCV by lessthanoptimal.

the class PointCloudViewerSwing method copyCloud.

@Override
public DogArray<Point3dRgbI_F64> copyCloud(@Nullable DogArray<Point3dRgbI_F64> copy) {
    if (copy == null)
        copy = new DogArray<>(Point3dRgbI_F64::new);
    else
        copy.reset();
    DogArray<Point3dRgbI_F64> _copy = copy;
    // See if it has color information on the points or not
    final PackedArray<Point3D_F32> cloudXyz = panel.getCloudXyz();
    final BigDogArray_I32 cloudColor = panel.getCloudColor();
    synchronized (cloudXyz) {
        if (cloudXyz.size() == cloudColor.size) {
            cloudXyz.forIdx(0, cloudXyz.size(), (idx, point) -> _copy.grow().setTo(point.x, point.y, point.z, cloudColor.get(idx)));
        } else {
            cloudXyz.forIdx(0, cloudXyz.size(), (idx, point) -> _copy.grow().setTo(point.x, point.y, point.z));
        }
    }
    return copy;
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) Point3dRgbI_F64(boofcv.struct.Point3dRgbI_F64) BigDogArray_I32(org.ddogleg.struct.BigDogArray_I32) DogArray(org.ddogleg.struct.DogArray)

Example 7 with Point3dRgbI_F64

use of boofcv.struct.Point3dRgbI_F64 in project BoofCV by lessthanoptimal.

the class PointCloudReader method wrap.

static PointCloudReader wrap(Generic op, int size) {
    return new PointCloudReader() {

        Point3dRgbI_F64 p = new Point3dRgbI_F64();

        @Override
        public int size() {
            return size;
        }

        @Override
        public void get(int index, Point3D_F32 point) {
            op.get(index, p);
            point.x = (float) p.x;
            point.y = (float) p.y;
            point.z = (float) p.z;
        }

        @Override
        public void get(int index, Point3D_F64 point) {
            op.get(index, p);
            point.setTo(p);
        }

        @Override
        public int getRGB(int index) {
            op.get(index, p);
            return p.rgb;
        }
    };
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) Point3D_F64(georegression.struct.point.Point3D_F64) Point3dRgbI_F64(boofcv.struct.Point3dRgbI_F64)

Example 8 with Point3dRgbI_F64

use of boofcv.struct.Point3dRgbI_F64 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)

Aggregations

Point3dRgbI_F64 (boofcv.struct.Point3dRgbI_F64)8 DogArray (org.ddogleg.struct.DogArray)6 Point3D_F64 (georegression.struct.point.Point3D_F64)3 ArrayList (java.util.ArrayList)3 Test (org.junit.jupiter.api.Test)3 Point3D_F32 (georegression.struct.point.Point3D_F32)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 DogArray_I32 (org.ddogleg.struct.DogArray_I32)2 PointCloudWriter (boofcv.alg.cloud.PointCloudWriter)1 ColorizeMultiViewStereoResults (boofcv.alg.mvs.ColorizeMultiViewStereoResults)1 LookUpColorRgbFormats (boofcv.core.image.LookUpColorRgbFormats)1 LookUpImageFilesByIndex (boofcv.io.image.LookUpImageFilesByIndex)1 DoNothing2Transform2_F64 (boofcv.struct.distort.DoNothing2Transform2_F64)1 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)1 GrayF32 (boofcv.struct.image.GrayF32)1 PointCloudViewer (boofcv.visualize.PointCloudViewer)1 Point4D_F64 (georegression.struct.point.Point4D_F64)1 UncheckedIOException (java.io.UncheckedIOException)1 BigDogArray_I32 (org.ddogleg.struct.BigDogArray_I32)1