From 0d10761f921d7cf2f2cc05fdec344dce65d9840a Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@cnes.fr>
Date: Wed, 5 Apr 2017 15:50:43 +0200
Subject: [PATCH] BUG: Retrieve labels even in unsupervised mode

---
 .../app/otbTrainVectorClassifier.cxx                  | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx
index 62661a8468..2d867ec80a 100644
--- a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx
+++ b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx
@@ -64,14 +64,11 @@ private:
   void DoBeforeTrainExecute()
   {
     // Enforce the need of class field name in supervised mode
-    if (GetClassifierCategory() == Supervised)
+    featuresInfo.SetClassFieldNames( GetChoiceNames( "cfield" ), GetSelectedItems( "cfield" ) );
+    
+    if( featuresInfo.m_SelectedCFieldIdx.empty() )
       {
-      featuresInfo.SetClassFieldNames( GetChoiceNames( "cfield" ), GetSelectedItems( "cfield" ) );
-
-      if( featuresInfo.m_SelectedCFieldIdx.empty() )
-        {
-        otbAppLogFATAL( << "No field has been selected for data labelling!" );
-        }
+      otbAppLogFATAL( << "No field has been selected for data labelling!" );
       }
   }
 
-- 
GitLab