Description
Checklist
- I have searched for similar issues.
- For Python issues, I have tested with the latest development wheel.
- I have checked the release documentation and the latest documentation (for
main
branch).
My Question
Hi~ I want to render two layers mesh with textures and translate or rotate the first layer mesh while fixing the second mesh. I realized the function as folllowing and rendered success, but i got a "segmentation fault" error when I translated or rotated the first mesh. Does anyone know the reason?
`
mesh = o3d.io.read_triangle_mesh("shouban/demo.obj", True) # triangle_material_ids:673376
if not mesh.has_textures():
print("Mesh does not have texture. Loading texture manually...")
texture = o3d.io.read_image(os.path.join('shouban', "material_0.png"))
mesh.textures = [texture]
background = o3d.io.read_triangle_mesh("bg/bg.obj")
background.triangle_material_ids = o3d.utility.IntVector([0]*2)
if not background.has_textures():
print("Background Mesh does not have texture. Loading texture manually...")
image_path = os.path.join('bg', 'chun.png')
if not os.path.exists(image_path):
raise FileNotFoundError(f"Image file not found at {image_path}")
bg_tex = o3d.io.read_image(image_path)
background.textures = [bg_tex]
def rotate_and_save(angles):
def _custum_rotate_and_save(vis):
R = mesh.get_rotation_matrix_from_xyz((angles[0], angles[1], 0))
mesh.rotate(R, center=(0, 0, 0))
vis.update_geometry(mesh)
vis.poll_events()
vis.update_renderer()
# capture_frame(vis)
return False
return _custum_rotate_and_save
def camera_translate(trans):
def _custum_camera_translate(vis):
mesh.translate(trans)
vis.update_geometry(mesh)
vis.poll_events()
vis.update_renderer()
# capture_frame(vis)
return False
return _custum_camera_translate
key_to_callback = {}
key_to_callback[ord("J")] = rotate_and_save((1, 0))
key_to_callback[ord("L")] = rotate_and_save((-1, 0))
key_to_callback[ord("I")] = rotate_and_save((0, 1))
key_to_callback[ord("K")] = rotate_and_save((0, -1))
key_to_callback[ord("W")] = camera_translate((0.01, 0, 0))
key_to_callback[ord("S")] = camera_translate((-0.01, 0, 0))
key_to_callback[ord("A")] = camera_translate((0.0, 0.01, 0))
key_to_callback[ord("D")] = camera_translate((0.0, -0.01, 0))
key_to_callback[ord("X")] = camera_translate((0.0, 0.0, 0.01))
key_to_callback[ord("Z")] = camera_translate((0.0, 0.0, -0.01))
可视化
o3d.visualization.draw_geometries_with_key_callbacks([mesh, background], key_to_callback)`
rendered image:

error message:
Background Mesh does not have texture. Loading texture manually... [Open3D WARNING] GLFW Error: Cocoa: Failed to find service port for display 2025-03-27 20:33:44.267 Python[14397:3623372] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/f6/8w1fzjn16x38wqnvtxw7tld40000gp/T/com.apple.python3.savedState [1] 14397 segmentation fault python3 test.py