Forum

Author Topic: Transfer camera parameters to a minimal OpenGL renderer  (Read 746 times)

glennk

  • Newbie
  • *
  • Posts: 15
    • View Profile
Transfer camera parameters to a minimal OpenGL renderer
« on: February 14, 2023, 01:41:46 PM »
Hello,

I want to export the model and cameras acquired by Metashape to a minimal OpenGL renderer. In this renderer I want to add a background image and add some geometry matching the background image (example :  Metashape's 3D model).

Thanks to Metashape's python API, I exported
  • the cameras transforms
  • the cameras focal lengths
  • the pixels widths and heights

How to create the camera Projection matrix and camera Model matrix from these informations ?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14837
    • View Profile
Re: Transfer camera parameters to a minimal OpenGL renderer
« Reply #1 on: February 14, 2023, 06:37:40 PM »
Hello glennk,

You can find the information about the distortion model used in Metashape in Appendix C of Metashape manual:
https://www.agisoft.com/pdf/metashape-pro_2_0_en.pdf

But it wouldn't work accurately, if rolling shutter option has been applied or additional corrections have been estimated.

You may also consider exporting adjusted interior orientation parameters in external format more convenient for your needs, for example, OpenCV format, if you are planning to use OpenCV library.
Best regards,
Alexey Pasumansky,
Agisoft LLC

glennk

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Transfer camera parameters to a minimal OpenGL renderer
« Reply #2 on: February 15, 2023, 06:03:52 PM »
Thank you Alexey,

I ended up with this guide : https://strawlab.org/2011/11/05/augmented-reality-with-OpenGL/

I had to transpose the matrix before using it.
Also, since cx and cy are already centered :
(width - 2*cx)/width -> -2*cx/width
and
(-height + 2*cy)/height -> 2*cy/height
« Last Edit: February 15, 2023, 06:06:49 PM by glennk »