Forum

Author Topic: Mesh creation based on specific dense cloud classes  (Read 3047 times)

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Mesh creation based on specific dense cloud classes
« on: February 27, 2017, 11:50:15 AM »
Hello,
I'm trying to mesh my dense cloud after classifying it, and only mesh the points within the "ground" class.

According to what I found on the forums, here's the list of existing classes.

Code: [Select]
Created = 0,
Unclassified = 1,
Ground = 2,
LowVegetation = 3,
MediumVegetation = 4,
HighVegetation = 5,
Building = 6,
LowPoint = 7,
ModelKeyPoint = 8,
Water = 9,
OverlapPoints = 12

My code is the following:
Code: [Select]
import os, PhotoScan

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 or not depending on chunk type
    if not any(type_chunk in chunk.label for type_chunk in type_chunk):
        doc.chunk.dense_cloud.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 = 2)
        chunk.smoothModel(passes = 50)
    else:
        chunk.buildModel(surface = PhotoScan.HeightField,
        interpolation = PhotoScan.EnabledInterpolation,
        face_count = PhotoScan.MediumFaceCount)
        chunk.smoothModel(passes = 100)

I get the following error when running it:

Code: [Select]
2017-02-27 09:35:28   File "C:/PFE_CAPRA/Scripts/170227/AOI_Process_PartII.py", line 84, in <module>
2017-02-27 09:35:28     face_count = PhotoScan.MediumFaceCount, classes = 2)
2017-02-27 09:35:28 TypeError: classes should be a list of int

Any help is appreciated.

Best regards.
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14771
    • View Profile
Re: Mesh creation based on specific dense cloud classes
« Reply #1 on: February 27, 2017, 11:58:37 AM »
Hello Thibaud,

The list of int should be:
Code: [Select]
classes = [2]
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Mesh creation based on specific dense cloud classes
« Reply #2 on: February 27, 2017, 01:00:37 PM »
Right, sometimes I feel kind of stupid with my rookie mistakes...

Another question, how can I avoid creating a new chunk (or instantly delete it?)

Every time I run my script I create a chunk and it ends up ruining the script because I modify OBJ files that are supposedly created during the script (dense clouds etc.) but since the new chunk is empty, no file's created and script can't run completely.

I'd like to cut it out, as the script is supposed to run on projects with already created chunks.

Best regards.
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14771
    • View Profile
Re: Mesh creation based on specific dense cloud classes
« Reply #3 on: February 27, 2017, 01:06:09 PM »
Hello Thibaud,

If you do not need to create a new chunk, then you need to remove doc.addChunk() line.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Mesh creation based on specific dense cloud classes
« Reply #4 on: February 27, 2017, 04:09:28 PM »
Thank you, as usual!

Any idea why my cloud isn't smoothed?

I have two chunks, one's named "trou18-Approche", the other one is "trou18-Green". The first one is smoothed and all good, the second one isn't smoothed!

I think it has to do with my if not condition here :

Code: [Select]
# 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 = 2)
        chunk.smoothModel(passes = 50)
    else:
        chunk.buildModel(surface = PhotoScan.HeightField,
        interpolation = PhotoScan.EnabledInterpolation,
        face_count = PhotoScan.MediumFaceCount)
        chunk.smoothModel(passes = 100)

Should I use elif any(type_chunk in chunk.label for type_chunk in type_chunk): instead of else: ?

EDIT: It works with ELIF.
« Last Edit: February 27, 2017, 05:02:37 PM by Thibaud Capra »
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--