Forum

Author Topic: How to get Camera positions and orientations in the model coordinates  (Read 4397 times)

Paul Lee

  • Newbie
  • *
  • Posts: 6
    • View Profile
Hello,
      I have a question about how to get camera positions and orientations in the model coordinates from Camera XML file?
I have read some old topics and try to compute the camera positions, but i think my result is wrong;
Code: [Select]
chunk = PhotoScan.app.document.chunks[0]
cam = chunk.cameras[0]

# Note that transform defaults to a NoneType object rather than an identity
# matrix so the following line will throw an exception if both objects haven't
# been transformed.
pose = chunk.transform.matrix * cam.transform

x = pose.row(0)[3]
y = pose.row(1)[3]
z = pose.row(2)[3]
and i will show my XML file;

camera transform
 <camera id="0" label="DJI_0001.JPG" sensor_id="0" enabled="true">
        <transform>9.9353754099316705e-001 -1.0667474386505985e-001 3.8776973303428809e-002 -8.3545833955933146e-001 1.0740356481423635e-001 9.9406638821910986e-001 -1.7218887252318876e-002 9.7500907161662065e-001 -3.6710065410525856e-002 2.1272396064802211e-002 9.9909952270192637e-001 -6.3408148648161092e-002 0.0000000000000000e+000 0.0000000000000000e+000 0.0000000000000000e+000 1.0000000000000000e+000</transform>
        <orientation>1</orientation>
        <reference x="120.082336888889" y="30.306620111111101" z="-161.27000000000001" enabled="true"/>
      </camera>

chunk transform:
<transform>
      <rotation>-8.5154984092655994e-001 -2.8906664153194872e-001 4.3738237867041524e-001 -5.2402908222904920e-001 4.4381679860009604e-001 -7.2692514763113114e-001 1.6012164005248356e-002 -8.4821408030862222e-001 -5.2941145111346777e-001</rotation>
      <translation>-2.7623808168979078e+006 4.7687376192631284e+006 3.1996855596515518e+006</translation>
      <scale>4.3545534008516684e+000</scale>
    </transform>

so why my translation in chunk transform is too large...

And model point cloud examples:
v -5.048078 -9.708275 -173.960195
v -1.617002 -10.448514 -173.926402
v -5.330289 -10.316930 -173.955417
v -9.931332 -10.259327 -173.937610
v -9.860345 -10.351381 -173.909159
v -10.617223 -10.555562 -173.926107


Thank you and hope for your reply!
« Last Edit: March 06, 2017, 04:31:04 PM by Paul Lee »