kopia lustrzana https://github.com/OpenDroneMap/ODM
Merge pull request #1619 from HeDo88TH/fix-pc-rectify-userdata
Fix pc rectify userdatapull/1621/head
commit
066e5bebb4
|
@ -0,0 +1,25 @@
|
||||||
|
import numpy as np
|
||||||
|
from .dimension import Dimension
|
||||||
|
|
||||||
|
class UserDataDimension(Dimension):
|
||||||
|
"""A dimension that stores the user data of a point cloud."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(UserDataDimension, self).__init__()
|
||||||
|
|
||||||
|
def assign_default(self, point_cloud):
|
||||||
|
default = np.full(point_cloud.len(), 0, dtype=np.uint8)
|
||||||
|
super(UserDataDimension, self)._set_values(point_cloud, default)
|
||||||
|
|
||||||
|
def assign(self, *point_clouds, **kwargs):
|
||||||
|
|
||||||
|
# Simply copy the value of the UserData dimension from the original point cloud
|
||||||
|
# to the new point cloud
|
||||||
|
for point_cloud in point_clouds:
|
||||||
|
super(UserDataDimension, self)._set_values(point_cloud, point_cloud.user_data)
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
return 'UserData'
|
||||||
|
|
||||||
|
def get_las_type(self):
|
||||||
|
return 'uint8'
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from opendm.dem.ground_rectification.extra_dimensions.userdata_dimension import UserDataDimension
|
||||||
import pdal
|
import pdal
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from opendm import log
|
from opendm import log
|
||||||
|
@ -23,6 +24,9 @@ def read_cloud(point_cloud_path):
|
||||||
|
|
||||||
cloud = PointCloud.with_dimensions(x, y, z, classification, red, green, blue)
|
cloud = PointCloud.with_dimensions(x, y, z, classification, red, green, blue)
|
||||||
|
|
||||||
|
if "UserData" in arrays.dtype.names:
|
||||||
|
cloud.add_dimension(UserDataDimension(), arrays["UserData"])
|
||||||
|
|
||||||
return pipeline.metadata["metadata"]["readers.las"], cloud
|
return pipeline.metadata["metadata"]["readers.las"], cloud
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +68,9 @@ def write_cloud(metadata, point_cloud, output_point_cloud_path):
|
||||||
arrays['Green'] = green.astype(np.uint8).ravel()
|
arrays['Green'] = green.astype(np.uint8).ravel()
|
||||||
arrays['Blue'] = blue.astype(np.uint8).ravel()
|
arrays['Blue'] = blue.astype(np.uint8).ravel()
|
||||||
|
|
||||||
|
if "UserData" in point_cloud.extra_dimensions:
|
||||||
|
arrays['UserData'] = point_cloud.extra_dimensions["UserData"].ravel()
|
||||||
|
|
||||||
writer_pipeline = {
|
writer_pipeline = {
|
||||||
"pipeline": [
|
"pipeline": [
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue