You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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:
Beta Was this translation helpful? Give feedback.
All reactions