[nodes] HDR Fusion: Flag userNbBrackets as invalid if it isn't a multiple of the number of inputs

Add an error message for `userNbBrackets` and set `validValue` to false
if the set number of brackets is not a multiple of the number of input
images.
This commit is contained in:
Candice Bentéjac 2023-08-02 15:15:09 +02:00 committed by Loïc Vital
parent 1e14b2c5a0
commit fdd9d088c5
3 changed files with 48 additions and 9 deletions

View file

@ -74,6 +74,8 @@ Sample pixels from Low range images for HDR creation.
range=(0, 15, 1),
uid=[],
group="user", # not used directly on the command line
errorMessage="The set number of brackets is not a multiple of the number of input images.\n"
"Errors will occur during the computation."
),
desc.IntParam(
name="nbBrackets",
@ -207,13 +209,24 @@ Sample pixels from Low range images for HDR creation.
# Old version of the node
return
node.outliersNb = 0 # Reset the number of detected outliers
if node.userNbBrackets.value != 0:
node.nbBrackets.value = node.userNbBrackets.value
return
node.userNbBrackets.validValue = True # Reset the status of "userNbBrackets"
cameraInitOutput = node.input.getLinkParam(recursive=True)
if not cameraInitOutput:
node.nbBrackets.value = 0
return
if node.userNbBrackets.value != 0:
# The number of brackets has been manually forced: check whether it is valid or not
if cameraInitOutput and cameraInitOutput.node and cameraInitOutput.node.hasAttribute("viewpoints"):
viewpoints = cameraInitOutput.node.viewpoints.value
# The number of brackets should be a multiple of the number of input images
if (len(viewpoints) % node.userNbBrackets.value != 0):
node.userNbBrackets.validValue = False
else:
node.userNbBrackets.validValue = True
node.nbBrackets.value = node.userNbBrackets.value
return
if not cameraInitOutput.node.hasAttribute("viewpoints"):
if cameraInitOutput.node.hasAttribute("input"):
cameraInitOutput = cameraInitOutput.node.input.getLinkParam(recursive=True)