Forum

Author Topic: Point Classification for Version 2.0  (Read 6940 times)

benton

  • Newbie
  • *
  • Posts: 31
    • View Profile
Point Classification for Version 2.0
« on: June 29, 2023, 08:32:55 AM »
Metashape version 2.0.2
OS Win 10


Hello,

I would like to classify ground points using Metashape python script, but I am having difficulty finding the correct syntax.

This is what I have tried so far;

Code: [Select]
# chunk.PointCloud.classifyPoints(Unclassified,Ground)
# PointCloud.classifyPoints(Unclassified,Ground)
# chunk.PointCloud.classifyGroundPoints(max_angle=15.0,max_distance=1.0,cell_size=50.0,erosion_radius=0.0)
# chunk.classifyPoints(Unclassified,Ground)
# chunk.classifyGroundPoints(max_angle=15.0,max_distance=1.0,cell_size=50.0,erosion_radius=0.0)
# chunk.DepthMapsData.classifyPoints(Unclassified,Ground)
# chunk.dense_cloud.classifyPoints(source = Metashape.PointClass.Created, target = [Metashape.PointClass.Ground], confidence=0.01)
# chunk.PointCloudData.classifyPoints(source = Metashape.PointClass.Created, target = [Metashape.PointClass.Ground], confidence=0.01)
chunk.classifyPoints(source = Metashape.PointCloudData, target = [Metashape.PointClass.Ground], confidence=0.01)

This is a workflow that I am using and would like to insert a classification component (I have included the failed lines of classification);

Code: [Select]
print('Match Photos')
chunk.matchPhotos(\
downscale=v_accuracy,\
generic_preselection=False,\
reference_preselection=True,\
guided_matching=False,\
filter_mask=False,\
keypoint_limit=v_keypoints,\
tiepoint_limit=v_tiepoints\
)
doc.save()

print('Align Cameras')
chunk.alignCameras()
doc.save()

print('Optimise Cameras')
chunk.optimizeCameras(\
fit_f=True,fit_cx=True,\
fit_cy=True,fit_b1=True,\
fit_b2=True,fit_k1=True,\
fit_k2=True,fit_k3=True,\
fit_k4=False,fit_p1=True,\
fit_p2=True,fit_p3=False,\
fit_p4=False,adaptive_fitting=True,\
tiepoint_covariance=True\
)
doc.save()

print('Build Depth Maps')
chunk.buildDepthMaps(downscale=v_quality, filter_mode=v_filter)
doc.save()

print('Build Point Cloud')
chunk.buildPointCloud(\
source_data=Metashape.DepthMapsData\
, point_colors=True\
)
doc.save()

print('Classify Point Cloud')
# chunk.PointCloud.classifyPoints(Unclassified,Ground)
# PointCloud.classifyPoints(Unclassified,Ground)
# chunk.PointCloud.classifyGroundPoints(max_angle=15.0,max_distance=1.0,cell_size=50.0,erosion_radius=0.0)
# chunk.classifyPoints(Unclassified,Ground)
# chunk.classifyGroundPoints(max_angle=15.0,max_distance=1.0,cell_size=50.0,erosion_radius=0.0)
# chunk.DepthMapsData.classifyPoints(Unclassified,Ground)
# chunk.dense_cloud.classifyPoints(source = Metashape.PointClass.Created, target = [Metashape.PointClass.Ground], confidence=0.01)
# chunk.PointCloudData.classifyPoints(source = Metashape.PointClass.Created, target = [Metashape.PointClass.Ground], confidence=0.01)
chunk.classifyPoints(source = Metashape.PointCloudData, target = [Metashape.PointClass.Ground], confidence=0.01)
doc.save()

print('Export Point Cloud')
chunk.exportPointCloud(\
output_path + "/_RGB_POINT_CLOUD/input.laz"\
, crs=v_crs_to\
, source_data=Metashape.PointCloudData\
, save_point_color=True\
, save_point_classification=True\
, format=Metashape.PointCloudFormatLAZ\
)
doc.save()


Thank You
Ben
« Last Edit: June 29, 2023, 08:41:22 AM by benton »

Paulo

  • Hero Member
  • *****
  • Posts: 1608
    • View Profile
Re: Point Classification for Version 2.0
« Reply #1 on: June 29, 2023, 07:20:52 PM »
Hi,

I would suggest use task approach as in:

Code: [Select]
task = Metashape.Tasks.ClassifyGroundPoints()
task.cell_size = 50.0
task.max_angle = 15.0
task.max_distance = 1.0
task.erosion_radius = 0.0
task.apply('your_chunk')                           
« Last Edit: June 30, 2023, 03:39:37 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

benton

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Point Classification for Version 2.0
« Reply #2 on: June 30, 2023, 08:00:38 AM »
Thank You Paulo

I was able to successfully implement your suggestion

Regards
Ben