Hello everybody,
I am working on a python Metashape script in Visual Studio Code using Jupyter Notebooks on a MacBook Air M2 with 16GB Memory.
I want to know how long each Metashape task/function (e.g. matchPhotos, buildModel, buildDEM, etc.) in my code is going to take.
I've started to use the following suggestion by Alexey from a few years back:
Hello kingd0559,
The simple example of callback function usage is below:
def progress_print(p):
print('Current task progress: {:.2f}%'.format(p))
chunk = PhotoScan.app.document.chunk
chunk.matchPhotos(progress=progress_print)
It will print the current progress to the console for the image matching operation.
However, applying this function for example to buildUV or buildModel will make VSC go to a kinda "freeze" mode and it's hard to do anything until the task is done, this with only a view pictures as a trial basis. Plus, the cell outputs and hence, also the progress, is not properly displayed anymore.
Has someone experienced a similar situation and knows what one can do about it, especially for bigger projects?
-------------
In the discussion where I found the above, there was also the following idea by Alexey that I like:
And another simple example that may be helpful for those who want also to estimate the time left for the current operation based on the spent time and current progress value:
import time, PhotoScan
def progress_print(p):
elapsed = float(time.time() - start_time)
if p:
sec = elapsed / p * 100
print('Current task progress: {:.2f}%, estimated time left: {:.0f} seconds'.format(p, sec))
else:
print('Current task progress: {:.2f}%, estimated time left: unknown'.format(p)) #if 0% progress
chunk = PhotoScan.app.document.chunk
global start_time
start_time = time.time()
chunk.matchPhotos( progress=progress_print)
Changing
PhotoScan to
Metashape did not the job. Is there an updated way to do this for Metashape version 2.0.1? maybe even with adding a progress bar?

Thank you for replies.
Cheers, boulder1998