Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

AttributeError: 'open3d.open3d.geometry.PointCloud' object has no attribute 'open3d'

Open edwincasallas22 opened this issue 7 years ago • 3 comments

Hello I'm working with the following global registration code:

import numpy as np
import open3d
import copy
from open3d import *



def draw_registration_result_original_color(source, target, transformation):
    source_temp = copy.deepcopy(source)
    source_temp.transform(transformation)
    draw_geometries([source_temp, target])


if __name__ == "__main__":

    print("1. Load two point clouds and show initial pose")
    source = open3d.io.read_point_cloud("../../TestData/ICP/12pruebaOK.pcd")
    target = open3d.io.read_point_cloud("../../TestData/ICP/11pruebaOK.pcd")



    # some pre-processing
    for i in range(len(source.points)):
        source.points[i] /= 100
    for i in range(len(target.points)):
        target.points[i] /= 100
    source.open3d.estimate_normals(source,KDTreeSearchParamHybrid(radius = 0.05, max_nn = 30))
    target.open3d.estimate_normals(traget,KDTreeSearchParamHybrid(radius = 0.05, max_nn = 30))


    # draw initial alignment
    current_transformation = np.identity(4)
    draw_registration_result_original_color(
            source, target, current_transformation)

    # point to plane ICP
    current_transformation = np.identity(4);
    print("2. Point-to-plane ICP registration is applied on original point")
    print("   clouds to refine the alignment. Distance threshold 0.02.")
    result_icp = registration_icp(source, target, 0.02,
            current_transformation, TransformationEstimationPointToPoint())
    current_transformation = result_icp.transformation
    draw_registration_result_original_color(
            source, target, current_transformation)

    result_icp = registration_icp(source, target, 0.02,
            current_transformation, TransformationEstimationPointToPlane())
    current_transformation = result_icp.transformation
    draw_registration_result_original_color(
            source, target, result_icp.transformation)

    # colored pointcloud registration
     # This is implementation of following paper
     # J. Park, Q.-Y. Zhou, V. Koltun,
     # Colored Point Cloud Registration Revisited, ICCV 2017
    voxel_radius = [ 0.04, 0.02, 0.01 ];
    max_iter = [ 50, 30, 14 ];
    print("3. Colored point cloud registration")
    for scale in range(3):
        iter = max_iter[scale]
        radius = voxel_radius[scale]
        print([iter,radius,scale])

        print("3-1. Downsample with a voxel size %.2f" % radius)
        source_down = voxel_down_sample(source, radius)
        target_down = voxel_down_sample(target, radius)

        print("3-2. Estimate normal.")
        estimate_normals(source_down, open3d.KDTreeSearchParamHybrid(radius = radius * 2, max_nn = 30))
        estimate_normals(target_down, open3d.KDTreeSearchParamHybrid(radius = radius * 2, max_nn = 30))

        print("3-3. Applying colored point cloud registration")
        result_icp = registration_colored_icp(source_down, target_down,
                radius, current_transformation,
                ICPConvergenceCriteria(relative_fitness = 1e-6,
                relative_rmse = 1e-6, max_iteration = iter))
        current_transformation = result_icp.transformation
        print(result_icp)
    draw_registration_result_original_color(
            source, target, result_icp.transformation)

When I use this algorithm I get the following error:

  1. Load two point clouds and show initial pose Traceback (most recent call last): File "ejemplo.py", line 31, in source.open3d.estimate_normals(source,KDTreeSearchParamHybrid(radius = 0.05, max_nn = 30)) AttributeError: 'open3d.open3d.geometry.PointCloud' object has no attribute 'open3d'

Do you know how to fix this problem?

edwincasallas22 avatar Oct 17 '19 16:10 edwincasallas22

source.open3d.estimate_normals -> source.estimate_normals?

yxlao avatar Oct 17 '19 22:10 yxlao

This don't work :c I get the following error:

  1. Load two point clouds and show initial pose Traceback (most recent call last): File "ejemplo.py", line 31, in source.estimate_normals(KDTreeSearchParamHybrid(radius = 0.05, max_nn = 30)) NameError: name 'KDTreeSearchParamHybrid' is not defined

edwincasallas22 avatar Oct 17 '19 22:10 edwincasallas22

You should have a look at the tutorials for open3d 0.8.0 (or the version that you are using) and the docu, then you would notice that you have to use o3d.geometry.KDTreeSearchParamHybrid(...).

griegler avatar Oct 18 '19 06:10 griegler