Forum

Author Topic: can I get a list of the cameras tied to each point in the sparse cloud?  (Read 7200 times)

jeremyeastwood

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Hi there,

I'd like to link each point in the sparse point cloud (also dense cloud later on) to the cameras which "see" it (the cameras in which that point in space appears).  Alternatively I'd like a list of the points seen by each camera.

Can I do this through the python api directly, i.e. is there a property of a point in the chunk.point_cloud.points (or similar) which gives me the cameras, or do I have to calculate the camera footprint and find the point locations which fall within those bounds?

Thanks

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: can I get a list of the cameras tied to each point in the sparse cloud?
« Reply #1 on: December 11, 2015, 12:55:41 PM »
Hello Jeremy,

What information about the points for each photo do you wish to export? Point index an XYZ coordinates?
For the sparse cloud you can use chunk.point_cloud.projections[camera] method to get the list projections present on the photo (they have point index attribute).

The access to the dense cloud points is currently not available via Python.
Best regards,
Alexey Pasumansky,
Agisoft LLC

jeremyeastwood

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: can I get a list of the cameras tied to each point in the sparse cloud?
« Reply #2 on: December 11, 2015, 10:42:10 PM »
Hi Alexey,

Thanks for the quick response.  I've now got what looks like camera-local coords for each tie-point seen in each camera (e.g. chunk.point_cloud.projections[chunk.cameras[0]][0].coord, so what I need to do is link this one specific point to one of the points in the sparse point cloud, i.e. a specific index in chunk.point_cloud.points.  Is there a way to do this?

What I'm trying to do is link each point in the sparse point cloud to the cameras used to locate it, so that I can generate a lookup where I can select some points and see the relevant cameras, or select some cameras and see the points they generated.

Thanks again for your help

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: can I get a list of the cameras tied to each point in the sparse cloud?
« Reply #3 on: December 30, 2015, 12:07:40 PM »
Hello Jeremy,

The following code highlights the points related to the valid matches on the selected cameras:
Code: [Select]
#highlights valid matches for selected photos in active chunk
#compatibility: Agisoft PhotoScan Pro 1.2.1

import PhotoScan

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 = list()
for photo in chunk.cameras:
if photo.selected:
selected_photos.append(photo)

for photo in selected_photos:

point_index = 0
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
else:
points[point_index].selected = True

PhotoScan.app.update()

print("Highlighted points for the following cameras: ")
print(selected_photos)
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: can I get a list of the cameras tied to each point in the sparse cloud?
« Reply #4 on: December 30, 2015, 12:13:36 PM »
And the following script should work similar to GUI "Filter Photos by Points" function:
Code: [Select]
#selects cameras where the projections of the selected tie points do appear
#compatibility: Agisoft PhotoScan Pro 1.2.1

import PhotoScan

doc = PhotoScan.app.document
chunk = doc.chunk
point_cloud = chunk.point_cloud
points = point_cloud.points
projections = point_cloud.projections

npoints = len(points)

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

PhotoScan.app.update()

print("For the selected points the following cameras were used: ")
print(selected_photos)
Best regards,
Alexey Pasumansky,
Agisoft LLC

jeremyeastwood

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: can I get a list of the cameras tied to each point in the sparse cloud?
« Reply #5 on: January 22, 2016, 02:51:49 AM »
Thanks so much for writing these scripts Alexey - really helpful!