Forum

Author Topic: Camera Rig configuration through Python API  (Read 3014 times)

ilia

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Camera Rig configuration through Python API
« on: May 26, 2022, 11:53:31 AM »
Hi!

I didn't find any opportunity to set up the rig, including offsets through Python API.
May I ask where to look for? I have precalibrated camera rig to experiment with, but I have to go manually loading the whole configuration in Metashape everytime.

Also, are there functions to call if I want to load all cameras as a rig in the same manner when I click "Load Folder" and select the rig configuration?

ilia

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Camera Rig configuration through Python API
« Reply #1 on: June 13, 2022, 03:57:32 PM »
Still wondering if it's possible to do.
I have several rig configurations and I calibrate all of them. So I would like to know if there is a way to upload this data straight into metashape without copy-pasting it by hand.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Camera Rig configuration through Python API
« Reply #2 on: June 14, 2022, 07:43:52 PM »
Hello ilia,

Please check, if the example in the following thread works for your needs or requires any modification:
https://www.agisoft.com/forum/index.php?topic=14453.msg63627#msg63627
Best regards,
Alexey Pasumansky,
Agisoft LLC

ilia

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Camera Rig configuration through Python API
« Reply #3 on: June 28, 2022, 03:19:56 PM »
Dear Alexey,

Thank you for the link. I will try it today/tomorrow and will write you back. My problem was that even though Metashape supports camera rigs there are not much information about it in official Python API documentation or on forums.

ilia

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Camera Rig configuration through Python API
« Reply #4 on: June 28, 2022, 07:58:46 PM »
I still can't find where and how I can set slave camera offsets for the camera rig, but I'm struggle to find how I can install through Python API slave offsets. I've checked again Python API document. I see there Sensor class. I see there is Camera class and there is Sensor class, but I don't see how I can specify relative transformation from slave camera to master camera. But I see there are fields in GUI of Metashape.
My guess it that for slave cameras we can enable these references through default antenna  but they will calculated not relative to GNSS, but relative to the master Sensor. But I'm not sure. I guess I will try to experiment with it a bit today to figure out.

ilia

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Camera Rig configuration through Python API
« Reply #5 on: June 28, 2022, 08:29:17 PM »
I think I sort of understood how to work with it. It looks like Sensor's fields .location and .rotation with .fixed_location and .fixed_rotation are the fields I need to use. For slave cameras they control their relative position to the master camera. I'm still confused about the class Reference and its role inside Sensor class and its role for master and slave cameras.
May I ask you to clarify these moments?

I would say my main source of confusion is the different use of terms "camera", "sensor", "reference" in Python API and in GUI.
« Last Edit: June 28, 2022, 08:31:39 PM by ilia »

ilia

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Camera Rig configuration through Python API
« Reply #6 on: June 29, 2022, 10:38:58 PM »
After the whole day of experiments I'm still wondering how to properly to set all values.
For an example ms.Sensor.Reference.location_enable is read-only attribute.

I just can't figure out how to pass all information I have about relative camera positions in Metashape from Python API.
All I need is to set cam1, ..., camN extrinsics relative to cam0. And I just don't understand how.
All I was able to achieve is install "Adjusted Parameters".
I would like to understand several things if possible:
1. May I not optimize relative position of camera sensors? From GUI I don't see such opportunity as it switches off all reference fields if I switch off "adjust location" checkmark at slave sensor.
2. If it's not possible, I would like to install reference values with really small accuracy values to prevent them from being optimized. And again. I can't just match what I see in Python API document and GUI.

I guess I need some help.
Just in case: my goal is to load precalibrated information in Metashape to improve the quality of the reconstruction. And do it from Python script. Intrinsics were installed without any issues. But extrinsics keep giving me a headache as I can't understand how do they match to the ones I see in GUI. I see that I can install slave offsets there, but I still don't understand how I can operate on reference values as they seem as readonly.

ilia

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Camera Rig configuration through Python API
« Reply #7 on: July 01, 2022, 03:50:36 PM »
I guess it is solved.

The single not solved issue I have is how to lock location of slave sensors. My solution was to set their accuracy values too small to decrease the optimization step for them. But I would prefer not to optimize them at all.

vkam

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Camera Rig configuration through Python API
« Reply #8 on: February 08, 2023, 11:11:03 PM »
Hello!

I am working with Metashape Pro 2.0.  I have a similar problem of ingesting externally created camera extrinsic data for a rig.  In GUI version of Metashape, I was able to do this by exporting computed extrinsic camera xml file, editing the file, then importing the file back in a new session.  How can I ingest external camera extrinsic info directly?  Any help would be greatly appreciated.

Vkam