Hi bisenberger,
I made a script which makes it possible, by selecting the percent of tie points you'd like to keep.
If it is not exactly what you need, you can try to adjust my script, it is not a hard one.
Best,
Etienne
# Permet de filtrer les tie points en gardant un certain pourcentage de points
import Metashape
import glob
import os
import time
import math
def Tie_Points_Filtering():
doc = Metashape.app.document
# Demande à l'utilisateur du nom du chunk
chunk_name = Metashape.app.getString("What is the chunk's name ?")
# Itération au sein des chunks pour travailler dans celui sélectionner par l'utilisateur
for chunk_it in doc.chunks:
if chunk_name == chunk_it.label:
chunk = chunk_it
# Demande de combien de pourcent de tie points à garder
TARGET_PERCENT = Metashape.app.getFloat("What percent of tie points would you like to keep after the alignement ?")
########################## Filtre des tie points #######################
# Fonction pour supprimer les mauvais tie points
def remove_tie_points(critere,TARGET_PERCENT):
points = chunk.tie_points
num_points = len([i for i in chunk.tie_points.points if i.valid])
target = num_points * TARGET_PERCENT / 100
# Trie des Tiepoints selon leur erreur
list_values = []
f = Metashape.TiePoints.Filter()
f.init(points, criterion = critere)
list_values = [val for i,val in enumerate(f.values) if chunk.tie_points.points[i].valid]
list_values.sort()
# Threshold à appliquer
threshold = list_values[int(target)]
f.selectPoints(threshold)
f.removePoints(threshold)
# Suppresion des tie points pour selon les 3 différentes manières
critere = Metashape.TiePoints.Filter.ReprojectionError
remove_tie_points(critere,int(TARGET_PERCENT))
critere = Metashape.TiePoints.Filter.ReconstructionUncertainty
remove_tie_points(critere,int(TARGET_PERCENT))
critere = Metashape.TiePoints.Filter.ProjectionAccuracy
remove_tie_points(critere,int(TARGET_PERCENT))
chunk.optimizeCameras(fit_f=True, fit_cx=True, fit_cy=True, fit_b1=False, fit_b2=False, fit_k1=True,
fit_k2=True, fit_k3=True, fit_k4=True, fit_p1=True, fit_p2=True, fit_corrections=True,
adaptive_fitting=True, tiepoint_covariance=True)
label = "Scripts/[02] Tie Points Filtering"
Metashape.app.addMenuItem(label, Tie_Points_Filtering)