Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: ilia on May 26, 2022, 11:53:31 AM

Title: Camera Rig configuration through Python API
Post by: ilia 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?
Title: Re: Camera Rig configuration through Python API
Post by: ilia 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.
Title: Re: Camera Rig configuration through Python API
Post by: Alexey Pasumansky 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
Title: Re: Camera Rig configuration through Python API
Post by: ilia 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.
Title: Re: Camera Rig configuration through Python API
Post by: ilia 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.
Title: Re: Camera Rig configuration through Python API
Post by: ilia 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.
Title: Re: Camera Rig configuration through Python API
Post by: ilia 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.
Title: Re: Camera Rig configuration through Python API
Post by: ilia 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.