def write_xyz_file(file_name):
    points = read_raw_las_data(file_name)
    pc = create_vtkpc_from_array(points)
    writer = vtk.vtkSimplePointsWriter()
    writer.SetFileName(file_name[:-4] + ".xyz")
    writer.SetInputData(pc.vtkPolyData)
    print("Writing to %s" % file_name[:-4] + ".xyz")
    writer.Write()
示例#2
0
room4 = "../MantecaRoom4/room4S.las"
room5 = "../MantecaRoom5/room5.las"
room6 = "../MantecaRoom6/room6S.las"
dock = "../MantecaDock/dock.las"
room2out = "../MantecaRoom2/room2F.las"
room3out = "../MantecaRoom3/room3F.las"
room4out = "../MantecaRoom4/room4F.las"
room5out = "../MantecaRoom5/room5F.las"
room6out = "../MantecaRoom6/room6F.las"
dockout = "../MantecaDock/dockF.las"
config_file = "roomsconfig.txt"

with File(room2, mode='r') as f:
    print("Starting Room 2")
    # points = subsample_frac_from_las_data("../MantecaRoom1/room1slice.las", sample_frac=.01)
    points = read_raw_las_data(room2)
    points, kwargs = ann_guided_filter(points,
                                       num_neighbors=50,
                                       filter_eps=.07,
                                       config_file=config_file)
    write_to_config(config_file,
                    room2,
                    ann_guided_filter.__name__,
                    kwargs,
                    include_las_name=True)
    points, kwargs = rounding_filter(points, config_file=config_file)
    write_to_config(config_file,
                    room2,
                    rounding_filter.__name__,
                    kwargs,
                    include_las_name=False)
示例#3
0
from Filters.ANNGuidedFilter import ann_guided_filter
from PlotUtils.VtkPointCloud import VtkPointCloud

# input_file = "../MantecaDock/dock.las"
input_file = "../MantecaDock/fourPallets.las"
input2 = "../MantecaDock/palletsRadial.las"
pointCloud = VtkPointCloud()
filteredPointCloud = VtkPointCloud()
pc2 = VtkPointCloud()

with File(input_file, mode='r') as f:
    input_header = f.header

    print("reading %s" % input_file)

    points = read_raw_las_data(input_file)
    for point in tqdm(points, total=len(points), desc="Adding"):
        pointCloud.addPoint(point)

    points2 = read_raw_las_data(input2)
    for point in tqdm(points, total=len(points2), desc="Adding"):
        pc2.addPoint(point)

    filtered_points = ann_guided_filter(points2, 40, .1)
    # filtered_points = radius_outlier_filter(points, r=1, search_eps=0, sd_cutoff=1)
    for filtered_point in tqdm(filtered_points,
                               total=len(filtered_points),
                               desc="Adding"):
        filteredPointCloud.addPoint(filtered_point)

    print("Original has %d points" % len(points))
示例#4
0
input_cloud - set of points
tree_name - file name that tree will be written to
dim - dimension of points
"""
from Utils.ReadRawLAS import read_raw_las_data
import time
from tqdm import trange
from annoy import AnnoyIndex


input1 = "MantecaDock/fourPallets.las"
input1 = "MantecaRoom1/room1ANNGuidedN40Epsp07.las"


def ann_build_save_tree(input_cloud, tree_name, dim=3):
    num = len(input_cloud)
    tree = AnnoyIndex(dim, metric='euclidean')
    for k in trange(num, desc="Preparing for ANN"):
        tree.add_item(k, input_cloud[k])

    start = time.time()
    num_trees = 2
    tree.build(num_trees)
    end = time.time() - start
    print("Building %d trees took %d seconds" % (num_trees, end))
    tree.save(tree_name)
    print("Tree saved")


ann_build_save_tree(read_raw_las_data(input1), "MantecaRoom1/room1AGtree.tree")
sys.path.append('../')
from Filters.ANNGuidedFilter import ann_guided_filter
from tqdm import trange
import numpy as np
from Utils.ReadRawLAS import read_raw_las_data
from laspy.file import File

input1 = "../MantecaDock/fourPallets.las"
output1 = "../Output/temp.las"

pc = np.array([], dtype=np.float32)
pc2 = np.array([], dtype=np.float32)
with File(input1, mode='r') as f:
    input_header = f.header

    raw_points = read_raw_las_data(input1)
    points = ann_guided_filter(raw_points, num_neighbors=50, filter_eps=.07)

    #
    #
    # points2 = read_raw_las_data(output1)
    # for point in tqdm(points2, total=len(points), desc="Adding to pc"):
    #     pc2.addPoint(point)
    #
    # create_point_cloud_plot_qt([pc, pc2])
    # pdb.set_trace()

    with File(output1, mode='w', header=input_header) as file:
        # pdb.set_trace()
        # points = pc.getPoints()
        # print(points)
from Utils.ReadRawLAS import read_raw_las_data
from PlotUtils.VtkPointCloud import VtkPointCloud

# input_file = "../MantecaDock/dock.las"
# x = [1, 2, 3, 4, 6]
# print(binary_search(x, 0, len(x)-1, 5))
input1 = "../MantecaRoom1/rack.las"
input2 = "../MantecaRoom1/rackGuided.las"
pc = VtkPointCloud()
pc2 = VtkPointCloud()
pc3 = VtkPointCloud()
with File(input1, mode='r') as f:
    input_header = f.header
    # print("reading %s" % input_file)

    points = read_raw_las_data(input1)
    for point in tqdm(points, total=len(points), desc="Adding"):
        pc.addPoint(point)

    points_z = [point[2] for point in points]
    points2d = [point[:2] for point in points]

    points_f = ann_guided_filter(points2d, neighbors=1000, filter_eps=.1, dim=2)

    # pdb.set_trace()
    for i in range(len(points)):
        # points_f[i].append(points_z[i])
        points_f[i] = np.append(points_f[i], points_z[i])

    pdb.set_trace()
    for point in tqdm(points_f, total=len(points_f), desc="Adding"):