Author Topic: Exported cameras not scaled  (Read 1794 times)


  • Newbie
  • *
  • Posts: 35
    • View Profile
Exported cameras not scaled
« on: June 17, 2019, 03:55:05 PM »
I'm working with some custom software that allows some photo overlay tools on dense clouds.  When I import the dense cloud and camera position data from an unscaled model, it works fine.  However, when I import the same from a scaled model, the camera positions are not correct.  We use the script below to export the .xml camera position file as well as a file that contains the transform and x,y.z position data for every camera.  I've looked these over and it looks like the position data exported from the scaled model is exactly the same as that pulled from an unscaled version of the same model.  I'm wondering if anybody knows why this is and how I can get position data for the cameras in the scaled coordinate system.

import PhotoScan
import math
import os
import json

doc =
chunk = doc.chunk # FIXME thyis is just the active chunk
cams = chunk.cameras

proj_path = doc.path
proj_dir, proj_name = os.path.split(proj_path)
proj_name = proj_name[:-4]

outputs = {}

cams_filename = proj_dir + '/' + proj_name + '.cams.xml'
meta_filename = proj_dir + '/' + proj_name + '.meta.json'

meta_file = open(meta_filename, 'w')


for cam in cams:
    key = cam.key
    path =
    center =
    if center is not None:
        geo = chunk.transform.matrix.mulp(center)
        if is not None:
            lla = list(
        center = list(center)
    agi_trans = cam.transform
    trans = None
    if agi_trans is not None:
        trans = [list(agi_trans.row(n)) for n in range(agi_trans.size[1])]
    outputs[key] = {'path' : path, 'center' : center, 'transform' : trans}
meta_file.write(json.dumps({'cameras' : outputs}, indent=4))


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14110
    • View Profile
Re: Exported cameras not scaled
« Reply #1 on: June 20, 2019, 08:22:51 PM »
Hello willfig,

camera.transform matrices are defined in the internal coordinate system. To get the geographic coordinates from them you need to apply chunk.transform and then method (like in your script).

Can you specify, what is desired output from the script?
Best regards,
Alexey Pasumansky,
Agisoft LLC


  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Exported cameras not scaled
« Reply #2 on: June 21, 2019, 09:23:22 AM »
Hi Alexey,

The files produced by the script allow this external software to show the camera points and also have their orientation so that images can be projected back onto the dense cloud. What we've realised is that if we have a dense cloud that we've scaled in MS (using markers and/or scale bars...but no camera GPS data...we're underwater), and we export the dense cloud and run this script to get the two output files, the cameras are not in the correct position in this external software.  If we copy the chunk, turn off all scale features, update scaling and reset transformation and then do the same process, the cameras are in the correct position.  When I compare the script output files from the scaled and unscaled models they appear exactly the same...which is odd.  And importantly, I can see in the .json that even in the file exported from the scaled model, the camera centers at least are not correct.  I say that by comparing them with the estimated x,y,z values in the reference pane.  Any idea if we're doing something wrong in the script such that we're not getting the scaled values out of it?   I've attached the two .json files that come from the script from one of our projects.
 I exported it from both a scaled and unscaled version of the model. Thanks.



  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Exported cameras not scaled
« Reply #3 on: July 04, 2019, 03:35:55 PM »
Hi Alexey,

Just wondering if you’d had any thoughts on this?