Forum

Author Topic: Camera export: distortion model  (Read 5095 times)

3create

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • 3create
Camera export: distortion model
« on: August 12, 2022, 10:12:01 PM »
To set the stage:
my previous workflow was to export the cameras (i.e. fbx) and export the undistorted images out of Metashape.
Exporting the undistorted images is no longer directly supported in the latest Metashape builds (only via scripting).

So I undistorted the images with the calibration parameters from a 1.8.4 project in 1.7.2. Works fine.
However, I noticed, that these undistorted images don't match with the exported scene/model.

So now I am a bit confused.
In short: what is currently the process of exporting the model with matching cameras? And of course the camera images need to be undistorted for correct alignment in 3rd party apps?!

Thanks, Guy

Bzuco

  • Full Member
  • ***
  • Posts: 203
    • View Profile
Re: Camera export: distortion model
« Reply #1 on: August 13, 2022, 03:49:15 PM »
Hi 3create,

did you enable center principal point option in export dialog? without this option exported images does not match scene model. If you have that option checked and still see differences, how big they are in comparison whole scene size?

3create

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • 3create
Re: Camera export: distortion model
« Reply #2 on: August 14, 2022, 03:51:06 PM »
Thanks for the reply Bzuco.
I figured out what the problem was: I loaded my generic pre-calibaration XML for the camera-lens-combo into 1.7.2 instead of the field calibration of the 1.8.4 project.
This explains the slight mismatches.

But this does pose the general question of why the useful undistortion option has been removed. Hence I wouldn't need to be using a second (older) installalltion, exporting und importing calibration models or alternatively use scripting.
@ Agisoft: would love this feture back in the "Convert Images"  in the latest builds  :)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Camera export: distortion model
« Reply #3 on: August 15, 2022, 05:26:14 PM »
Hello 3create,

If you need to replicate the results of the previous versions for Convert Images option (related to undistort operation), then you should enable Precalibrated option for the Initial tab of the Camera Calibration dialog and substitute the default focal length value (in pixels) with the value from the Adjusted tab. Then use Convert Images dialog with Transform to Initial Calibration option enabled.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Paulo

  • Hero Member
  • *****
  • Posts: 1350
    • View Profile
Re: Camera export: distortion model
« Reply #4 on: August 15, 2022, 06:28:18 PM »
Thanks Alexey,

very informative as this method avoids running a script to generate undistorted images.

Good to have you back from holidays, I guess :)
Best Regards,
Paul Pelletier,
Surveyor

jedfrechette

  • Full Member
  • ***
  • Posts: 132
  • Lidar Guys
    • View Profile
    • www.lidarguys.com
Re: Camera export: distortion model
« Reply #5 on: August 15, 2022, 07:10:25 PM »
What's the rational for removing the ability to export undistorted images from the GUI without this workaround? Easy access to undistorted photos is a very important aspect of some workflows.
Jed

3create

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • 3create
Re: Camera export: distortion model
« Reply #6 on: August 15, 2022, 09:21:21 PM »
Thanks for the workaround advice Alexey!

But I agree with jedfrechette's comment: "Easy access to undistorted photos is a very important aspect of some workflows".
It really is a workflow issue, I'm using this method all the time (matching 3d-reconstructed data with the original image footage).

Guess we could start a poll?!? ;)

Paulo

  • Hero Member
  • *****
  • Posts: 1350
    • View Profile
Re: Camera export: distortion model
« Reply #7 on: August 16, 2022, 01:33:35 AM »
Hello Alexey,

relative to this issue, i am defining a ConvertImages() task to  convert 5 selected images using initial calibration and color correction. When I apply the task, it starts processing first image and gives a message Zero image size with OSError can't save Image...see following attachment

Any ideas?

By the way, I get same error if I use GUI selecting images  index 1,2,3,4:
Code: [Select]
2022-08-15 17:56:49 ConvertImages: use_initial_calibration = on, color_correction = on, path = C:/Users/paul.pelletier/Downloads/Byron/Gibraltar_20220721/Undis/{filename}.{fileext}
2022-08-15 17:56:49 Converting images...
2022-08-15 17:56:51 Zero image size
2022-08-15 17:56:51 Finished processing in 2.777 sec (exit code 0)
2022-08-15 17:56:52 Error: Can't save image: C:/Users/paul.pelletier/Downloads/Byron/Gibraltar_20220721/Undis/DJI_20220521084324_0002.JPG
« Last Edit: August 16, 2022, 05:57:36 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Camera export: distortion model
« Reply #8 on: August 16, 2022, 03:47:18 PM »
Hello Paul,

I am using the same code for a similar random project and everything works as expected in 1.8.4 build 14671.

Can you show the screenshots of Initial and Adjusted values tab, so that I could try to replicate the case in the same conditions?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Paulo

  • Hero Member
  • *****
  • Posts: 1350
    • View Profile
Re: Camera export: distortion model
« Reply #9 on: August 16, 2022, 06:28:38 PM »
Hi Alexey,

here are the 2 screenshots. As you can see I want to revert to initial calib with adjusted f, cx, cy (not center principal point).

 on Agisoft Metashape Professional Version: 1.8.4 build 14671 (64 bit)

Hope this can help,
Best Regards,
Paul Pelletier,
Surveyor

Bzuco

  • Full Member
  • ***
  • Posts: 203
    • View Profile
Re: Camera export: distortion model
« Reply #10 on: August 17, 2022, 10:40:30 AM »
Thak you Alexey, now I can jump from 1.7.6 to latest as I am using undistorted images in every project.

It is just copy one value between tabs, I can live without that option in GUI  :).

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Camera export: distortion model
« Reply #11 on: August 17, 2022, 11:05:20 AM »
Hello Paul,

I think you are missing width and height definition for the new calibration in your function:
Code: [Select]
init_calib.width = sensor.width
init_calib.height = sensor.height
Best regards,
Alexey Pasumansky,
Agisoft LLC

Paulo

  • Hero Member
  • *****
  • Posts: 1350
    • View Profile
Re: Camera export: distortion model
« Reply #12 on: August 17, 2022, 04:37:58 PM »
Thank you, Alexey,

I was missing that! now it works
Best Regards,
Paul Pelletier,
Surveyor

jedfrechette

  • Full Member
  • ***
  • Posts: 132
  • Lidar Guys
    • View Profile
    • www.lidarguys.com
Re: Camera export: distortion model
« Reply #13 on: August 17, 2022, 06:25:41 PM »
It is just copy one value between tabs, I can live without that option in GUI  :).

You might be able to, but what about all of the other users who need this functionality? Are they going to find this thread or come up with the workaround by themselves? As far as I know this isn't documented anywhere else.

To me this just seems like a needless feature regression. This software has had the ability to export undistorted photos from the GUI for more than a decade, why was that feature removed now?

We're using the Python API to do this so aren't directly affected by this particular change, but the way Agisoft tends to somewhat arbitrarily remove or break features between point releases is one of my major frustrations with this software.
Jed

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Camera export: distortion model
« Reply #14 on: August 17, 2022, 07:03:31 PM »
Hello Jed,

We'll try to improve the convenience of Convert Images dialog in respect of Undistort Photos functionality.
Best regards,
Alexey Pasumansky,
Agisoft LLC