Forum

Author Topic: Enable fiducial search  (Read 7912 times)

fabvin

  • Newbie
  • *
  • Posts: 22
    • View Profile
Enable fiducial search
« on: November 17, 2023, 03:12:13 PM »
Dear all,
I wanted to create a code to detect fiducials in scanned images on all chunks of a metashape project, but I need to know the python code to enable the detection of fiducials (as in tools, Camera calibration, Film camera with fiducial marks):

def detect_fiducials():
    doc =scan.app.document
    for chk_sel in doc.chunks:
       code to enable fiducial detection
      chk_sel.detectFiducials(generate_masks=True,generic_detector=True)

Best regards

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15629
    • View Profile
Re: Enable fiducial search
« Reply #1 on: November 17, 2023, 06:54:48 PM »
Hello fabvin,

The analogue of "Film camera with fiducial marks" in Python API is the following property of the sensor (calibration group):
Code: [Select]
sensor.film_camera = True
So if there are only scanned images in all the chunks, you need to enable this option for all the sensors (there could be many by default, if the dimensions of the input images are different), merge groups and then proceed to the fiducial detection. Of course, if they are taken with the same camera, so that the fiducial marks are the same.
Best regards,
Alexey Pasumansky,
Agisoft LLC

fabvin

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Enable fiducial search
« Reply #2 on: November 21, 2023, 11:50:01 AM »
Thank you Alexey, it works perfectly!
The complete code:

Code: [Select]
def detect_fiducials():
    doc =scan.app.document
    for chk_sel in doc.chunks:
      for sensor in chk_sel.sensors:
        sensor.film_camera = True
      if chk.enabled != True:
        chk_sel.detectFiducials(generate_masks=True,generic_detector=True)
      else:
        chk_sel.detectFiducials(generate_masks=True, generic_detector=False, right_angle_detector=False,fiducials_position_corners=False,fiducials_position_sides=False)


I have two other questions:

Is it necessary to indicate the real size of the physical support of the scan (I have no idea...) or having the exact position of the fiducial marks is sufficient for resampling?

The detectFiducials algorithm detects systematically 8 fiducials marks (auto_0 to auto_7) that figurate in the table but the (auto_4,..., auto_7) marks are not present in the images. I manually delete the 4 last marks but I wonder if it's really necessary?

Best regards, and thanks again for your quick answer!