Forum

Author Topic: Metashape External Orientation instead of Aerial Triangulation  (Read 10783 times)

Isaac H. E.

  • Newbie
  • *
  • Posts: 34
    • View Profile
Hello Alexey,

I would like to to use the exterior orientation (EO) (XYZ+OPK) provided by a third party post processing INS (GNSS+IMU) software of a group of images part of a photogrammetric block.

Is it possible to "force" the EO information of each image loaded in to MetaShape to avoid having to rurn MetaShape "Align Photos..." procedure?

Best Regards

Isaac

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15160
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #1 on: April 29, 2019, 05:21:33 PM »
Hello Isaac,

Yes, knowing the complete exterior orientation parameters (location and orientation angles) you can skip Align Cameras stage. It would work similar to Import Cameras feature that is Building Point cloud according to the imported EO/IO data - the images are matched, but EO and IO parameters are not refined.

So if you would like to do some further processing, like dense cloud generation in Metashape, then you would likely need to import the calibration parameters as well.

If your external format is not supported by Import Cameras operation, the procedure can be implemented via Python script.
Best regards,
Alexey Pasumansky,
Agisoft LLC

cstallings@b1rd.io

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #2 on: February 27, 2020, 02:04:26 AM »
Hello,

We are facing a similar issue. I have a camera system that I has exterior orientation (XYZ, RPH), calibrated cameras in Agisoft format, and an existing DEM surface. I just want to hold the eo and rectify the images.  All options to proceed will not work without first doing the align photos step. I want to skip this step and just rectify the images but it will not let me. Please let me know how to skip the align photos step and just rectify the images to the current surface and the initial EO's from the inertial navigation system.

Thanks

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15160
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #3 on: February 28, 2020, 05:17:21 PM »
Hello cstallings,

If you need to position the cameras according to the imported Source Reference values you should use Python scripting and assign corresponding transformation matrix to each camera. After that load proper calibration information for the camera and use Build Points command from the tools menu to perform the image matching, preserving the current exterior and interior orientation data.

Please check if the following script does the proper task of orienting the cameras based on the Reference data:
Code: [Select]

import Metashape

chunk = Metashape.app.document.chunk
crs = chunk.crs
T = chunk.transform.matrix

origin = None
for camera in chunk.cameras:
if not camera.type == Metashape.Camera.Type.Regular:
continue
if not camera.reference.location:
continue
if not camera.reference.rotation:
continue

pos = crs.unproject(camera.reference.location)
m = crs.localframe(pos)
rot = Metashape.utils.ypr2mat(camera.reference.rotation) * Metashape.Matrix().Diag([1, -1, -1])
R = Metashape.Matrix().Translation(pos) * Metashape.Matrix().Rotation(m.rotation().t() * rot)

if not origin:
origin = pos
chunk.transform.matrix = Metashape.Matrix().Translation(origin)
T = chunk.transform.matrix

camera.transform = T.inv() * R
chunk.updateTransform()
Best regards,
Alexey Pasumansky,
Agisoft LLC

cstallings@b1rd.io

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #4 on: February 28, 2020, 08:45:21 PM »
Alexey,

This worked perfectly. Thank you so much for your help!

MurrayW

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #5 on: August 12, 2020, 04:49:16 AM »
Hi all/anyone.....
(Metashape Professional 1.6.1 10009 64 bit)

I am having problems with this script. 
As a test I set up a small block, went through the steps to produce an orthophoto  - and it is accurate.
I then exported cameras as type Omega Phi Kappa .txt and the camera calibration.

then I set up the exact same photos in a new psx
I imported the camera callibration, and  then the cameras as XYZ OPK
I used this script Tools/Run Script

Now the model has the photos incorrect - see attached image
In the Model Window, the photos are represented with what seems to be:
 -  Phi = almost 90; it looks like the aeroplane nose is pointing to the sky
 - Omega = almost 90; it looks the wings of the plane are pointing backwards/forwards

Thanks and cheers
Murray

Paulo

  • Hero Member
  • *****
  • Posts: 1359
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #6 on: August 12, 2020, 06:20:16 AM »
Hi Murray,

if you are importing external orientation as XYZOPK (Omega Phi Kappa) then you should change following line of code:
Code: [Select]
rot = Metashape.utils.ypr2mat(camera.reference.rotation) * Metashape.Matrix().Diag([1, -1, -1])by:
Code: [Select]
rot = Metashape.utils.opk2mat(camera.reference.rotation) * Metashape.Matrix().Diag([1, -1, -1])
and it should work...

a more general way is to use euler2mat utility which would work whatever euler angle convention is used for orientation (YawPitchRoll, OmegaPhiKappa, PhiKappaOmega or AlphaNuKappa) defined by chunk.euler_angles as in:
Code: [Select]
rot = Metashape.utils.euler2mat(camera.reference.rotation, chunk.euler_angles) * Metashape.Matrix().Diag([1, -1, -1])
« Last Edit: August 13, 2020, 06:35:54 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

MurrayW

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #7 on: August 14, 2020, 03:53:50 AM »
Thanks Paulo, 

opk2mat in place of ypr2mat = Omega Phi Kappa instead of Yaw Pitch Roll.

of course! 

I am a python-beginner...

cheers
Murray

theoremwr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #8 on: October 16, 2020, 04:44:30 PM »
The first script works great with P4 photos but does not run with Parrot Anafi data.  Is there any chance this could be made to work? Thanks
« Last Edit: October 16, 2020, 04:46:40 PM by theoremwr »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15160
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #9 on: October 22, 2020, 11:43:12 PM »
Hello theoremwr,

Can you please share a small set of images to support@agisoft.com in order to check that? If the exterior orientation data is available from the text file, please provide it as well.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15160
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #10 on: November 26, 2020, 06:22:55 PM »
Hello theoremwr,

Thank you for sharing the sample images. We see that the orientation angles are in Parrot namespace which is not yet supported, but we'll try to add support for it in the next version update.

Also the angles are present in the pix4d namespace, which should be read, if the namespace is properly defined, however, in the provided files there's some long link which is not interpreted by Metashape and therefore ignored.

The values, however, can be read using Python even in the current version, if you parse camera.photo.imageMeta() output for every camera and access the required fields.
Best regards,
Alexey Pasumansky,
Agisoft LLC

theoremwr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #11 on: December 07, 2020, 04:56:40 PM »
Thanks for reply,  Would you mind showing me where to add that script change to make it run with the current version?  Thanks again.

Paulo

  • Hero Member
  • *****
  • Posts: 1359
    • View Profile
Re: Metashape External Orientation instead of Aerial Triangulation
« Reply #12 on: December 07, 2020, 08:39:24 PM »
Hi theoremwr,

assuming you want to get Parrot CameraYawDegree, CameraPitchDegree and CameraRollDegree from camera.photo.imageMeta() for each image then following code should do the tricK:
Code: [Select]
chunk = Metashape.app.document.chunk
for  camera in chunk.cameras:
    camera.reference.rotation = Metashape.Vector((float(camera.photo.imageMeta()['Parrot/CameraYawDegree']),90+float(camera.photo.imageMeta()['Parrot/CameraPitchDegree']),float(camera.photo.imageMeta()['Parrot/CameraRollDegree'])))

Assuming that chunk.euler_angles is set to Metashape.EulerAngles.EulerAnglesYPR

see attached screen copy
« Last Edit: December 08, 2020, 05:16:44 PM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor