From 8ead486524ad22cf040d4f3e4a5143f11fb4b97e Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Tue, 7 Feb 2023 16:37:17 +0200 Subject: [PATCH 1/3] Color LAS load and save --- src/3rdParty/_PCL/services/LasIOSupport.jl | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/3rdParty/_PCL/services/LasIOSupport.jl b/src/3rdParty/_PCL/services/LasIOSupport.jl index a8081d68d..cbf7d7a6c 100644 --- a/src/3rdParty/_PCL/services/LasIOSupport.jl +++ b/src/3rdParty/_PCL/services/LasIOSupport.jl @@ -12,13 +12,16 @@ function loadLAS( filepath::AbstractString ) header, points = load(filepath) - pts = (p->[ - p.x*header.x_scale+header.x_min; - p.y*header.y_scale+header.y_min; - p.z*header.z_scale+header.z_min - ]).(points) - @cast pts_[i,d] := pts[i][d] - return PointCloud(pts_) + pts = map(points) do p + SA[p.x*header.x_scale+header.x_min; p.y*header.y_scale+header.y_min; p.z*header.z_scale+header.z_min; 1] + end + + colors = map(points) do pnt + RGB(pnt.red, pnt.green, pnt.blue) + end + + colored_points = PointXYZ.(colors, pts) + return PointCloud(;points=colored_points, width=UInt32(length(colored_points)), height=UInt32(1)) end @@ -33,7 +36,10 @@ function saveLAS( x = map(p->p.data[1], pc.points) y = map(p->p.data[2], pc.points) z = map(p->p.data[3], pc.points) - pCloud = LasPoint2.(round.(scale*x),round.(scale*y),round.(scale*z), 1, 0, 0, 0, 0, 0, 1, 1, 1); + r = map(p->p.color.r, pc.points) + g = map(p->p.color.g, pc.points) + b = map(p->p.color.b, pc.points) + pCloud = LasPoint2.(round.(scale*x),round.(scale*y),round.(scale*z), 1, 0, 0, 0, 0, 0, r, g, b); tim = unix2datetime(pc.header.stamp*1e-6) # now() From 13e52a35e92a4772b085f99288e6d3d185432a76 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Tue, 7 Feb 2023 17:14:20 +0200 Subject: [PATCH 2/3] Also support streams --- src/3rdParty/_PCL/services/LasIOSupport.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdParty/_PCL/services/LasIOSupport.jl b/src/3rdParty/_PCL/services/LasIOSupport.jl index cbf7d7a6c..3350d8006 100644 --- a/src/3rdParty/_PCL/services/LasIOSupport.jl +++ b/src/3rdParty/_PCL/services/LasIOSupport.jl @@ -27,7 +27,7 @@ end # TODO, make save LAS function saveLAS( - filepath::AbstractString, + filepath::Union{AbstractString, Stream}, pc::PointCloud; scale=1000 ) From eda64b93b2e933a9e394b540ecd8e013755bec97 Mon Sep 17 00:00:00 2001 From: Dehann Fourie <6412556+dehann@users.noreply.github.com> Date: Thu, 9 Feb 2023 13:10:53 -0800 Subject: [PATCH 3/3] Update src/3rdParty/_PCL/services/LasIOSupport.jl --- src/3rdParty/_PCL/services/LasIOSupport.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdParty/_PCL/services/LasIOSupport.jl b/src/3rdParty/_PCL/services/LasIOSupport.jl index 3350d8006..06f8ea3d7 100644 --- a/src/3rdParty/_PCL/services/LasIOSupport.jl +++ b/src/3rdParty/_PCL/services/LasIOSupport.jl @@ -27,7 +27,7 @@ end # TODO, make save LAS function saveLAS( - filepath::Union{AbstractString, Stream}, + filepath::Union{<:AbstractString, <:Stream}, pc::PointCloud; scale=1000 )