From f82e36823b84bd7944628f1d916325e93b19520c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <cedric.traizet@c-s.fr>
Date: Thu, 18 Apr 2019 17:08:20 +0200
Subject: [PATCH] ENH: added a warning if the number of input of centroid is
 not the same as the number of classes

---
 .../AppClassification/include/otbTrainSharkKMeans.hxx         | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Modules/Applications/AppClassification/include/otbTrainSharkKMeans.hxx b/Modules/Applications/AppClassification/include/otbTrainSharkKMeans.hxx
index d56a83c815..872391ee73 100644
--- a/Modules/Applications/AppClassification/include/otbTrainSharkKMeans.hxx
+++ b/Modules/Applications/AppClassification/include/otbTrainSharkKMeans.hxx
@@ -111,6 +111,10 @@ void LearningApplicationBase<TInputValue, TOutputValue>::TrainSharkKMeans(
       shark::Normalizer<> normalizer(scaleRV, offsetRV);
       centroidData = normalizer(centroidData);
     }
+
+    if (centroidData.numberOfElements() != k)
+      otbAppLogWARNING( "The input centroid file will not be used because it contains " << centroidData.numberOfElements() <<
+      " points, which is different than from the requested number of class: " << k <<".");
     
     classifier->SetCentroidsFromData( centroidData);
   }
-- 
GitLab