コード例 #1
0
def ply2pcd(file_path = None):
    if file_path is None:
        file_path, file_format = get_file()

    cloud = pcl.load(file_path, cloud_format)
    file_path = file_path[:-3]
    print(file_path)
    pcl.save_XYZRGBA(cloud, (file_path + "pcd"), format="pcd")
コード例 #2
0
        [0, 1],
        [0, 2],
        [0, 3],
    ]
    #each vector is red, green blue are PCA1, PCA2 and PCA3 respectivley.
    colors = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

    #create open3d linesets.
    line_set = o3d.LineSet()
    line_set.points = o3d.Vector3dVector(points)
    line_set.lines = o3d.Vector2iVector(lines)
    line_set.colors = o3d.Vector3dVector(colors)

    return line_set


if __name__ == "__main__":

    cloud_path, cloud_format = load.get_file()
    # cloud = pcl.load(cloud_path,cloud_format)
    cloud = o3d.io.read_point_cloud(cloud_path, format="ply")

    #Perform PCA on entire object
    vectors, center, result = get_pca(cloud)

    #create vectors in o3d linesets
    line_set = o3d_pca_geometry(vectors, center)

    #display in o3d
    o3d.draw_geometries([cloud, line_set])
コード例 #3
0
    for point in range(len(picked_points) - 1):

        p1 = np_cloud[picked_points[point]]
        p2 = np_cloud[picked_points[point + 1]]

        #triangulate the distance between the two points
        angle = get_angle(p1, p2)
        distance = trangulate_dist(p1[2], p2[2], angle)

        print("Section " + str(point + 1) + ": " + str(distance) + " meters")

        #distance = euclid_dist(p1, p2)
        distance_segments.append(distance)
        total_distance += distance

    print(str(total_distance * 100) + " centimeters")
    print(str(total_distance) + " meters")
    return total_distance, distance_segments


if __name__ == "__main__":
    print("Starting...")

    # Grab new intrinsics (may be changed by decimation)
    #angle = get_angle((10,1,1), (1,1,0) )
    #length = get_length(3,2,angle)
    cloud_path, cloud_format = get_file()
    cloud = o3d.io.read_point_cloud(cloud_path, format=cloud_format)
    #intrinsics = read_intrinsics((cloud_path[:-4] + "_intrinsics.txt"))
    length = manual_measure(cloud)
    print("Stopping...")
コード例 #4
0
import pcl
import open3d

from load import get_file

if __name__ == "__main__":
    target_path, target_format = get_file()
    target_cloud = pcl.load(target_path)
    open3d.registration.registration_ransac_based_on_feature_matching()
    input_path, input_format = get_file()
    input_cloud = pcl.load(input_path)

    ndt = pcl.NormalDistributionsTransform()
    ndt.set_Resolution(1.0)
    ndt.set_StepSize(0.1)

    ndt.set_InputTarget(target_cloud)

    step = ndt.get_StepSize()
    final = ndt.get_FinalNumIteration()

    prob = ndt.get_TransformationProbability()

    ndt.set_InputTarget()
    print(step)
    print(final)
    print(prob)
コード例 #5
0
import pcl
import load


def filter(pcl_cloud, leaf_size=0.01):
    sor = pcl_cloud.make_voxel_grid_filter()
    sor.set_leaf_size(leaf_size, leaf_size, leaf_size)
    cloud_filtered = sor.filter()
    return cloud_filtered


if __name__ == "__main__":
    cp, cf = load.get_file()
    cloud = pcl.load(cp, cf)
    cloud_filtered = filter(cloud, 0.001)
    pcl.save(cloud_filtered, "./data/tests/_test_voxel_grid2.ply")