diff --git a/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.h b/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.h index 71f4f7263d05b56b23827dd680160d2a1c6752e4..c051b33997673d423c5c306dc0b6aa2026313c9c 100644 --- a/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.h +++ b/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.h @@ -237,6 +237,9 @@ private: /** Step of the detection grid */ unsigned int m_GridStep; + /** classification model */ + ModelPointerType m_Model; + }; diff --git a/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.txx b/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.txx index fa9c4b4427710b11846a7731425b8dbd5e8a9e3f..884cf3f07645b43b1dd0b6f93ce1c9a92ff4b9a6 100644 --- a/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.txx +++ b/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.txx @@ -36,8 +36,7 @@ PersistentObjectDetectionClassifier<TInputImage, TOutputVectorData, TLabel, TFun m_NoClassLabel(0), m_GridStep(10) { - // Need 2 inputs : a vector image, and a SVMModel - this->SetNumberOfRequiredInputs(2); + this->SetNumberOfRequiredInputs(1); // Have 2 outputs : the image created by Superclass, a vector data with points this->SetNumberOfRequiredOutputs(3); @@ -86,7 +85,11 @@ void PersistentObjectDetectionClassifier<TInputImage, TOutputVectorData, TLabel, TFunctionType> ::SetModel(ModelType* model) { - this->SetNthInput(1, model); + if (model != m_Model) + { + m_Model = model; + this->Modified(); + } } template <class TInputImage, class TOutputVectorData, class TLabel, class TFunctionType> @@ -94,11 +97,7 @@ const typename PersistentObjectDetectionClassifier<TInputImage, TOutputVectorDat PersistentObjectDetectionClassifier<TInputImage, TOutputVectorData, TLabel, TFunctionType> ::GetModel(void) const { - if(this->GetNumberOfInputs()<2) - { - return ITK_NULLPTR; - } - return static_cast<const ModelType*>(this->itk::ProcessObject::GetInput(1)); + return m_Model; } template <class TInputImage, class TOutputVectorData, class TLabel, class TFunctionType> diff --git a/Modules/Learning/Supervised/include/otbLabelMapClassifier.h b/Modules/Learning/Supervised/include/otbLabelMapClassifier.h index 9914e2a15e81d9e71b1b038f1231b94b98ba8f47..75dc291f3df947dbe9a9ab6d45d4fca8ccd73470 100644 --- a/Modules/Learning/Supervised/include/otbLabelMapClassifier.h +++ b/Modules/Learning/Supervised/include/otbLabelMapClassifier.h @@ -35,7 +35,7 @@ namespace otb { * \sa otb::SVMModel * \sa itk::InPlaceLabelMapFilter * - * \ingroup OTBSVMLearning + * \ingroup OTBSupervised */ template<class TInputLabelMap> class ITK_EXPORT LabelMapClassifier : diff --git a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h index 1e5cbb964e77daba9345a2e390e76d889f9ee9c7..fc51f72bf969238dea8b05c60dfcaec274b9b0f0 100644 --- a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h @@ -238,9 +238,9 @@ public: void SetConfidenceMode(unsigned int mode) { - if (mode != m_ConfidenceMode) + if (m_ConfidenceMode != static_cast<ConfidenceMode>(mode) ) { - m_ConfidenceMode = mode; + m_ConfidenceMode = static_cast<ConfidenceMode>(mode); this->m_ConfidenceIndex = this->HasProbabilities(); this->Modified(); } diff --git a/Modules/Learning/Supervised/include/otbSVMMarginSampler.txx b/Modules/Learning/Supervised/include/otbSVMMarginSampler.txx index 04aa7ddc0e7e93f6306afed99025a18f5398cbd9..b5ca257fadec2c14c4d69aa5078005a3ddf71b81 100644 --- a/Modules/Learning/Supervised/include/otbSVMMarginSampler.txx +++ b/Modules/Learning/Supervised/include/otbSVMMarginSampler.txx @@ -89,13 +89,13 @@ SVMMarginSampler< TSample, TModel > while (iter != end && iterO != endO) { int i = 0; - typename SVMModelType::InputSampleType modelMeasurement; + typename SVMModelType::InputSampleType modelMeasurement(numberOfComponentsPerSample); measurements = iter.GetMeasurementVector(); // otbMsgDevMacro( << "Loop on components " << svm_type ); for (i=0; i<numberOfComponentsPerSample; ++i) { - modelMeasurement.PushBack(measurements[i]); + modelMeasurement[i] = measurements[i]; } // Get distances to the hyperplanes