Forum

Author Topic: Delete tie points outside of bounding box  (Read 6915 times)

stephan

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Delete tie points outside of bounding box
« on: May 18, 2018, 06:08:15 PM »
Here is a puzzle I cannot figure out: I'd like to select all tie points that are a specific distance away from the closest edge of the bounding box, and to be able to set this distance as a function of the length along the X axis of the bounding box. Does anyone know how to make such a selection ?


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15429
    • View Profile
Re: Delete tie points outside of bounding box
« Reply #1 on: May 21, 2018, 07:36:55 PM »
Hello stephan,

You can use the following script as a reference for your task. The example just removes the points of the sparse cloud that are outside the bounding box for each chunk in the project:

Code: [Select]
import PhotoScan
def main():
doc = PhotoScan.app.document
for i in range(len(doc.chunks)):
chunk = doc.chunks[i]
R = chunk.region.rot #Bounding box rotation matrix
C = chunk.region.center #Bounding box center vertor
size = chunk.region.size

if not (chunk.point_cloud and chunk.enabled):
continue
elif not len(chunk.point_cloud.points):
continue
for point in chunk.point_cloud.points:

if point.valid:
v = point.coord
v.size = 3
v_c = v - C
v_r = R.t() * v_c

if abs(v_r.x) > abs(size.x / 2.):
point.valid = False
elif abs(v_r.y) > abs(size.y / 2.):
point.valid = False
elif abs(v_r.z) > abs(size.z / 2.):
point.valid = False
else:
continue

print("Script finished. Points outside the region were removed.")

PhotoScan.app.addMenuItem("Custom menu/Filter point cloud by bounding box", main)
Best regards,
Alexey Pasumansky,
Agisoft LLC

stephan

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Re: Delete tie points outside of bounding box
« Reply #2 on: May 23, 2018, 09:08:46 PM »
Thanks Alexey, that's a big help.