isl-org / isl-org/Open3D

How can I apply a transformation only once in open3D

Open
#6,894 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](https://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](https://www.open3d.org/docs/release/) and the [latest documentation](https://www.open3d.org/docs/latest/) (for `main` branch).

### My Question

I want to apply a simple rotation to my 3D model, say 10° pitch, with respect to the recent rotation only once but the model keeps rotating indefinitely. I tried using rotation matrix in a transformation but I get the same issue.

Later I want to be able to generate a pose (rotation+translation) from the video processing and apply it the 3D model.

Here is an example code:

from colorama import init
import numpy as np
import open3d as o3d
import cv2

# Paths to the 3D object and video file
obj_path = "Compressor HD.obj"

# Callback function to update the texture of the plane with video frames
def update(vis):
global obj_mesh, initial_rotation

obj_mesh.rotate(o3d.geometry.get_rotation_matrix_from_xyz(np.radians([10, 0, 0])), center=[0, 0, 0])

vis.update_geometry(obj_mesh)
vis.poll_events()
vis.update_renderer()
return False

if __name__ == "__main__":

vis = o3d.visualization.VisualizerWithKeyCallback()
vis.create_window()

# Load and add the 3D object to the scene
obj_mesh = o3d.io.read_triangle_mesh(obj_path)
obj_mesh.compute_vertex_normals()
vis.add_geometry(obj_mesh)

initial_rotation = obj_mesh.get_rotation_matrix_from_xyz([0, 0, 0])

# Create and add coordinate frame
axis_length = 200
coordinate_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=axis_length, origin=[0, 0, 0])
vis.add_geometry(coordinate_frame)

# Register callback to update video frame texture
vis.register_animation_callback(update)

vis.run()
vis.destroy_window()
cv2.destroyAllWindows()

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.