Esempio n. 1
0
from laspy.file import File
import numpy as np
from Utils.AxisAlignedBox3D import AxisAlignedBox3D
from SliceFunctions.NaiveSliceFromLAS import naive_slice_from_las
from PlotUtils.VtkPointCloud import VtkPointCloud

input_file = "../MantecaDock/dock.las"
output_file = "../MantecaDock/fourPallets.las"

inFile = File(input_file, mode='r')
outFile = File(output_file, mode='w', header=inFile.header)

pointCloud = VtkPointCloud()

sliced = naive_slice_from_las(
    input_file, AxisAlignedBox3D([204.24, -6.7, -1.9], [208.46, -3.24, 3.5]))
# sliced = [[1, 1, 1]]
print("Number of points sliced: %d" % len(sliced))
# for point in sliced:
#     pointCloud.addPoint(point)
#
#     outFile.write(point)
# pdb.set_trace()
allx = np.array([sliced[i][0] for i in range(len(sliced))])
ally = np.array([sliced[i][1] for i in range(len(sliced))])
allz = np.array([sliced[i][2] for i in range(len(sliced))])
outFile.x = allx
outFile.y = ally
outFile.z = allz
# print("Number of points: %d" % len(sliced))
# print('Plotting')
Esempio n. 2
0
from laspy.file import File
from tqdm import tqdm
from PlotUtils.PointCloudPlotQt import create_point_cloud_plot_qt
from Utils.ReadRawLAS import read_raw_las_data
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),
Esempio n. 3
0
"""
A test for Subsample.py
"""
import vtk
from vtk.util import numpy_support
import csv
import numpy as np
from PlotUtils.VtkPointCloud import VtkPointCloud
from SubsampleFunctions.Subsample import subsample

pointCloud = VtkPointCloud()
desired_number_points = 10000

txt = open('../AllentownRoom2_Cleaned.txt', 'rb')

with open('../AllentownRoom2_Cleaned.txt') as f:
    reader = csv.reader(f, delimiter="\t")
    for raw in list(reader):
        fix = raw[0].split()
        pointCloud.addPoint(
            np.asarray([float(fix[0]),
                        float(fix[1]),
                        float(fix[2])]))

print('Subsampling')
print(type(pointCloud.vtkPoints))
data = numpy_support.vtk_to_numpy(pointCloud.vtkPoints.GetData())
sample = subsample(data, desired_number_points)
print(len(sample))
sampleCloud = VtkPointCloud()
for point in sample:
import vtk

from Utils.TextFunctions.SubsampleFromTextData import subsample_from_data
from PlotUtils.VtkPointCloud import VtkPointCloud

pointCloud = VtkPointCloud()
desired_number_points = 10000

# txt = open('AllentownRoom2_Cleaned.txt', 'rb')
#
# points = np.array([])
# with open('AllentownRoom2_Cleaned.txt') as f:
#     reader = csv.reader(f, delimiter="\t")
#     i = 0
#     for raw in list(reader):
#         rand = np.random.randint(0, i+1)
#         fix = raw[0].split()
# # TODO finish this, use numpy arrays then convert at the end

#pointCloud.addPoint(np.asarray([float(fix[0]), float(fix[1]), float(fix[2])]))

points = subsample_from_data("../AllentownRoom2_Cleaned.txt",
                             desired_number_points)
for point in points:
    pointCloud.addPoint(point)

print(len(points))
print('Plotting')
# Renderer
renderer = vtk.vtkRenderer()
renderer.AddActor(pointCloud.vtkActor)
def create_vtkpc_from_array(points):
    pc = VtkPointCloud()
    for point in tqdm(points, total=len(points), desc="Adding to VTK PC"):
        pc.addPoint(point)
    return pc
from laspy.file import File
from tqdm import tqdm
from PlotUtils.PointCloudPlotQt import create_point_cloud_plot_qt
from Filters.ANNGuidedFilter import ann_guided_filter
import pdb
import numpy as np
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()
import vtk
from tqdm import tqdm
from Utils.AxisAlignedBox3D import AxisAlignedBox3D
from SliceFunctions.NaiveSliceFromLAS import naive_slice_from_las
from PlotUtils.VtkPointCloud import VtkPointCloud

input_file = "../MantecaRoom1/rack.las"
out_file = "../MantecaDock/smallArea.las"
pointCloud = VtkPointCloud()
filteredPointCloud = VtkPointCloud()

# inFile = File(out_file, mode='r')
# outFile = File(out_file, mode='w', header=inFile.header)

pointCloud = VtkPointCloud()

print("reading from %s" % input_file)
sliced = naive_slice_from_las(
    input_file,
    AxisAlignedBox3D([197.5000, -6.7000, -.2000], [209.5000, 1.0600, 8.6000]))
# pdb.set_trace()
# 1975000, 2095000, -67000, 10600, -2000, 86000 minx maxx miny maxy minz maxz
for point in tqdm(sliced, total=len(sliced), desc="Adding"):
    pointCloud.addPoint(point)

print("Number of points: %d" % len(sliced))
print('Plotting')
# Renderer
renderer = vtk.vtkRenderer()
renderer.AddActor(pointCloud.vtkActor)
renderer.SetBackground(.2, .3, .4)