Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: smescarzaga on July 02, 2019, 01:19:30 AM
-
I'm trying to automate a workflow that calls for the selection of a percentage of the sparse cloud at each iteration, rather than at some threshold of reconstruction uncertainty, projection error, etc. I've seen below where a threshold variable is passed into a gradual selection
fltr = ps.PointCloud.Filter()
fltr.init(chunk, ps.PointCloud.Filter.ReconstructionUncertainty)
fltr.selectPoints(2 * thresh)
How I can I specify in the script to select a percentage of the initial points?
EDIT: As a clarification, I'd like the filter to select a percentage of the points in my cloud based on reconstruction uncertainty.
-
Hello smescarzaga,
I can suggest to use the following approach:
import Metashape as ps
chunk = ps.app.document.chunk
THRESHOLD = 10 #percentage values for selection
fltr = ps.PointCloud.Filter()
fltr.init(chunk, ps.PointCloud.Filter.ReconstructionUncertainty)
values = fltr.values.copy()
values.sort()
thresh = values[int(len(values)* (1-THRESHOLD/100))]
fltr.selectPoints(thresh)
It will set selected the given percentage of the points (THRESHOLD).
-
This works great! Thank you Alexey!
-
I would like to apply this script to the total number of points as well.
Anybody knows how to do this? I was thinking about implementing len(chunk.point_cloud.points) in some way