Hello,
I have a script which masks automatically all the images in a chunk. On my computer, it runs at about 3 images per seconds so masking all the images in a project with 2315 images takes more than 12 minutes. If I can't inform the user of the masking progress, there are very good chances that he will think that the program is stuck and will simply kill it...
I tried adding a print statement into my mask loop but what happens is that ALL the printing is done AFTER the function finishes, defeating the purpose of printing to inform the user of the processing progress. See below:
def CreateMasks(chunk):
imagesMaskedCount = 0
for cam in chunk.cameras:
print("Image(" + str(imagesMaskedCount) + ") masked...") #Just printing after returning!!!
src = cam.photo.image()
openCVImg = AgisoftOpenCVUtils.AgisoftToOpenCVImage(src)
gray = cv2.cvtColor(openCVImg, cv2.COLOR_BGR2GRAY)
whiteColor = (255,255,255)
# Create a mask supposed to cover everything that is white.
mask = PhotoScan.Utils.createDifferenceMask(src, whiteColor, tolerance=5, fit_colors=False )
m = PhotoScan.Mask()
m.setImage(mask)
# Assign this mask to our camera.
cam.mask = m
imagesMaskedCount = imagesMaskedCount+1
Is there a way to make the printing work "real time" instead of just in "batch" at the end of my long function?
Thanks,
Bruno