Incorrect signature for python.ImportImage()
Description
When calling
presum = otb.Registry.CreateApplication("SARPresummation")
input_dict = {
'array' : raw_master,
'origin' : [0,0],
'size' : raw_master.shape,
'metadata' : generate_kwl(input, None, input, antenna='master')
}
presum.ImportImage('in', input_dict)
with raw_master
being a 2D np.array
of complex numbers, I have the following errors
With OTB 7.0
Traceback (most recent call last):
File "/work/scratch/mine/dev/swot/install/SARModules/release/bin/chain-all.py", line 161, in <module>
chain_applis(options)
File "/work/scratch/mine/dev/swot/install/SARModules/release/bin/chain-all.py", line 131, in chain_applis
presum.ImportImage('in', input_dict)
File "/softs/projets/otb/rh7/7.0-python3.7.2/otb/lib/otb/python/otbApplication.py", line 3506, in ImportImage
img = self.SetImageFromNumpyArray(paramKey, pyImg["array"], index)
File "/softs/projets/otb/rh7/7.0-python3.7.2/otb/lib/otb/python/otbApplication.py", line 3431, in SetImageFromNumpyArray
img = self.ImageImporterMap[pixT](self,paramKey, index, npArray)
TypeError: SetImageFromCDoubleNumpyArray_() missing 3 required positional arguments: 'dim1', 'dim2', and 'dim3'
With current version in dev branch
Traceback (most recent call last):
File "/work/scratch/mine/dev/swot/install/SARModules/rel-myOTB/bin/chain-all.py", line 163, in <module>
chain_applis(options)
File "/work/scratch/mine/dev/swot/install/SARModules/rel-myOTB/bin/chain-all.py", line 133, in chain_applis
presum.ImportImage('in', input_dict)
File "/work/scratch/mine/dev/img/build/otb/superbuild_install/lib/otb/python/otbApplication.py", line 2088, in ImportImage
img = self.SetImageFromNumpyArray(paramKey, pyImg["array"], index)
File "/work/scratch/mine/dev/img/build/otb/superbuild_install/lib/otb/python/otbApplication.py", line 2013, in SetImageFromNumpyArray
img = self.ImageImporterMap[pixT](self,paramKey, index, npArray)
File "/work/scratch/mine/dev/img/build/otb/superbuild_install/lib/otb/python/otbApplication.py", line 1795, in SetImageFromCDoubleNumpyArray_
def SetImageFromCDoubleNumpyArray_(self, *args): return _otbApplication.Application_SetImageFromCDoubleNumpyArray_(self, *args)
TypeError: Application_SetImageFromCDoubleNumpyArray_() takes exactly 7 arguments (4 given)
My understanding
In otbApplication.i
, SetImageFromNumpyArray()
calls the typed python binding function from the map with only 4 parameters.
Then, depending on OTB version, the python binding may the correct number of parameters, but eventually it fails to call the OTB mapped function which expects 7 parameters.
If I understand correctly, SetImageFromNumpyArray()
should be able to deduce the region (1) parameters. Either they could come from ImportImage()
region key in the dictionary, or they could be deduced from the shape of the np.array
. Then all these region information could be forwarded all the way to C++ mapped functions.
(1) At this time, size parameters are expected, but it should be possible to pass the complete region information instead of guessing something in the SetFromNumpyArrayMacro
macro.
Configuration information
- OS: Linux CentOS 7
- OTB 7.0 on HAL, or installed from dev branch
- Python: 3.7.2