-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add serialization and deserialization methods to Octree #7329
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
base: main
Are you sure you want to change the base?
Add serialization and deserialization methods to Octree #7329
Conversation
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds binary serialization and deserialization support to the Octree class, complementing the existing JSON-based I/O functionality. The implementation allows Octree objects to be saved and loaded in a binary format (.bin) for more efficient storage and transmission.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
cpp/open3d/geometry/Octree.h |
Adds binary serialization method declarations to all Octree node classes |
cpp/open3d/geometry/Octree.cpp |
Implements binary serialization/deserialization for all Octree node types |
cpp/open3d/io/OctreeIO.h |
Adds function declarations for binary I/O operations |
cpp/open3d/io/OctreeIO.cpp |
Implements high-level binary I/O functions and registers .bin format support |
cpp/open3d/io/file_format/FileBIN.cpp |
Adds low-level binary file read/write utilities |
cpp/tests/geometry/Octree.cpp |
Adds unit test for binary stream serialization/deserialization |
cpp/tests/io/OctreeIO.cpp |
Updates existing tests to verify both JSON and binary formats |
cpp/pybind/t/geometry/pointcloud.cpp |
Minor formatting fix for function definition |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lumurillo thanks for this nice addition. Some thoughts:
- Can we use msgpack, instead of raw binary format for serialization? This is already used elsewhere in Open3D, is simple to use, should provide good speed and smaller size and will also be cross-platform. Raw binary format sometimes has issues if you write on Windows and read in Linux or vice versa. It will also enable reading / writing from plain Python through the Python msgpack library.
- msgpack in Open3D:
Open3D/cpp/open3d/io/rpc/Messages.h
Line 250 in fb7088c
// macro for creating the serialization/deserialization code *.msgpack
files to store tensor geometries in the Tensorboard plugin, for example. - Tutorial: https://github.com/msgpack/msgpack-c/wiki/v2_0_cpp_tutorial
From Github Copilot, about the macOS errors: The build is failing due to missing override specifiers for functions that override virtual methods in the Octree classes. The compiler treats this as an error because of the -Werror,-Winconsistent-missing-override flag. For example:
To fix this, add the override keyword to all overriding methods in the derived classes. Specifically, in cpp/open3d/geometry/Octree.h (ref: 1fada55), update the relevant function declarations as follows: For OctreeInternalNode: bool SerializeToBinaryStream(std::string& out) const override;
bool DeserializeFromBinaryStream(const std::string& in, size_t& offset) override; For OctreeInternalPointNode: bool SerializeToBinaryStream(std::string& out) const override;
bool DeserializeFromBinaryStream(const std::string& in, size_t& offset) override; For OctreeColorLeafNode: bool SerializeToBinaryStream(std::string& out) const override;
bool DeserializeFromBinaryStream(const std::string& in, size_t& offset) override; For OctreePointColorLeafNode: bool SerializeToBinaryStream(std::string& out) const override;
bool DeserializeFromBinaryStream(const std::string& in, size_t& offset) override; Add override to all other similar functions that are overriding a base class method but are missing it. This will resolve the compilation errors and allow the build to succeed. You can see the problematic lines in Octree.h here: |
Add serialization and deserialization methods to the Octree.
Type
Motivation and Context
Checklist:
python util/check_style.py --apply
to apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.