-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Hello everybody,
I am calculating volumes of rockfall events using CloudCompare and its M3C2 plugin. As I am dealing with a vast number of events, I want to write a code using the CloudComPy environment to loop over all of the events and calculate the M3C2 distance for them automatically.
However, when I run the M3C2 algorithm on my pointclouds via python something weird happens: It calculates the distances with a shift (see graphic below to see what I mean).
Does somebody have an idea what might be causing this issue?
Left: manual computation of M3C2 in CloudCompare, Right: M3C2 output when using CloudComPy
My code looks like this:
`import subprocess
import os
import cloudComPy as cc
import cloudComPy.M3C2
#initialize CloudCompare
cc.initCC()
cloudcompare_exe = r'c:\Program Files\CloudCompare\CloudCompare.exe'
#USER INPUT
#Parameters
directory = r'motherdirectory'
filepath = r'pathTo .bin file'
output_folder_M3C2 = r'Here I want to store the results'
M3C2_params = r'.txt file containing the M3C2 parameters' #First, you have to perform ONE M3C2 and save the parameters to a file
first_last_year = ['2020', '2024']
name_cirque = 'Aneto'
amount_of_events = 94
#DATA READING
#loading bin file and extract structure
datafile = cc.importFile(filepath)
list_cloud_names = datafile[4]
list_clouds = datafile[1]
firstyear_events = list_clouds[0:(amount_of_events - 1)]
lastyear_events = list_clouds[(amount_of_events + 1):(amount_of_events * 2)]
#PERFORM M3C2
#indexes to loop through clouds
i = 0
M3C2_list = []
#perform M3C2
while i < amount_of_events:
ref = lastyear_events[i]
comp = firstyear_events[i]
M3C2_i = cc.M3C2.computeM3C2([ref,comp], M3C2_params) #compute M3C2 for cloud i +1
M3C2_list.append(M3C2_i) #add entities (clouds) to newly created list
cc.SaveEntities([M3C2_i],os.path.join(output_folder_M3C2,name_cirque +
'M3C2_' + str(i+1)))
i += 1`
And I my parameter .txt file like this: (I exported it directly from the M3C2 popup window in CloudCompare with the parameters desired)
[General]
M3C2VER=1
NormalScale=100
NormalMode=0
NormalMinScale=2
NormalStep=0.5
NormalMaxScale=5
NormalUseCorePoints=false
NormalPreferedOri=4
SearchScale=0.5
SearchDepth=20
SubsampleRadius=14.06076
SubsampleEnabled=false
RegistrationError=0.162448
RegistrationErrorEnabled=true
UseSinglePass4Depth=false
PositiveSearchOnly=false
UseMedian=false
UseMinPoints4Stat=false
MinPoints4Stat=5
ProjDestIndex=1
UseOriginalCloud=false
ExportStdDevInfo=false
ExportDensityAtProjScale=false
MaxThreadCount=10
UsePrecisionMaps=false
PM1Scale=1
PM2Scale=1
Thanks for you help in advance.