Forum

Author Topic: Camera Coordinate Export  (Read 15304 times)

Geo

  • Newbie
  • *
  • Posts: 35
    • View Profile
Camera Coordinate Export
« on: April 12, 2013, 07:55:43 PM »
I have a project with ground control.  I would like to export the derived camera coordinates.  I tried exporting a camera calibration, but it did not seem to contain the camera positions.  I tried exporting a point cloud and it does not seem to contain the camera positions.  Can someone please tell how to obtain the derived camera positions.  Thanks you, Jim

RalfH

  • Sr. Member
  • ****
  • Posts: 344
    • View Profile
Re: Camera Coordinate Export
« Reply #1 on: April 13, 2013, 11:40:43 AM »
This can be found under Tools > Export > Export cameras

Geo

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Camera Coordinate Export
« Reply #2 on: April 13, 2013, 04:50:25 PM »
Hi Ralf,  Thank you so much for responding - I appreciate it very much.  I tried the export as you described and it provides lots of camera information, but does not seem to show the camera coordinates unless I am reading the XML data incorrectly.  Here is an XML extract of one of the cameras.

<camera label="CF000562.tif">
  <resolution width="10328" height="7760" />
- <calibration>
  <width>10328</width>
  <height>7760</height>
  <fx>1.4479973408764949e+004</fx>
  <fy>1.4535791730453300e+004</fy>
  <cx>5.6405986514219658e+003</cx>
  <cy>4.0217494497967714e+003</cy>
  <skew>1.0248499033259051e+001</skew>
  <k1>4.7129602820834129e-002</k1>
  <k2>-8.9743950898289060e-001</k2>
  <k3>2.6755592513789348e+000</k3>
  <p1>-9.7256261531628758e-003</p1>
  <p2>9.0270191676931101e-003</p2>
  </calibration>
  <transform>9.9969884077091586e-001 -7.3242928484923983e-003 2.3421838005515637e-002 3.7121356222894308e-002 7.2217738400186656e-003 9.9996398249964125e-001 4.4586641565500223e-003 5.7372106110421824e-002 -2.3453650971452515e-002 -4.2881741716965030e-003 9.9971572850404955e-001 -2.1255313213737501e-001 0.0000000000000000e+000 0.0000000000000000e+000 0.0000000000000000e+000 1.0000000000000000e+000</transform>
  </camera>

Am I reading the out out incorrectly?  I have WGS 84 UTM zone 10 datum set and I would expect the camera coordinates to be shown in the same format.  Any thoughts?

Thank you,
Jim

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: Camera Coordinate Export
« Reply #3 on: April 13, 2013, 06:56:15 PM »
Hello Jim,

If you need only estimated coordinates shown on the corresponding tab of the Ground Control pane, then you can just use save button on the pane toolbar and check on "save estimated" option.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Geo

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Camera Coordinate Export
« Reply #4 on: April 13, 2013, 09:13:33 PM »
Hi Alexey - Fantastic, That works.  Very much appreciated

Jim

jedfrechette

  • Full Member
  • ***
  • Posts: 131
  • Lidar Guys
    • View Profile
    • www.lidarguys.com
Re: Camera Coordinate Export
« Reply #5 on: April 13, 2013, 09:19:09 PM »
I'm glad you found a solution, but just for completeness:

The exported camera XML files only provide part of the information you need to determine camera positions. The contents of the <transform> tag is a 4X4 transformation matrix, copied below in a more readable form. Hopefully without to many transcription errors.

0.999-0.007-0.023-0.037
0.007-0.999-0.004-0.057
-0.023-0.0040.999-.0212
0.000-0.000-0.0001.000

The first 3 rows of the last column should give you the coordinates of the camera, however, those values don't look like any UTM coordinates I've ever seen. That is because there is an additional transformation applied at the chunk level and you also need to know that. The camera XML files should probably have an additional <chunk_transform> tag or the option of baking the complete transform in to the file.

You can get the coordinates for the first camera in the first chunk with the following Python snippet. Of course, for a real application you would probably want to loop through all the chunks and cameras saving the x, y, z values to a file.

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 * cam.transform

x = pose.row(0)[3]
y = pose.row(1)[3]
z = pose.row(2)[3]
Jed

Geo

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Camera Coordinate Export
« Reply #6 on: April 13, 2013, 11:13:57 PM »
Hi Jed,  Thank you for the detailed info about the transform and your python script.  It is a beyond my understanding, but I am sure others will find it very helpful.  I understand that the estimated coordinates as Alexey describes are valid estimated coordinate values without further transformation?

Thank you,
Jim

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: Camera Coordinate Export
« Reply #7 on: April 13, 2013, 11:34:49 PM »
Hello Jim,

Estimated coordinates saved through Ground Control pane are in the same coordinate system the source coordinates are.
Best regards,
Alexey Pasumansky,
Agisoft LLC

cbudin

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Camera Coordinate Export
« Reply #8 on: April 16, 2013, 01:18:00 AM »

I am also trying to get the cameras' positions as well as orientations.  I am using PhotoScan Standard on small object scans so I don't see the Ground Control pane anywhere.  Also, I am hoping to modify camera position and orientation and re-import the result back into PhotoScan.  Some of the other camera export formats do include the camera positions, but it looks like PhotoScan can't re-import those formats.  What should I do here?

Thanks,
Clay Budin

RalfH

  • Sr. Member
  • ****
  • Posts: 344
    • View Profile
Re: Camera Coordinate Export
« Reply #9 on: April 19, 2013, 10:37:39 PM »
The cameras.xml contains all necessary data. You can extract the parameters, transform them, put them back into the xml and then re-import.

See also these threads:
http://www.agisoft.ru/forum/index.php?topic=1004.msg4961#msg4961
http://www.agisoft.ru/forum/index.php?topic=965.msg4804#msg4804