Forum

Author Topic: Set custom default settings with Python API  (Read 1411 times)

ikemarv

  • Newbie
  • *
  • Posts: 5
    • View Profile
Set custom default settings with Python API
« on: February 24, 2022, 01:43:02 PM »
Hello,

I would like to set default settings with a Python script for MetashapePro GUI.
I use accetto/ubuntu-vnc-xfce-g3 to host a instance for MetashapePro GUI on a node. Every time the instance is redeployed and MetashapePro is reinstalled, the settings reset. So I would like to set my own default settings.

1. add default coordinate system
2. change "advanced preferences":
- Enable "Load camera location accuracy from XMP meta data"
- Disable "Enable VBO support"
- Disable "Enable rich Python console"
(If it works, no prio) 3. change default attributes of task "Align Photos":
- Accuracy: Highest
- Key point limit = 100,000
- Tie point limit: 10,000

I already tried on my local machine (MacOS):
1. change chunk.crs -> doesn't work outside of GUI
Code: [Select]
import Metashape
import shutil
with open('PATH-TO-PRJ-FILE') as f:
    crs_text = f.read()
shutil.copyfile('PATH-TO-GEOID-TIF', '/Applications/MetashapePro.app/Contents/MacOS/geoids/GEOID.tif')
Metashape.CoordinateSystem.addGeoid('/Applications/MetashapePro.app/Contents/MacOS/geoids/GEOID.tif')
Metashape.app.document.addChunk()
chunk = Metashape.app.document.chunk
chunk.crs = Metashape.CoordinateSystem(crs_text)
chunk.updateTransform()
additionally I tried to change CRS with getCoordinateSystem:
Code: [Select]
crs = Metashape.CoordinateSystem(crs_text)
Metashape.app.getCoordinateSystem(crs)

2.
- Disable "Enable VBO support" works with
Code: [Select]
Metashape.app.settings.setValue("main/enable_vbo", "0")- I don't know the variable name for "Load camera location accuracy from XMP meta data" and "Enable rich Python console";
this didn't work for me:
Code: [Select]
Metashape.app.settings.setValue("main/console/enable_rich_console", "0")
Metashape.app.settings.setValue("main/load_xmp_accuracy", "1")

Versions:
- ubuntu: metashape-pro_1_8_1_amd64.tar.gz
- local machine (MacOS): Agisoft Metashape Professional Version: 1.8.0 build 13794 (64 bit)

Thanks for your help!
« Last Edit: February 24, 2022, 01:49:42 PM by ikemarv »

ikemarv

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Set custom default settings with Python API
« Reply #1 on: March 01, 2022, 06:49:59 PM »
The thread can be closed.
It's possible to create a custom .conf file or just change the .conf file with
Code: [Select]
[General]]
recentCRS="COMPD_CS[...]"

[main]
load_xmp_accuracy=1
enable_vbo=0
console\enable_rich_console=0
on a linux node the .conf file is placed here:
Code: [Select]
/home/headless/.config/Agisoft/Metashape Pro.conf