Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 7153 - 3DGS IO #7191

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

lumurillo
Copy link
Contributor

Fixes #7153

  • Bug fix (non-breaking change which fixes an issue): Fixes #
  • New feature (non-breaking change which adds functionality). Resolves #
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

Provide IO capabilities with 3DGS support for files like PLY and SPLAT.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Notes

  • Some of the test may fail because we need that the sample files are uploaded to the corresponding repo.

lumurillo and others added 3 commits March 7, 2025 12:45
* Include additional 3DGS properties for reading operation

* Add validation methods for 3DGS mandatory properties

* Read and Write including additional vertex

* Add the validation check to the write method

* Add a unit test for a valid ReadCloutPoint operation

* PLY read to point cloud

* PLY write correction

* Inline documentation

* Add constant defines for magic numbers and attribute names

* Add unit tests for reading and writing 3DGS formatted point clouds

* Add 3DGS attribute verification to the read operation

---------

Co-authored-by: Juan Cruz <[email protected]>
Co-authored-by: Gomez Rodriguez, Diego <[email protected]>
* Add splat writer

* Add splat reader

* Splat reader added to PointCloudIO.h

* Fix CMakeList.txt

* Add test for reading PointCloud from SPLAT format

* Fixing Style

---------

Co-authored-by: ikun03 <[email protected]>
Copy link

update-docs bot commented Mar 8, 2025

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@lumurillo lumurillo changed the title Issue 7153 dev Issue 7153 - 3DGS IO Mar 8, 2025
Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lumurillo and team for this very useful contribution!

Naming: Can we replace the use of 3DGS to GaussianSplat everywhere?
This also take care of variants of 3DGS such as 2D Gaussian Splatting. Also splat seems to be the more common / short name for this representation in other software.

Btw: a good way to remember the f_rest size is that it's n^2-1 for order n :-)

PS: Review is WIP: Will review test and docs later.

rot.cwiseMin(255.0).cwiseMax(0.0).cast<int>();

for (int idx = 0; idx < 4; ++idx) {
splat_write_byte(splat_file, int_to_byte(int_rot[idx]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bounds checking inside int_to_byte is unnecessary, since we have clamped the values above. Simpler static_cast should be faster.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Done.

@@ -309,16 +359,11 @@ TEST(TPointCloudIO, WritePTSColorConversion1) {

// Check PTS color boolean to uint8 conversion.
TEST(TPointCloudIO, WritePTSColorConversion2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this .pts file IO test deletion accidental?

Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to modify the unit tests a bit:

ply:

  1. Start with a ply file as a string [Done].
  2. Create tensors for each of the attributes (manually fill them in). See example here.
  3. Write ply string to disk as ply.
  4. Read it back from disk.
  5. Test - all attributes are present, are the right shape and data type as the tensors in step 2.
  6. Test all attribute values match (See example here).

splat:

  1. Start with .splat file as a binary blob - you can get this by converting the .ply file above to .splat with the reference convert.py script (antimatter github). You can convert it to a C array with xxd -i infile.splat outfile.h. If the C array is too big, let me know and we can add it directly to the git repo (with some cmake additions). This step directly proves that antimatter reference splats can be read by Open3D.
  2. Start with the same tensor attributes as in the ply test.
  3. Write it to disk as splat.
  4. Read it back from disk.
  5. Test - all attributes are present, are the right shape and data type as the tensors.
  6. Test all attribute values match (See example here).

This simplifies the tests by using round trip test, no data file is needed for splat,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't add data to the repo (as much as possible), so we can delete it from here. Instead, I'll add it to the Open3D downloads site.

Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joserochh!

@joserochh
Copy link

I think we need to modify the unit tests a bit:

ply:

  1. Start with a ply file as a string [Done].
  2. Create tensors for each of the attributes (manually fill them in). See example here.
  3. Write ply string to disk as ply.
  4. Read it back from disk.
  5. Test - all attributes are present, are the right shape and data type as the tensors in step 2.
  6. Test all attribute values match (See example here).

splat:

  1. Start with .splat file as a binary blob - you can get this by converting the .ply file above to .splat with the reference convert.py script (antimatter github). You can convert it to a C array with xxd -i infile.splat outfile.h. If the C array is too big, let me know and we can add it directly to the git repo (with some cmake additions). This step directly proves that antimatter reference splats can be read by Open3D.
  2. Start with the same tensor attributes as in the ply test.
  3. Write it to disk as splat.
  4. Read it back from disk.
  5. Test - all attributes are present, are the right shape and data type as the tensors.
  6. Test all attribute values match (See example here).

This simplifies the tests by using round trip test, no data file is needed for splat,

I have modified splat unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3D Gaussian splatting IO
3 participants