Forum

Author Topic: python scripting code for camera path estimation.  (Read 5301 times)

raehyuk

  • Newbie
  • *
  • Posts: 12
    • View Profile
python scripting code for camera path estimation.
« on: September 24, 2019, 09:08:23 AM »
Hello.

I have to extract camera path for a given sequence of photos.

I have 2 questions.

1) Does accuracy setting affect the accuracy of camera path? If so, which setting do you recommend (It would be best to set it to HighestAccuracy but it will take too much time)

2) Could you write very simple (it is okay if it is not fully functional) python script for computing path and saving it.

Thank you !

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15472
    • View Profile
Re: python scripting code for camera path estimation.
« Reply #1 on: September 24, 2019, 02:22:46 PM »
Hello raehyuk,

Do you mean to connect the estimated camera locations with some polyline shape? Should the order of the vertices be based on the order of the cameras in the chunk or it should rely on the date&time meta data?
Best regards,
Alexey Pasumansky,
Agisoft LLC

raehyuk

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: python scripting code for camera path estimation.
« Reply #2 on: September 25, 2019, 04:36:43 AM »
Yes it is.

They are ordered according to the timestamps (name of each image).


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15472
    • View Profile
Re: python scripting code for camera path estimation.
« Reply #3 on: October 02, 2019, 06:21:44 PM »
Hello raehyuk,

You can try the following code that creates the camera path track according to the cameras order in the Workspace pane:

Code: [Select]
import Metashape
chunk  = Metashape.app.document.chunk
track  =chunk.addCameraTrack()
track.label = "Camera Track Path"
keyframes = list()
for camera in [camera for camera in chunk.cameras if camera.type == Metashape.Camera.Type.Regular]:
    if not camera.transform:
        continue #skip NA cameras
    pos = chunk.addCamera()
    pos.type = Metashape.Camera.Type.Keyframe
    pos.transform = camera.transform
    keyframes.append(pos)
track.keyframes = keyframes
chunk.camera_track = track
print("Done")
Best regards,
Alexey Pasumansky,
Agisoft LLC