isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
10.82k stars 2.24k forks source link

got trouble in deform_as_rigid_as_possible() #1718

Open uingue opened 4 years ago

uingue commented 4 years ago

Describe the bug I run mesh_deformation.py and change the given mesh to my own .obj file mesh.tar.gz some .obj run perfectly but others got trouble in deform_as_rigid_as_possible().

To Reproduce Steps to reproduce the behavior:

  1. load my own mesh in mesh_deformation.py

    def problem3(): mesh = o3d.io.read_triangle_mesh("./mesh/mesh_normalized.obj") vertices = np.asarray(mesh.vertices) static_ids = [idx for idx in np.where(vertices[:, 1] < -0.32)[0]] static_positions = [] for id in static_ids: static_positions.append(vertices[id]) handle_ids = [0] handle_positions = [vertices[0] + np.array((0.1, 0.1, 0.1))] return mesh, static_ids + handle_ids, static_positions + handle_positions

  2. python ./example/Python/Advanced/mesh_deformation.py

  3. got the error:

Traceback (most recent call last): File "/home/uingue/code/Open3D/examples/Python/Advanced/mesh_deformation.py", line 101, in o3d.utility.IntVector(constraint_ids), constraint_pos, max_iter=50) RuntimeError: [Open3D ERROR] [DeformAsRigidAsPossible] Failed to build solver (factorize)

Expected behavior get the deformed mesh

Environment (please complete the following information):

Additional context

griegler commented 4 years ago

I tried to rerun your example with the mesh you provide. I get the same error, but the error seems to be that static_positions and static_ids are empty.

syncle commented 4 years ago

@uingue could you comment on @griegler's feedback? @griegler is this issue requires the bug fix?

griegler commented 4 years ago

@syncle maybe we could add more information to the error message. Another alternative is to expand the method parameters to use separate params for static and handle ids and positions.

dlehgo14 commented 3 years ago

I had the same error in other data. It seems that my error occurs because #constrain_ids is too small. When I increased it, the error disappeared.

sonamkumar123 commented 2 years ago

I am also getting error, trying the same file from the sample 'armadillo.obj'

[DeformAsRigidAsPossible] Failed to build solver (factorize)

D:\Dev\Morphic_Git\Morph>open3dMorph.py [Open3D DEBUG] [DeformAsRigidAsPossible] setting up S' [Open3D DEBUG] [DeformAsRigidAsPossible] done setting up S' [Open3D DEBUG] [DeformAsRigidAsPossible] setting up system matrix L [Open3D DEBUG] [DeformAsRigidAsPossible] done setting up system matrix L [Open3D DEBUG] [DeformAsRigidAsPossible] setting up sparse solver [Open3D Error] (class std::shared_ptr cdecl open3d::geometry::TriangleMesh::DeformAsRigidAsPossible(const class std::vector<int,class std::allocator > &,const class std::vector<class Eigen::Matrix<double,3,1,0,3,1>,class std::allocator<class Eigen::Matrix<double,3,1,0,3,1> > > &,unsigned int64,enum open3d::geometry::MeshBase::DeformAsRigidAsPossibleEnergy,double) const) D:\a\Open3D\Open3D\cpp\open3d\geometry\TriangleMeshDeformation.cpp:101: [DeformAsRigidAsPossible] Failed to build solver (factorize)

Traceback (most recent call last): File "D:\Dev\Morphic_Git\Morph\open3dMorph.py", line 27, in max_iter=50) RuntimeError: [Open3D Error] (class std::shared_ptr cdecl open3d::geometry::TriangleMesh::DeformAsRigidAsPossible(const class std::vector<int,class std::allocator > &,const class std::vector<class Eigen::Matrix<double,3,1,0,3,1>,class std::allocator<class Eigen::Matrix<double,3,1,0,3,1> > > &,unsigned int64,enum open3d::geometry::MeshBase::DeformAsRigidAsPossibleEnergy,double) const) D:\a\Open3D\Open3D\cpp\open3d\geometry\TriangleMeshDeformation.cpp:101: [DeformAsRigidAsPossible] Failed to build solver (factorize)

Tupel1001 commented 2 years ago

I had the same error message. It turned out there were some vertices in my mesh that weren't connected to any edges. I removed these, and then it worked. I haven't tried your code or your mesh, but maybe this helps.

benjaminum commented 2 years ago

@uingue please reopen if the problem still persists.

senhypevr commented 1 year ago

I encountered the same problem as @uingue when I deform my triangle meshes using DeformAsRigidAsPossible. I tried with a sequences of meshes with some of them going through while others failed (error message as shown below). I traced back the error to Eigen's sparseLU factorize() and the error message is "m_lastError = "THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT: " . I tried to add small number like 0.000001 to make the matrix non singular but the problem persists. Does any one encountered similar problem and solved it? thanks a lot!

OPEN3D ERROR MESSAGE: C++ exception with description "[Open3D Error] (std::shared_ptr open3d::geometry::TriangleMesh::DeformAsRigidAsPossible(const std::vector&, const std::vector<Eigen::Matrix<double, 3, 1> >&, size_t, open3d::geometry::MeshBase::DeformAsRigidAsPossibleEnergy, double) const) /home/hypevr/.conan/data/open3d/0.15.1/n3/stable/build/758629cca39294be41b7b6f0c60a5c6b0b6e57f8/source_subfolder/cpp/open3d/geometry/TriangleMeshDeformation.cpp:101: [DeformAsRigidAsPossible] Failed to build solver (factorize)

senhypevr commented 1 year ago

Hi griegler, do you know what caused this issue? thanks so much! @griegler

be-Frozen commented 7 months ago

I encountered the same problem as mentioned by @sonamkumar123 . I can only run deform_as_rigid_as_possible() on Armadillo mesh. If I use any other mesh, the problem persists. Can anyone solve this problem? Thanks a lot.

digitalmonkey commented 4 months ago

I had the same error - I was able to take my mesh, load it into Meshlab and used the "close holes" filter under "Remeshing, simplification and reconstruction" to seal up some holes. This allowed the solver to work for me. It feels like the deformer works best with manifold meshes that are close to being watertight. My mesh still had a hole.

Ziriuzzz commented 3 months ago

@digitalmonkey @be-Frozen I had the same issue. It could be solved by specifying the energy type (although the result seems not well). with o3d.utility.VerbosityContextManager(o3d.utility.VerbosityLevel.Debug) as cm: mesh_prime = mesh.deform_as_rigid_as_possible(constraint_ids, constraint_pos, max_iter=50, energy=o3d.geometry.DeformAsRigidAsPossibleEnergy.Spokes) Hope above code will help.

be-Frozen commented 1 month ago

@Ziriuzzz It appears that specifying the energy type is not the key. The problem still exists after setting energy=o3d.geometry.DeformAsRigidAsPossibleEnergy.Spokes. or energy=o3d.geometry.DeformAsRigidAsPossibleEnergy.Smoothed. After experiments, I finally found that the deform_as_rigid_as_possible function has certain restrictions on the mesh, which may cause this problem. It could be solved by removing degenerate triangles, duplicated triangles, and degenerate triangles. Here's how you can do it: mesh.remove_unreferenced_vertices() mesh.remove_duplicated_vertices() mesh.remove_degenerate_triangles() I hope this helps!