qizekun / ShapeLLM

[ECCV 2024] ShapeLLM: Universal 3D Object Understanding for Embodied Interaction
https://qizekun.github.io/shapellm/
Apache License 2.0
91 stars 6 forks source link

Question about Embodied Interaction #7

Closed homiec closed 1 week ago

homiec commented 2 weeks ago

Thanks for your great work,I have a question about “ 3D referring expression grounding on GAPartNet” in ShapeLLM.

Could you please explain in detail how to do it here? How to convert the 3D bbox generated by ShapeLLM into the 6 DoF pose of GAPartNet?

qizekun commented 2 weeks ago

Hi, here is an example of converting 3D BBox to 6DoF pose.

import numpy as np

def bbox_to_pose(points):
    """
    Converts a 3D bounding box (8 * 3D points) to a 6 degrees of freedom (6DoF) pose.

    Parameters:
    points (numpy.ndarray): An array of shape (8, 3) representing the 3D points of the bounding box.

    Returns:
    translation (numpy.ndarray): A translation vector of shape (3,).
    rotation_matrix (numpy.ndarray): A rotation matrix of shape (3, 3).
    """
    if points.shape != (8, 3):
        raise ValueError("Points array must have shape (8, 3)")

    # Calculate the center point (translation vector)
    center = np.mean(points, axis=0)

    # Compute the rotation matrix
    centered_points = points - center
    cov_matrix = np.cov(centered_points.T)
    eigenvalues, eigenvectors = np.linalg.eig(cov_matrix)
    idx = eigenvalues.argsort()[::-1]
    rotation_matrix = eigenvectors[:, idx]

    return center, rotation_matrix