Forum

Author Topic: How to move a camera from one chunk to another  (Read 297 times)

BorodinMaxim

  • Newbie
  • *
  • Posts: 3
    • View Profile
How to move a camera from one chunk to another
« on: May 11, 2022, 10:16:09 AM »
How to move a camera from one chunk to another?
I didn't find any information about this in the Python API Reference. However, this can be easily done using the User Interface.
How can I do this using the API?


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13729
    • View Profile
Re: How to move a camera from one chunk to another
« Reply #1 on: May 13, 2022, 05:43:01 PM »
Hello Maxim,

Do you need to preserve the exterior orientation parameters for the cameras being copied? And whether you are interested in moving cameras to new (empty) chunk or to the chunk with some processed data?
Best regards,
Alexey Pasumansky,
Agisoft LLC

BorodinMaxim

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to move a camera from one chunk to another
« Reply #2 on: May 13, 2022, 06:03:20 PM »
Alexey, I need to move cameras to new (empty) chunk
« Last Edit: May 13, 2022, 06:14:56 PM by BorodinMaxim »

BorodinMaxim

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to move a camera from one chunk to another
« Reply #3 on: May 20, 2022, 02:07:32 PM »
Is there a solution to my problem?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13729
    • View Profile
Re: How to move a camera from one chunk to another
« Reply #4 on: May 23, 2022, 04:54:51 PM »
Hello Maxim,

If you need just to remove the cameras from the active chunk and create new cameras from the same source photos in the new empty chunk, you can use the following script:

Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk #active chunk

cameras = [camera for camera in chunk.cameras if camera.selected and camera.type == Metashape.Camera.Type.Regular] #cameras to be moved
paths = [camera.photo.path for camera in cameras] #camera paths

new_chunk = Metashape.app.document.addChunk() #new empty chunk
new_chunk.addPhotos(paths)

chunk.remove(cameras)

It is applied to the selected cameras in the active chunk.

Let me know, if you need to preserve exterior and/or interior orientation parameters for moved cameras in the newly created chunk.
Best regards,
Alexey Pasumansky,
Agisoft LLC