Ejemplo n.º 1
0
def problem2():
    mesh = o3dex.get_armadillo_mesh()
    vertices = np.asarray(mesh.vertices)
    static_ids = [idx for idx in np.where(vertices[:, 1] < -30)[0]]
    static_positions = []
    for id in static_ids:
        static_positions.append(vertices[id])
    handle_ids = [2490]
    handle_positions = [vertices[2490] + np.array((-40, -40, -40))]

    return mesh, static_ids + handle_ids, static_positions + handle_positions
def scale():
    pcd = o3dex.get_armadillo_mesh().sample_points_poisson_disk(5000)
    pcd_s = copy.deepcopy(pcd).translate((200, 0, 0))
    pcd_s.scale(0.5, center=pcd_s.get_center())
    print('Displaying original and scaled geometries ...')
    o3d.visualization.draw([{
        "name": "Original Geometry",
        "geometry": pcd
    }, {
        "name": "Scaled Geometry",
        "geometry": pcd_s
    }],
                           show_ui=True)
def rotate():
    pcd = o3dex.get_armadillo_mesh().sample_points_poisson_disk(5000)
    pcd_r = copy.deepcopy(pcd).translate((200, 0, 0))
    R = pcd.get_rotation_matrix_from_xyz((np.pi / 2, 0, np.pi / 4))
    pcd_r.rotate(R)
    print('Displaying original and rotated geometries ...')
    o3d.visualization.draw([{
        "name": "Original Geometry",
        "geometry": pcd
    }, {
        "name": "Rotated Geometry",
        "geometry": pcd_r
    }],
                           show_ui=True)
def translate():
    pcd = o3dex.get_armadillo_mesh().sample_points_poisson_disk(5000)
    pcd_tx = copy.deepcopy(pcd).translate((150, 0, 0))
    pcd_ty = copy.deepcopy(pcd).translate((0, 200, 0))
    print('Displaying original and translated geometries ...')
    o3d.visualization.draw([{
        "name": "Original Geometry",
        "geometry": pcd
    }, {
        "name": "Translated (in X) Geometry",
        "geometry": pcd_tx
    }, {
        "name": "Translated (in Y) Geometry",
        "geometry": pcd_ty
    }],
                           show_ui=True)
def transform():
    pcd = o3dex.get_armadillo_mesh().sample_points_poisson_disk(5000)
    T = np.eye(4)
    T[:3, :3] = pcd.get_rotation_matrix_from_xyz((0, np.pi / 3, np.pi / 2))
    T[0, 3] = 150
    T[1, 3] = 200
    print(T)
    pcd_t = copy.deepcopy(pcd).transform(T)
    print('Displaying original and transformed geometries ...')
    o3d.visualization.draw([{
        "name": "Original Geometry",
        "geometry": pcd
    }, {
        "name": "Transformed Geometry",
        "geometry": pcd_t
    }],
                           show_ui=True)
Ejemplo n.º 6
0
# IN THE SOFTWARE.
# ----------------------------------------------------------------------------

import open3d as o3d
import numpy as np
import os
import sys

pyexample_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(pyexample_path)

import open3d_example as o3dex

if __name__ == "__main__":
    N = 2000
    pcd = o3dex.get_armadillo_mesh().sample_points_poisson_disk(N)
    # Fit to unit cube.
    pcd.scale(1 / np.max(pcd.get_max_bound() - pcd.get_min_bound()),
              center=pcd.get_center())
    pcd.colors = o3d.utility.Vector3dVector(np.random.uniform(0, 1,
                                                              size=(N, 3)))
    print('Displaying input voxel grid ...')
    voxel_grid = o3d.geometry.VoxelGrid.create_from_point_cloud(pcd,
                                                                voxel_size=0.05)
    o3d.visualization.draw([voxel_grid])

    octree = o3d.geometry.Octree(max_depth=4)
    octree.create_from_voxel_grid(voxel_grid)
    print('Displaying octree ..')
    o3d.visualization.draw([octree])
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
# ----------------------------------------------------------------------------

import open3d as o3d
import os
import time
import sys

pyexample_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(pyexample_path)

import open3d_example as o3dex

if __name__ == "__main__":
    # Compute ISS Keypoints on armadillo pointcloud.
    mesh = o3dex.get_armadillo_mesh()
    pcd = o3d.geometry.PointCloud()
    pcd.points = mesh.vertices

    tic = time.time()
    keypoints = o3d.geometry.keypoint.compute_iss_keypoints(pcd)
    toc = 1000 * (time.time() - tic)
    print("ISS Computation took {:.0f} [ms]".format(toc))

    mesh.compute_vertex_normals()
    mesh.paint_uniform_color([0.5, 0.5, 0.5])
    keypoints.paint_uniform_color([1.0, 0.0, 0.0])
    o3d.visualization.draw([keypoints, mesh], point_size=5)