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;
}
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;
}
};
}
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);
}
}
Aggregations