Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: Thibaud Capra on February 24, 2017, 12:31:17 PM

Title: Classifying point cloud according to chunk.label
Post by: Thibaud Capra on February 24, 2017, 12:31:17 PM
Hello,
I'm trying to refine a script I've been working on to automate even more parts. This time, depending on how the chunk has been automatically labeled previously, I want to filter or not my point cloud.

Here's my code (Python API 1.2.0), currently not working:

Code: [Select]
import os
import PhotoScan

print(""">>> Initialisation du script <<<""")

doc = PhotoScan.app.document
chunk = doc.addChunk()
type_chunk = ['Green']

for chunk in doc.chunks:
    # Build Dense Cloud
    chunk.buildDenseCloud(quality=PhotoScan.MediumQuality,
    filter=PhotoScan.AggressiveFiltering)
   
    # Classify Point Cloud depending on chunk type
    if not any(type_chunk in chunk.label for type_chunk in type_chunk):
        PhotoScan.DenseCloud.classifyGroundPoints(max_angle = 15.0,
        max_distance = 0.3, cell_size = 1.0)
    else:
        continue
    print("""--------------------- DPC OK ----------------""")
   
    # Build Mesh, then Smooth Mesh depending on chunk type
    if not any(type_chunk in chunk.label for type_chunk in type_chunk):
        chunk.buildModel(surface = PhotoScan.HeightField,
        interpolation = PhotoScan.EnabledInterpolation,
        face_count = PhotoScan.MediumFaceCount, classes = 1)
        chunk.smoothModel(passes = 50)
    else:
        chunk.buildModel(surface = PhotoScan.HeightField,
        interpolation = PhotoScan.EnabledInterpolation,
        face_count = PhotoScan.MediumFaceCount)
        chunk.smoothModel(passes = 100)

Error message:
TypeError: descriptor "classifyGroundPoints' of 'PhotoScan.DenseCloud' object needs an argument

Also, when building the model, i assumed the correct integer for ground points was 1. What's the correct one?

Best regards