Forum

Author Topic: Capture view for open camera (view mode)  (Read 5494 times)

Jaume

  • Newbie
  • *
  • Posts: 32
    • View Profile
Capture view for open camera (view mode)
« on: July 28, 2020, 12:03:35 AM »
Dear Agisoft Users,

I am struggling to write a script to do a certain process in photos. The idea is to:

1. choose cameras (selected or by given range define by labels) from chunk or group (name),
2. open photos one by one in a new tab with certain delay (e.g. 1000ms),
3. capture view by given parameters,
4. save images to directory.

I wrote the script that captures view only for Model View Mode. I've got sth like this:

Code: [Select]
import Metashape
import os

# Checking compatibility
compatible_major_version = "1.6"
found_major_version = ".".join(Metashape.app.version.split('.')[:2])
if found_major_version != compatible_major_version:
    raise Exception("Incompatible Metashape version: {} != {}".format(found_major_version, compatible_major_version))


def capture_view():

    doc = Metashape.app.document
    if not len(doc.chunks):
        raise Exception("No chunks!")

    print("Script started...")
   
    chunk = doc.chunk #active chunk, if there's any in the project
    for camera in chunk.cameras:
        camera = chunk.cameras[0]
        capture = Metashape.app.model_view.captureView(width = 600, height = 450, transparent = False, hide_items = True)
        capture.save('E:/Capture/' + camera.label + '_cv.png')
    print("Script finished!")


label = "Custom menu/Capture View"
Metashape.app.addMenuItem(label, capture_view)
print("To execute this script press {}".format(label))

I couldn't find the module such as captureView for camera view (open image).

I will be very grateful for any support in this topic.

Jaume

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Capture view for open camera (view mode)
« Reply #1 on: September 01, 2020, 09:31:50 PM »
Does anyone know about this topic? I really want a tip on how to deal with this matter  :(

I put the image that shows the issue. I need to make it for all cameras in chunk automatically (with some delay for the photo to load - come up on the screen).