From 38c82ca3547c596988003f3d22db9e19e8ccb35b Mon Sep 17 00:00:00 2001 From: Arnaud Jaen <arnaud.jaen@c-s.fr> Date: Tue, 2 Apr 2013 17:40:22 +0200 Subject: [PATCH] ENH: Use forward declaration in all MachineLearningModel. --- .../OpenCV/otbBoostMachineLearningModel.h | 3 ++- .../OpenCV/otbBoostMachineLearningModel.txx | 2 ++ .../OpenCV/otbKNearestNeighborsMachineLearningModel.h | 2 +- .../OpenCV/otbKNearestNeighborsMachineLearningModel.txx | 2 ++ .../OpenCV/otbRandomForestsMachineLearningModel.h | 8 +++----- .../OpenCV/otbRandomForestsMachineLearningModel.txx | 9 +++++++++ .../OpenCV/otbSVMMachineLearningModel.h | 2 +- .../OpenCV/otbSVMMachineLearningModel.txx | 1 + 8 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Code/UtilitiesAdapters/OpenCV/otbBoostMachineLearningModel.h b/Code/UtilitiesAdapters/OpenCV/otbBoostMachineLearningModel.h index fc6dae54a2..fa4f9be5c3 100644 --- a/Code/UtilitiesAdapters/OpenCV/otbBoostMachineLearningModel.h +++ b/Code/UtilitiesAdapters/OpenCV/otbBoostMachineLearningModel.h @@ -24,7 +24,8 @@ #include "itkListSample.h" #include "otbMachineLearningModel.h" -#include <opencv2/opencv.hpp> + +class CvBoost; namespace otb { diff --git a/Code/UtilitiesAdapters/OpenCV/otbBoostMachineLearningModel.txx b/Code/UtilitiesAdapters/OpenCV/otbBoostMachineLearningModel.txx index 3dec711f03..6c6cea7419 100644 --- a/Code/UtilitiesAdapters/OpenCV/otbBoostMachineLearningModel.txx +++ b/Code/UtilitiesAdapters/OpenCV/otbBoostMachineLearningModel.txx @@ -21,6 +21,8 @@ #include "otbBoostMachineLearningModel.h" #include "otbOpenCVUtils.h" +#include <opencv2/opencv.hpp> + namespace otb { diff --git a/Code/UtilitiesAdapters/OpenCV/otbKNearestNeighborsMachineLearningModel.h b/Code/UtilitiesAdapters/OpenCV/otbKNearestNeighborsMachineLearningModel.h index 5cfe8f899c..f94ef23a55 100644 --- a/Code/UtilitiesAdapters/OpenCV/otbKNearestNeighborsMachineLearningModel.h +++ b/Code/UtilitiesAdapters/OpenCV/otbKNearestNeighborsMachineLearningModel.h @@ -24,7 +24,7 @@ #include "itkListSample.h" #include "otbMachineLearningModel.h" -#include <opencv2/opencv.hpp> +class CvKNearest; namespace otb { diff --git a/Code/UtilitiesAdapters/OpenCV/otbKNearestNeighborsMachineLearningModel.txx b/Code/UtilitiesAdapters/OpenCV/otbKNearestNeighborsMachineLearningModel.txx index 4455c3838b..2ecdc83237 100644 --- a/Code/UtilitiesAdapters/OpenCV/otbKNearestNeighborsMachineLearningModel.txx +++ b/Code/UtilitiesAdapters/OpenCV/otbKNearestNeighborsMachineLearningModel.txx @@ -21,6 +21,8 @@ #include "otbKNearestNeighborsMachineLearningModel.h" #include "otbOpenCVUtils.h" +#include <opencv2/opencv.hpp> + namespace otb { diff --git a/Code/UtilitiesAdapters/OpenCV/otbRandomForestsMachineLearningModel.h b/Code/UtilitiesAdapters/OpenCV/otbRandomForestsMachineLearningModel.h index 12a8e60c36..9ed54c47b5 100644 --- a/Code/UtilitiesAdapters/OpenCV/otbRandomForestsMachineLearningModel.h +++ b/Code/UtilitiesAdapters/OpenCV/otbRandomForestsMachineLearningModel.h @@ -24,7 +24,7 @@ #include "itkListSample.h" #include "otbMachineLearningModel.h" -#include <opencv2/opencv.hpp> // opencv general include file +class CvRTrees; namespace otb { @@ -170,10 +170,8 @@ public: // return m_RFModel->getVarImportance(); // } - float GetTrainError() - { - return m_RFModel->get_train_error(); - } + float GetTrainError(); + protected: /** Constructor */ RandomForestsMachineLearningModel(); diff --git a/Code/UtilitiesAdapters/OpenCV/otbRandomForestsMachineLearningModel.txx b/Code/UtilitiesAdapters/OpenCV/otbRandomForestsMachineLearningModel.txx index 3e3990f68a..c998795a39 100644 --- a/Code/UtilitiesAdapters/OpenCV/otbRandomForestsMachineLearningModel.txx +++ b/Code/UtilitiesAdapters/OpenCV/otbRandomForestsMachineLearningModel.txx @@ -22,6 +22,7 @@ #include "otbRandomForestsMachineLearningModel.h" #include "otbOpenCVUtils.h" +#include <opencv2/opencv.hpp> // opencv general include file namespace otb { @@ -51,6 +52,14 @@ RandomForestsMachineLearningModel<TInputValue,TOutputValue> delete m_RFModel; } +template <class TInputValue, class TOutputValue> +float +RandomForestsMachineLearningModel<TInputValue,TOutputValue> +::GetTrainError() +{ + return m_RFModel->get_train_error(); +} + /** Train the machine learning model */ template <class TInputValue, class TOutputValue> void diff --git a/Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.h b/Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.h index 74e232955c..f10a448154 100644 --- a/Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.h +++ b/Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.h @@ -25,7 +25,7 @@ #include "itkListSample.h" #include "otbMachineLearningModel.h" -#include <opencv2/opencv.hpp> // opencv general include file +class CvSVM; namespace otb { diff --git a/Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.txx b/Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.txx index a532767646..b4563da2fb 100644 --- a/Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.txx +++ b/Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.txx @@ -21,6 +21,7 @@ #include <fstream> #include "otbSVMMachineLearningModel.h" #include "otbOpenCVUtils.h" +#include <opencv2/opencv.hpp> // opencv general include file namespace otb { -- GitLab