Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: mrv2020 on April 12, 2021, 06:48:48 AM

Title: Export Select Specific Point Cloud in multiples Chunks on multiples .psx
Post by: mrv2020 on April 12, 2021, 06:48:48 AM
Hi,

I have been using a script that works perfectly for defining shapes and exporting pointclouds through the shape label.

Due to the size of some dense clouds I had to run the 'filter dense cloud' to reduce and stay for a future consultation with the original cloud.

At this moment, I am encountering a certain difficulty.

The script needs to be run for the active dense cloud in each of the chunks, which leads to a manual process of activating the chunk and the cloud.

The projects are composed of multiple situations.
1. A psz file with a single chunk and a single point cloud.
2. A psz file with several chunks and one or more point cloud.

To solve this I noticed that in version 1.4.0 DenseCloud.label was added, so I started to differentiate the point clouds by the respective labels "original" and "reduced1" "reduced2" "reduced'n '" in each chunk.

At the moment of running the code I can't get DenseCloud.label to work, as well as the script to run regardless of the amount of chunks and pointclouds.

I tried to use cloud.key but it didn't work very well, because sometimes more than one type of filtering is done and it loses its order.

Code: [Select]
label = shape.label

chunk.exportPoints(path + "/" + label + "/PointCloud/" + label + "_MDT.LAZ", source_data=Metashape.DenseCloudData , format=Metashape.PointsFormatLAZ, classes = [ Metashape.PointClass.Ground] )

best regards,
Title: Re: Export Select Specific Point Cloud in multiples Chunks on multiples .psx
Post by: Alexey Pasumansky on April 13, 2021, 01:58:27 AM
Hello mrv2020,

To modify the label of the active dense cloud in the chunk:
Code: [Select]
chunk.dense_cloud.label = "Dense Cloud - Reduced " + str(chunk.dense_cloud.key)
Title: Re: Export Select Specific Point Cloud in multiples Chunks on multiples .psx
Post by: mrv2020 on April 13, 2021, 05:43:24 AM
Hi Alexey,

Very good! Worked perfectly! Thank you so much again!

best regards,
Title: Re: Export Select Specific Point Cloud in multiples Chunks on multiples .psx
Post by: mrv2020 on April 14, 2021, 12:33:04 AM
Hi Alexey,

And how to call and activate the dense cloud through its nominal label?

Best,
Title: Re: Export Select Specific Point Cloud in multiples Chunks on multiples .psx
Post by: Alexey Pasumansky on April 14, 2021, 02:51:31 PM
Hello mrv2020,

You need to create some custom function, for example:
Code: [Select]
def set_active_cloud_by_label(chunk, label):
    for dense_cloud in chunk.dense_clouds:
        if dense_cloud.label == label:
            chunk.dense_cloud = dense_cloud
            return 1
   return 0