1
Python and Java API / Filter Photos By Point - how does Photoscan do this so quickly?
« on: January 18, 2018, 08:13:03 AM »
Hello all,
For context, I am using a chunk with 170 cameras and a sparse cloud of 11936 tie points.
Using the right-click "Filter photos by points" option, Photoscan returns the relevant photos in 0.01325 sec.
Using a python script found elsewhere on these forums, shown below, it takes 2.00 sec.
Why is there this much of a difference? How is the right-click function able to perform so much faster?
Edit: code adjustment
For context, I am using a chunk with 170 cameras and a sparse cloud of 11936 tie points.
Using the right-click "Filter photos by points" option, Photoscan returns the relevant photos in 0.01325 sec.
Using a python script found elsewhere on these forums, shown below, it takes 2.00 sec.
Why is there this much of a difference? How is the right-click function able to perform so much faster?
Code: [Select]
#selects cameras where the projections of the selected tie points do appear
#compatibility: Agisoft PhotoScan Pro 1.2.1
import PhotoScan
import time
doc = PhotoScan.app.document
chunk = doc.chunk
point_cloud = chunk.point_cloud
points = point_cloud.points
projections = point_cloud.projections
npoints = len(points)
selected_photos = []
start_time = time.time()
for photo in chunk.cameras:
point_index = 0
photo.selected = False
for proj in projections[photo]:
track_id = proj.track_id
while point_index < npoints and points[point_index].track_id < track_id:
point_index += 1
if point_index < npoints and points[point_index].track_id == track_id:
if not points[point_index].valid:
continue
elif points[point_index].selected == True:
photo.selected = True
selected_photos.append(photo.label)
PhotoScan.app.update()
end_time = time.time()
print("Time Taken: "+str(end_time-start_time)+" sec")
print("For the selected points the following cameras were used: ")
print(selected_photos)
Edit: code adjustment