Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: andyroo on December 02, 2017, 01:31:10 AM
-
I am trying to figure out how to get the number of selected points. Do I need to iterate through the whole cloud looking at the [selected] flag or can I query the cloud attributes like:
npoints =len(chunk.point_cloud.points)
?
So far the only way I've found is to iterate:chunk = doc.chunk
points = chunk.point_cloud.points
nselected = len([True for point in points if point.valid is True and point.selected is True])
-
You can solve it with a list comprehension, like you started on.
chunk = doc.chunk
points = chunk.point_cloud.points
nselected = len([p for p in points if p.selected])
or just
chunk = doc.chunk
nselected = len([p for p in chunk.point_cloud.points if p.selected])
It calculates it really quickly on my computer.