Forum

Author Topic: Animation to replicate image camera positions  (Read 183 times)

vik748

  • Newbie
  • *
  • Posts: 7
    • View Profile
Animation to replicate image camera positions
« on: September 02, 2019, 06:12:35 AM »
Hi,
I would like create an animation looking at the 3D model from the image camera positions.  ie. the positions we can when we right click and image and click "Look Through".
When I tried to add these positions to the animation and check the transform, I see some difference in the numbers.  Could someone suggest how one might be able to generate the animation camera track file containing all the image camera positions? A script would be nice, but if you can point out the math required, I can comeup with the python script.

Thanks in advance. Cheers!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 10631
    • View Profile
Re: Animation to replicate image camera positions
« Reply #1 on: September 02, 2019, 02:55:12 PM »
Hello vik748,

Please check the following script that will create new camera track, where each keyframe corresponds to the location/orientation of every aligned camera in the chunk:

Code: [Select]
import Metashape

chunk = Metashape.app.document.chunk
chunk.addCameraTrack()
track = list()
for camera in list(chunk.cameras):
if (camera.type == Metashape.Camera.Type.Regular) and camera.transform:
keyframe = chunk.addCamera()
keyframe.type = Metashape.Camera.Type.Keyframe
keyframe.transform = camera.transform
track.append(keyframe)
chunk.camera_tracks[-1].keyframes = track
chunk.camera_track = chunk.camera_tracks[-1]
Best regards,
Alexey Pasumansky,
AgiSoft LLC

Paulo

  • Sr. Member
  • ****
  • Posts: 290
    • View Profile
Re: Animation to replicate image camera positions
« Reply #2 on: September 02, 2019, 07:37:08 PM »
Hi Alexey,

it seems keyframe transform has Y and Z axis inverted relative to camera transform, so that:
Code: [Select]
keyframe.transform = camera.transformhas to be modified to:
Code: [Select]
keyframe.transform = camera.transform * Metashape.Matrix().Diag([1, -1, -1, 1])
so that each keyframe looks in direction of model instead of opposite direction..... see https://www.agisoft.com/forum/index.php?topic=11146.0
Best Regards,

Paul Pelletier

kaell

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Animation to replicate image camera positions
« Reply #3 on: September 05, 2019, 09:30:30 PM »
Hi Alexey,

it seems keyframe transform has Y and Z axis inverted relative to camera transform, so that:
Code: [Select]
keyframe.transform = camera.transformhas to be modified to:
Code: [Select]
keyframe.transform = camera.transform * Metashape.Matrix().Diag([1, -1, -1, 1])
so that each keyframe looks in direction of model instead of opposite direction..... see https://www.agisoft.com/forum/index.php?topic=11146.0

Hi Paulo,

Can this script be used on Photoscan 1.4?

Paulo

  • Sr. Member
  • ****
  • Posts: 290
    • View Profile
Re: Animation to replicate image camera positions
« Reply #4 on: September 06, 2019, 02:14:06 AM »
I do not think so... seems keyframe concept was introduced with Metashape 1.5
Best Regards,

Paul Pelletier