Forum

Author Topic: CHECK/UNCHECK API (SOLVED)  (Read 1486 times)

mrv2020

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
CHECK/UNCHECK API (SOLVED)
« on: March 16, 2024, 03:04:27 PM »
Hi,

I'm reaching out to suggest a potential addition to the Metashape API that I believe could benefit many users. While the current API offers great flexibility, including enabling/disabling cameras (enabled) and selecting/deselecting them (selected), it seems there's no direct way to programmatically "uncheck" images for processing based on specific criteria (e.g., location accuracy).

Many of us automate workflows where pre-selecting images based on metadata or quality metrics is crucial before proceeding to resource-intensive processing steps. For instance, being able to automatically uncheck images with location accuracy below a certain threshold could save significant time and enhance the quality of project outputs.

Could we consider adding a method to the API to control the "check" state of images in the Reference Panel or before processing? This feature would provide even greater control over automated workflows and potentially improve processing efficiency and outcomes.

Code: [Select]
import Metashape
doc = Metashape.app.document
chunk = doc.chunks[0]
for camera in chunk.cameras:
    # Checks if the camera has a defined reference and location accuracy
    if camera.reference and camera.reference.location_accuracy:
        accuracy = max(camera.reference.location_accuracy.x, camera.reference.location_accuracy.y,camera.reference.location_accuracy.z)
        print(f"Camera {camera.label}: Accuracy = {accuracy}") # Prints the accuracy
        if accuracy > 9:
            camera.selected = False
            print(f"Camera {camera.label} unselected due to high accuracy.") # Print the action

Best,
« Last Edit: March 16, 2024, 09:02:29 PM by mrv2020 »

mrv2020

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: CHECK/UNCHECK API
« Reply #1 on: March 16, 2024, 09:02:05 PM »
Solved!!

Code: [Select]
for camera in chunk.cameras:
    camera.reference.enabled = False
for camera in chunk.cameras:
    if camera.reference.location_accuracy and max(camera.reference.location_accuracy) < 5:
        camera.reference.enabled = True