Forum

Author Topic: Disable/Enable camera groups in Python  (Read 2615 times)

geo_enth

  • Newbie
  • *
  • Posts: 2
    • View Profile
Disable/Enable camera groups in Python
« on: February 08, 2022, 04:02:45 PM »
Hi,

I was wondering wheter it's possible to disable/enable individual cameragroups in Python. I know it's possible to disable individual cameras but it would be more convenient and efficient to have something similar like
Code: [Select]
camera.enabled = True for camera groups

My concrete case:
I have created two camera groups (group #1 contains thousands of photos and group #2 only contains 10 photos which were subaligned to group #1). In the next step I want to create an orthomosaic of group #2 and thus I must disable group 1 (otherwise the orthomosaic is created for all photos). Am I missing something?

Help is highly appreciated!


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15117
    • View Profile
Re: Disable/Enable camera groups in Python
« Reply #1 on: February 08, 2022, 05:22:19 PM »
Hello geo_enth,

I think you can create a custom functions to enable/disable camera groups:

Code: [Select]
def disable_group(camera_group, chunk):
    for camera in chunk.cameras:
        if camera.group == camera_group:
            camera.enabled = False
    return
def enable_group(camera_group, chunk):
    for camera in chunk.cameras:
        if camera.group == camera_group:
            camera.enabled = True
    return

And use them in the following way for your needs:

Code: [Select]
chunk = Metashape.app.document.chunk
for camera in chunk.cameras:
    camera.enabled = False #disable all cameras before processing
for group in chunk.camera_groups:
    enable_group(group, chunk)
    chunk.buildOrthomosaic(...)
    chunk.orthomosaic.label = group.label
    chunk.orthomosaic = None #un-set active
    disable_group(group, chunk)
for camera in chunk.cameras:
    camera.enabled = True #enable all cameras again
Thus you should be able to get separate orthomosaic per each camera group in the chunk.
Best regards,
Alexey Pasumansky,
Agisoft LLC

geo_enth

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Disable/Enable camera groups in Python
« Reply #2 on: February 08, 2022, 05:50:19 PM »
That's what I was looking for!
thanks a lot!