kopia lustrzana https://github.com/OpenDroneMap/ODM
Preserve UserData dimension
rodzic
ffa7871c33
commit
be142549e3
|
@ -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
|
||||
from opendm.dem.ground_rectification.extra_dimensions.userdata_dimension import UserDataDimension
|
||||
import pdal
|
||||
import numpy as np
|
||||
from opendm import log
|
||||
|
@ -22,6 +23,7 @@ def read_cloud(point_cloud_path):
|
|||
blue = arrays["Blue"]
|
||||
|
||||
cloud = PointCloud.with_dimensions(x, y, z, classification, red, green, blue)
|
||||
cloud.add_dimension(UserDataDimension(), arrays["UserData"])
|
||||
|
||||
return pipeline.metadata["metadata"]["readers.las"], cloud
|
||||
|
||||
|
@ -63,6 +65,7 @@ def write_cloud(metadata, point_cloud, output_point_cloud_path):
|
|||
arrays['Red'] = red.astype(np.uint8).ravel()
|
||||
arrays['Green'] = green.astype(np.uint8).ravel()
|
||||
arrays['Blue'] = blue.astype(np.uint8).ravel()
|
||||
arrays['UserData'] = point_cloud.extra_dimensions["UserData"].ravel()
|
||||
|
||||
writer_pipeline = {
|
||||
"pipeline": [
|
||||
|
|
Ładowanie…
Reference in New Issue