Forum

Author Topic: Iterate through camera sensors within a chunk  (Read 1418 times)

Etienne_U

  • Newbie
  • *
  • Posts: 5
    • View Profile
Iterate through camera sensors within a chunk
« on: March 07, 2023, 01:57:50 PM »
Dear Metashape Community,

I have a project with multiple sensors ( let say sensor1, sensor2, sensor3 ...).
I would like to iterate through each sensor, to create a camera group for each sensor, but the messge error I get is "sensor is not iterable".

How can I solve it ?

Thanks a lot for your answers,

Best regards,

Etienne

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Iterate through camera sensors within a chunk
« Reply #1 on: March 07, 2023, 02:34:17 PM »
Hello Etienne,

Please check the example below, it creates a camera group (folder) for each sensor and then moves every camera in the chunk to the folder corresponding to the camera sensor:
Code: [Select]
chunk = Metashape.app.document.chunk

camera_groups = {}
for sensor in chunk.sensors:
camera_groups[sensor] = chunk.addCameraGroup()
camera_groups[sensor].label = sensor.label

for camera in chunk.cameras:
camera.group = camera_groups[camera.sensor]

print("Finished")
Best regards,
Alexey Pasumansky,
Agisoft LLC

Etienne_U

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Iterate through camera sensors within a chunk
« Reply #2 on: March 08, 2023, 11:07:34 AM »
Thanks a lot, this is exactly what I needed !