1
General / Can't upload masks from script
« on: June 06, 2024, 09:17:19 AM »
Hi!
I generated a Python script to manage repetitive tasks on many chunks: doc creation, images import, calibration settings and masks import.
Everything is working expect the masks import. I've got 4 sensors and a mask by sensor, so I'm trying to import these masks with the generateMasks function.
The function executes with no error and the progress bar indicates that the masks are imported, but is there one more step of assigning the masks or what's going on?
Here is the script I use, I first make a dict to access cameras from their label instead of their index which I don't know:
camdict = {}
for cam in chunk.cameras:
label = cam.label
ide = cam.key
camdict.update({label: ide})
chunk.generateMasks(path=r"C:\maks_1.png", cameras=[camdict[label] for label in ['DSC_0001', 'DSC_0002', 'DSC_0003'])
As said, I don't get an error and the function seems to execute, but I don't see the result.
When executing in GUI, I see in the log "GenerateMasks: path = C:\maks_1.png"
But when I import form the GUI, I see "ImportMasks: path = C:\maks_1.png cameras = 0,1,2"
Which should indicate that GenerateMasks ignores the camera list? I saw in the Python reference that ImportMasks was renommed to GenerateMasks, but it seems that this function still exists, while inaccessible... How can I access the original ImportMasks function from Python, while it still seems to exist? Or at least get the one targeted in the GUI... Explicitely setting masking_mode=MaskingModeFile and mask_operation=MaskOperationReplacement does not change anything, the process looks like it's doing something but no result... By the way, the amount of renamed functions in Python reference is astonishing what's the reason for this? On the user end, it's just aweful to have an incomplete doc containing partial informations and a forum where almost everything is outdated...
Thanks in advance!
Metashape 2.1
I generated a Python script to manage repetitive tasks on many chunks: doc creation, images import, calibration settings and masks import.
Everything is working expect the masks import. I've got 4 sensors and a mask by sensor, so I'm trying to import these masks with the generateMasks function.
The function executes with no error and the progress bar indicates that the masks are imported, but is there one more step of assigning the masks or what's going on?
Here is the script I use, I first make a dict to access cameras from their label instead of their index which I don't know:
camdict = {}
for cam in chunk.cameras:
label = cam.label
ide = cam.key
camdict.update({label: ide})
chunk.generateMasks(path=r"C:\maks_1.png", cameras=[camdict[label] for label in ['DSC_0001', 'DSC_0002', 'DSC_0003'])
As said, I don't get an error and the function seems to execute, but I don't see the result.
When executing in GUI, I see in the log "GenerateMasks: path = C:\maks_1.png"
But when I import form the GUI, I see "ImportMasks: path = C:\maks_1.png cameras = 0,1,2"
Which should indicate that GenerateMasks ignores the camera list? I saw in the Python reference that ImportMasks was renommed to GenerateMasks, but it seems that this function still exists, while inaccessible... How can I access the original ImportMasks function from Python, while it still seems to exist? Or at least get the one targeted in the GUI... Explicitely setting masking_mode=MaskingModeFile and mask_operation=MaskOperationReplacement does not change anything, the process looks like it's doing something but no result... By the way, the amount of renamed functions in Python reference is astonishing what's the reason for this? On the user end, it's just aweful to have an incomplete doc containing partial informations and a forum where almost everything is outdated...
Thanks in advance!
Metashape 2.1