Otb segmentation

Dear all,

i want to perform a object-based-image analysis within QGIS 3.4.4 (Madeira). Therefore i installed and configured the OTB plugin. It is available in my toolbox in QGIS, but each time when i try to run the tool segmentation i receive the error message: wrong or missing parameter value: condition.

I tried to modify my parameters but it doesn’t work.

Might this be due to false chosen parameters, installation problems or the fact that the plugin is still experimental?

I would be very glad to receive an answer soon because time is running (master thesis :frowning: )

Thanks in advance,

Vana

@ Julien: Do you mean the tab ‘log’ of the tool segmentation with algorithm configuration window?
Thw log window is empty (see screenshot)

Hi Vana,

Yes this is an issue we are trying to solve. You need to manually change the descriptor file!

It should be in PathWhereIsOTB/share/otb/description/Segmentation.txt then change this line :

QgsProcessingParameterString|filter.cc.expr|Condition|None|False|False
to
QgsProcessingParameterString|filter.cc.expr|Condition|None|False|True

And you should be good to go!

Antoine

Hej Antoine,
so the previous error message doesn’t occur anymore. The calculation runs, but there is no result in the end. I attach the algorithm log. Seems that there is a problem with the installation (module missing)?
Regards,

It seems that you are giving the wrong path to OTB_APPLICATION_PATH. Where is your installation of OTB?
OTB_APPLICATION_PATH should look like this :
path_where_is_otb/lib/otb/applications/

Thank you Antoine for all your support,
i modified the paths. Now there is no error message anymore, but it runs super long without progress. I think there’s still a installation problem.

Well that is weird… What is the platform you are using and what version of OTB are you using? Also do you have the error with other application? If you try the Pixelvalue application for instance?

Yes i tried other otb applications, they also don’t work or actually QGIS runs without progress.
I am using Windows 7 and i downloaded OTB-6.6.1-Win64 from https://www.orfeo-toolbox.org/download/
and qgis-otb-plugin-master from https://gitlab.orfeo-toolbox.org/orfeotoolbox/qgis-otb-plugin.
I decompressed both and copied them to C:. The qgis-otb-plugin has been stored in a new folder qgis-plugins.
Than as in the cookbook https://www.orfeo-toolbox.org/CookBook/QGIS-interface.html?highlight=qgis described, i modified the environment variables by creating a new variable QGIS_PLUGINPATH and set the path to C:\qgis-plugins\qgis-otb-plugin.
Once QGIS has started, i modified the application folder and otb folder path (Settings > Options > Processing >Provider).
Did i miss a important step?

I don’t think so… Have you tried to run directly OTB? like monteverdi or any other application?
And also are you sure to use the right package for your architecture (x86 or x64)?

Hi Vana & Antoine,
did you manage to resolve the issues? I’m having exactly the same problems!

I am trying to run a segmentation meanshift on a tiff image with QGIS and OTB plugin. I downloaded and installed the latest versions of both yesterday.

I was getting the error message the same as Vana, “wrong or missing parameter value:condition” and I have changed the text as suggested by Antoine. That has resolved the error, but I’m not getting a result. When I click on run I get the following log file

Processing algorithm…
Algorithm ‘Segmentation’ starting…
Input parameters:
{ ‘in’ : ‘Y:/GIS/_WorkingProjects/2018_PROJECTS/18084_Drone imagery/Landell41_Orthomosaic_FriApr20063532/Landell41_Orthomosaic_export_FriApr20.tif’, ‘filter’ : ‘meanshift’, ‘filter.meanshift.spatialr’ : 5, ‘filter.meanshift.ranger’ : 15, ‘filter.meanshift.thres’ : 0.1, ‘filter.meanshift.maxiter’ : 100, ‘filter.meanshift.minsize’ : 100, ‘mode’ : ‘vector’, ‘mode.vector.out’ : ‘C:/Users/helena.nermut/AppData/Local/Temp/processing_a5a20cb71194425989dce8f4db5390da/5ea1964361154d7b97ffc4974475bb54/mode.vector.out.file’, ‘mode.vector.outmode’ : ‘ulco’, ‘mode.vector.inmask’ : None, ‘mode.vector.neighbor’ : False, ‘mode.vector.stitch’ : True, ‘mode.vector.minsize’ : 1, ‘mode.vector.simplify’ : 0.1, ‘mode.vector.layername’ : ‘’, ‘mode.vector.fieldname’ : ‘’, ‘mode.vector.tilesize’ : 1024, ‘mode.vector.startlabel’ : 1, ‘mode.vector.ogroptions’ : ‘’ }

I left it running over night (just in case) and it did not progress beyond this point.

The OTB application folder is set to C:/OTB-6.6.1/lib/otb/applications & the OTB folder is set to C:/OTB-6.6.1

Any ideas??
thanks
Helena

Hi Helena,
Have you tried running directly the Segmentation application in OTB to see whether it is a problem between QGIS and OTB or just OTB?
Which windows are you on? And what architecture?

Hi Antoine,
I’m running windows 10, 64bit. I’ll try running OTB separately and let you know how I go

thanks
Helena

Great! I’ll try to reproduce your problem, but I only have a windows 8 and QGIS 3.2.0.

EDIT: I have no problem running it with this configuration.
EDIT2: Problem identified with QGIS 3.4.4
EDIT3: The issue is on the qgis_otb_cli.bat file. The variable OTB_LOGGER_INFO introduce a bug and prevent the plugin to work correctly… This bat file is regenerated by QGIS every time, so we need to modify how it is generated by the otb plugin.

I have a quick and dirty workaround for now. It seems that the plugin does not behave correctly because of an environment variable…
To solve the issue what you can do is:

  • Find the file OtbAlgorithmProvider.py it should be in your otb plugin directory under otb.
  • Comment line 197 and 198 : they are about a looger :
if OtbUtils.loggerLevel():
  otb_cli_file.write(export_cmd + "OTB_LOGGER_LEVEL=" + "\"" + OtbUtils.loggerLevel() + "\"" + os.linesep)

Once those lines are commented re open QGIS and you should be good to go.
We will find a fix soon and the new master branch of the plugin will be flawless (I hope so!!).

Hi Antonie,
thanks so much for your help! I won’t be able to test till next week, but I will let you know how I go.

I also tested segmentation in Monteverdi and it all worked correctly

Thanks again for your help
Helena.

Hi Antonie,
I have the changes you suggested to OtbAlgorithmProvider.py. The OTB segmentation tool now works correctly in QGIS 3.4.4.

thank you very much for your help!

Helena

Hi Helena,

You can remove QGIS_PLUGINPATH variable and re-install plugin from cnes qgis plugin repository. This contains above fix from Antonie and works with QGIS 3.4 upto 3.8

Let me if it works for you.

Thanks Rasad. I will try and get to it in the next couple of days (sorry busy week at work) and let you know how I go
Helena

Hi Antoine & Rashad,
I have reinstalled the QGIS plugin and all is working well. Thank you to you both for the quick turn around on this issue. Very much appreciated!!

Cheers
Helena