Open3D
Open3D copied to clipboard
When Saving and Loading VoxelBlockGrid negative indices cause a Seg Fault
Checklist
- [X] I have searched for similar issues.
- [x] For Python issues, I have tested with the latest development wheel.
- [X] I have checked the release documentation and the latest documentation (for
mainbranch).
Describe the issue
I am working with the tensor implementation of the Voxel Block Grid and I have successfully built a voxel block grid of an object with a series of depth images but when I try to save and load the object I get errors.
The object saves without error but gives this output when loading which is a series of errors about the a negative index outside of the bounds. Then when I try to use the object and call ray_cast there is a Segmentation fault.
Steps to reproduce the bug
//This is the function I use to build and save the Voxel Block Grid
void create_npz_object_from_mesh(open3d::t::geometry::TriangleMesh mesh,std::string out_file_name, bool create_snapshot_files){
float voxel_size = 3.0/512;
int block_res = 8;
int64_t block_count = 6000;
auto mesh_points_ptr = mesh.ToLegacy().SamplePointsUniformly(5000);
auto pc_ptr = open3d::t::geometry::PointCloud::FromLegacy(mesh_points_ptr->points_,open3d::core::Dtype::Float32,open3d::core::Device("CUDA:0"));
open3d::t::geometry::VoxelBlockGrid voxel_grid({"tsdf","weight"},{open3d::core::Dtype::Float32,open3d::core::Dtype::Float32},
{{1},{1}},voxel_size,block_res,block_count,open3d::core::Device("CUDA:0"));
// Camera Specific; May need to be changed for different objects
auto camera_intrin = open3d::core::Tensor(std::vector<float>{200.0, 0.0, 150.0,0, 200, 150,0, 0, 1},{3,3}).To(open3d::core::Dtype::Float64); int img_width_height = 300;
// Transform matrix of 1.5m in the z
Eigen::Matrix4f transform_mat = Eigen::Matrix4f::Identity();
Eigen::Quaternionf q;
transform_mat(2, 3) = 1.5f; // Sets distance between virtual camera and object
open3d::core::Tensor extrinsic_cam_mat;
float step_size = M_PI/10;
for (float r_x=0;r_x<(2*M_PI-step_size);r_x+=step_size){
for (float r_y=0;r_y<(M_PI-step_size);r_y+=step_size){
q = Eigen::Quaternionf(Eigen::AngleAxisf(r_x, Eigen::Vector3f::UnitX()) *
Eigen::AngleAxisf(r_y, Eigen::Vector3f::UnitY()));
transform_mat.block<3, 3>(0, 0) = q.toRotationMatrix();
extrinsic_cam_mat = open3d::core::eigen_converter::EigenMatrixToTensor(transform_mat).To(open3d::core::Dtype::Float64);
// Note only looking 3m deep when 1.5m away from the object
auto depth_img = pc_ptr.ProjectToDepthImage(img_width_height,img_width_height,camera_intrin,extrinsic_cam_mat);
auto block_coords = voxel_grid.GetUniqueBlockCoordinates(depth_img,camera_intrin,extrinsic_cam_mat);
voxel_grid.Integrate(block_coords,depth_img,camera_intrin,extrinsic_cam_mat);
}
}
voxel_grid.Save(out_file_name);
return;
}
//But when I run
std::shared_ptr<open3d::t::geometry::VoxelBlockGrid> voxel_grid = std::make_shared<open3d::t::geometry::VoxelBlockGrid>();
voxel_grid->Load("file_name.npz")
Error message
Expected behavior
No response
Open3D, Python and System information
- Operating system: Ubuntu 20.04
- Open3D version: 0.18.0
- System architecture: arm64
- Is this a remote workstation?: yes
- How did you install Open3D?: build from source
- Compiler version (if built from source): gcc 9.4.0
Additional information
No response
I have the same problem with you. How did you solve it?