Option to remove the progress bar in the Python wrapper
In the command line interface (otbcli_XXX
), there is an option -progress
available to hide the progress of an application. For example :
- With progress :
otbcli_EdgeExtraction -in S2A_ROI.tif -out /tmp/out.tif -progress true
2020-06-17 16:28:59 (INFO) EdgeExtraction: Default RAM limit for OTB is 256 MB
2020-06-17 16:28:59 (INFO) EdgeExtraction: GDAL maximum cache size is 794 MB
2020-06-17 16:29:00 (INFO) EdgeExtraction: OTB will use at most 12 threads
2020-06-17 16:29:00 (INFO): Estimated memory for full processing: 38.8794MB (avail.: 256 MB), optimal image partitioning: 1 blocks
2020-06-17 16:29:00 (INFO): File /tmp/out.tif will be written in 1 blocks of 1000x1000 pixels
Writing /tmp/out.tif...: 100% [**************************************************] (0s)
- Without progress :
otbcli_EdgeExtraction -in S2A_ROI.tif -out /tmp/out.tif -progress false
2020-06-17 16:29:05 (INFO) EdgeExtraction: Default RAM limit for OTB is 256 MB
2020-06-17 16:29:05 (INFO) EdgeExtraction: GDAL maximum cache size is 794 MB
2020-06-17 16:29:05 (INFO) EdgeExtraction: OTB will use at most 12 threads
2020-06-17 16:29:05 (INFO): Estimated memory for full processing: 38.8794MB (avail.: 256 MB), optimal image partitioning: 1 blocks
2020-06-17 16:29:05 (INFO): File /tmp/out.tif will be written in 1 blocks of 1000x1000 pixels
The Python wrapper does not have the same functionality and it could be interesting to add it.
When creating an application in Python an observer object is added on the pipeline, the progress is then redirected to the python console. Calling RemoveAllObserver()
on the application will remove the progress reporting. However this API is not very explicit, and it can have side effects as all observers are removed.
A solution would be to store in the application Python object the tag associated to the observer return by ITK when creating the observer, to be able to remove the observer directly from Python with RemoveObserver(tag)
. This could be encapsulated in a Application.ReportProgress(bool)
method that removes the observer if there is one, or create another one if it has been previously destroyed.