Forum

Author Topic: Accessing Function Parameters Information  (Read 4220 times)

boulder1998

  • Newbie
  • *
  • Posts: 7
    • View Profile
Accessing Function Parameters Information
« on: June 28, 2023, 10:50:11 AM »
Dear all

I am currently working on a Metashape python workflow to analyse what are the best parameters to use for my project. I've noticed that many functions, such as the following, will put out a summary of the parameters used when finished running. I would like to log this information in a log file.

Example:
Code: [Select]
chunk.matchPhotos(keypoint_limit = 40000, tiepoint_limit = 10000, generic_preselection = True, reference_preselection = True)
doc.save()

This will give me following information that I want to log:
MatchPhotos: accuracy = High, preselection = generic, reference, keypoint limit = 40000, keypoint limit per mpx = 1000, tiepoint limit = 10000, apply masks = 0, filter tie points = 1, filter stationary points = 1, guided matching = 0

How do I access/extract this information to eventually get a list of all the parameters used for the individual functions in my python script?

Thank you!


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15159
    • View Profile
Re: Accessing Function Parameters Information
« Reply #1 on: June 28, 2023, 12:45:59 PM »
Hello boulder1998,

Looks like it is similar to the question from another thread:
https://www.agisoft.com/forum/index.php?topic=13650.msg60316#msg60316
Quote
You can check, if the corresponding assets exist in the chunk:
chunk.point_cloud, chunk.depth_maps, chunk.dense_cloud, chunk.model, chunk.elevation, chunk.orthomosaic, chunk.tiled_model.
then access it's meta information:
chunk.meta, chunk.point_cloud.meta, chunk.dense_cloud.meta and etc. it contains the information about the processing parameters used and time spent on the corresponding processing stage.
Is that what you would like to get?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Paulo

  • Hero Member
  • *****
  • Posts: 1359
    • View Profile
Re: Accessing Function Parameters Information
« Reply #2 on: June 28, 2023, 12:48:31 PM »
Hi boulder,

you would look at the meta attribute of Metashape.app.document.chunk.tie_points class as in:
Code: [Select]
chunk.tie_points.meta
Out[5]: 2023-06-28 03:37:22 {'Info/LastSavedDateTime': '2023:06:12 13:51:36', 'Info/LastSavedSoftwareVersion': '1.8.5.15520', 'Info/OriginalDateTime': '2023:06:10 19:06:37', 'Info/OriginalSoftwareVersion': '2.0.2.16334', 'MatchPhotos/descriptor_type': 'binary', 'MatchPhotos/descriptor_version': '1.1.0', 'MatchPhotos/downscale': '1', 'MatchPhotos/duration': '2143.105', 'MatchPhotos/filter_stationary_points': 'false', 'MatchPhotos/generic_preselection': 'true', 'MatchPhotos/guided_matching': 'false', 'MatchPhotos/keep_keypoints': 'false', 'MatchPhotos/keypoint_limit': '50000', 'MatchPhotos/keypoint_limit_per_mpx': '1000', 'MatchPhotos/max_workgroup_size': '100', 'MatchPhotos/ram_used': '1681215488', 'MatchPhotos/reference_preselection': 'true', 'MatchPhotos/reference_preselection_mode': '0', 'MatchPhotos/reset_matches': 'false', 'MatchPhotos/subdivide_task': 'true', 'MatchPhotos/tiepoint_limit': '10000', 'MatchPhotos/workitem_size_cameras': '20', 'MatchPhotos/workitem_size_pairs': '80'}

all keys() that begin with 'MatchPhotos/' will give you what you are looking for:
Code: [Select]
chunk.tie_points.meta.keys()
Out[6]: 2023-06-28 03:44:15
2023-06-28 03:44:15 ['Info/LastSavedDateTime',
2023-06-28 03:44:15  'Info/LastSavedSoftwareVersion',
2023-06-28 03:44:15  'Info/OriginalDateTime',
2023-06-28 03:44:15  'Info/OriginalSoftwareVersion',
2023-06-28 03:44:15  'MatchPhotos/descriptor_type',
2023-06-28 03:44:15  'MatchPhotos/descriptor_version',
2023-06-28 03:44:15  'MatchPhotos/downscale',
2023-06-28 03:44:15  'MatchPhotos/duration',
2023-06-28 03:44:15  'MatchPhotos/filter_stationary_points',
2023-06-28 03:44:15  'MatchPhotos/generic_preselection',
2023-06-28 03:44:15  'MatchPhotos/guided_matching',
2023-06-28 03:44:15  'MatchPhotos/keep_keypoints',
2023-06-28 03:44:15  'MatchPhotos/keypoint_limit',
2023-06-28 03:44:15  'MatchPhotos/keypoint_limit_per_mpx',
2023-06-28 03:44:15  'MatchPhotos/max_workgroup_size',
2023-06-28 03:44:15  'MatchPhotos/ram_used',
2023-06-28 03:44:15  'MatchPhotos/reference_preselection',
2023-06-28 03:44:15  'MatchPhotos/reference_preselection_mode',
2023-06-28 03:44:15  'MatchPhotos/reset_matches',
2023-06-28 03:44:15  'MatchPhotos/subdivide_task',
2023-06-28 03:44:15  'MatchPhotos/tiepoint_limit',
2023-06-28 03:44:15  'MatchPhotos/workitem_size_cameras',
2023-06-28 03:44:15  'MatchPhotos/workitem_size_pairs']
Best Regards,
Paul Pelletier,
Surveyor

boulder1998

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Accessing Function Parameters Information
« Reply #3 on: June 29, 2023, 04:39:54 PM »
Hi Alexey and Paolo

Thanks for your responses.

For the suggestion of Alexey: This goes in the right direction.
it is unfortunately not working for me. Maybe I've missed something additionally. Do I have to consider some further specifications/classes/functions that meta works? And would .meta apply for everything that is related to chunks => e.g. chunk.buildDEM.meta, chunk.point_cloud.meta?

Further, my interest lies also in the "translation" of for example downscale = 1, that would give a certain accuracy =high. I want to extract this translation information. So, the functions do this but I cannot extract it into a log file. So maybe for that there is even a better solution?

For the suggestion of Paolo: similar thing... key() gives me errors.

Thanks.

Paulo

  • Hero Member
  • *****
  • Posts: 1359
    • View Profile
Re: Accessing Function Parameters Information
« Reply #4 on: June 29, 2023, 09:54:11 PM »
Hi Alexey and Paolo

For the suggestion of Paolo: similar thing... key() gives me errors.

Thanks.

If you are using version prior to 2 (1.8.or less) then use chunk.point_cloud.meta.keys()

Code: [Select]
ps.app.version
Out[6]: 2023-06-29 12:53:29 '1.8.5'

chunk.point_cloud.meta.keys()
Out[7]: 2023-06-29 12:53:33
2023-06-29 12:53:33 ['Info/LastSavedDateTime',
2023-06-29 12:53:33  'Info/LastSavedSoftwareVersion',
2023-06-29 12:53:33  'Info/OriginalDateTime',
2023-06-29 12:53:33  'Info/OriginalSoftwareVersion',
2023-06-29 12:53:33  'MatchPhotos/descriptor_type',
2023-06-29 12:53:33  'MatchPhotos/descriptor_version',
2023-06-29 12:53:33  'MatchPhotos/downscale',
2023-06-29 12:53:33  'MatchPhotos/duration',
2023-06-29 12:53:33  'MatchPhotos/filter_stationary_points',
2023-06-29 12:53:33  'MatchPhotos/generic_preselection',
2023-06-29 12:53:33  'MatchPhotos/guided_matching',
2023-06-29 12:53:33  'MatchPhotos/keep_keypoints',
2023-06-29 12:53:33  'MatchPhotos/keypoint_limit',
2023-06-29 12:53:33  'MatchPhotos/keypoint_limit_per_mpx',
2023-06-29 12:53:33  'MatchPhotos/max_workgroup_size',
2023-06-29 12:53:33  'MatchPhotos/ram_used',
2023-06-29 12:53:33  'MatchPhotos/reference_preselection',
2023-06-29 12:53:33  'MatchPhotos/reference_preselection_mode',
2023-06-29 12:53:33  'MatchPhotos/reset_matches',
2023-06-29 12:53:33  'MatchPhotos/subdivide_task',
2023-06-29 12:53:33  'MatchPhotos/tiepoint_limit',
2023-06-29 12:53:33  'MatchPhotos/workitem_size_cameras',
2023-06-29 12:53:33  'MatchPhotos/workitem_size_pairs']
Best Regards,
Paul Pelletier,
Surveyor