Commit 88488484 authored by OTB Bot's avatar OTB Bot

STYLE

parent 06fcb91b
......@@ -26,7 +26,7 @@
//include opencv
#include <cv.h> // opencv general include file
#include <ml.h> // opencv machine learning include file
#include <ml.h> // opencv machine learning include file
namespace otb
{
......
......@@ -26,7 +26,7 @@
//include opencv
#include <opencv.hpp> // opencv general include file
#include <ml/ml.hpp> // opencv machine learning include file
#include <ml/ml.hpp> // opencv machine learning include file
namespace otb
{
......
......@@ -26,7 +26,7 @@
//include opencv
//#include <opencv.hpp> // opencv general include file
//#include <ml/ml.hpp> // opencv machine learning include file
//#include <ml/ml.hpp> // opencv machine learning include file
// SVM estimator
#include "otbSVMSampleListModelEstimator.h"
......
......@@ -20,7 +20,7 @@
#include "otbMachineLearningModel.h"
namespace otb
namespace otb
{
template <class TInputValue, class TOutputValue>
......@@ -43,7 +43,7 @@ MachineLearningModel<TInputValue,TOutputValue>
targets->Clear();
for(typename InputListSampleType::ConstIterator sIt = this->GetInputListSample()->Begin();
sIt!=this->GetInputListSample()->End();++sIt)
sIt!=this->GetInputListSample()->End(); ++sIt)
{
targets->PushBack(this->Predict(sIt.GetMeasurementVector()));
}
......
......@@ -79,7 +79,7 @@ bool ReadDataFile(const char * infname, InputListSampleType * samples, TargetLis
sample[id] = atof(feature.substr(semicolonpos+1,feature.size()-semicolonpos).c_str());
pos = nextpos;
}
}
}
samples->PushBack(sample);
labels->PushBack(label);
}
......
......@@ -28,7 +28,7 @@ namespace otb
output.create(1,sample.Size(),CV_32FC1);
// Loop on sample size
for(unsigned int i = 0; i < sample.Size();++i)
for(unsigned int i = 0; i < sample.Size(); ++i)
{
output.at<float>(0,i) = sample[i];
}
......@@ -47,30 +47,30 @@ namespace otb
// Check for valid listSample
if(listSample != NULL && listSample->Size() > 0)
{
// Retrieve samples count
unsigned int sampleCount = listSample->Size();
// Retrieve samples count
unsigned int sampleCount = listSample->Size();
// Build an iterator
typename T::ConstIterator sampleIt = listSample->Begin();
// Retrieve samples size alike
const unsigned int sampleSize = listSample->GetMeasurementVectorSize();
// Allocate CvMat
output.create(sampleCount,sampleSize,CV_32FC1);
// Fill the cv matrix
for(;sampleIt!=listSample->End();++sampleIt,++sampleIdx)
{
// Retrieve sample
typename T::MeasurementVectorType sample = sampleIt.GetMeasurementVector();
// Loop on sample size
for(unsigned int i = 0; i < sampleSize;++i)
{
output.at<float>(sampleIdx,i) = sample[i];
}
}
// Build an iterator
typename T::ConstIterator sampleIt = listSample->Begin();
// Retrieve samples size alike
const unsigned int sampleSize = listSample->GetMeasurementVectorSize();
// Allocate CvMat
output.create(sampleCount,sampleSize,CV_32FC1);
// Fill the cv matrix
for(; sampleIt!=listSample->End(); ++sampleIt,++sampleIdx)
{
// Retrieve sample
typename T::MeasurementVectorType sample = sampleIt.GetMeasurementVector();
// Loop on sample size
for(unsigned int i = 0; i < sampleSize; ++i)
{
output.at<float>(sampleIdx,i) = sample[i];
}
}
}
}
......@@ -94,22 +94,22 @@ namespace otb
unsigned int sampleSize = cvmat.cols;
// Loop on samples
for(unsigned int i = 0; i < sampleCount;++i)
{
typename T::MeasurementVectorType sample;
itk::PixelBuilder<typename T::MeasurementVectorType>::Zero(sample,sampleSize);
unsigned int realSampleSize = sample.Size();
for(unsigned int j = 0; j < realSampleSize;++j)
{
// Don't forget to cast
sample[j] = static_cast<typename T::MeasurementVectorType
::ValueType>(cvmat.at<float>(i,j));
}
// PushBack the new sample
output->PushBack(sample);
}
for(unsigned int i = 0; i < sampleCount; ++i)
{
typename T::MeasurementVectorType sample;
itk::PixelBuilder<typename T::MeasurementVectorType>::Zero(sample,sampleSize);
unsigned int realSampleSize = sample.Size();
for(unsigned int j = 0; j < realSampleSize; ++j)
{
// Don't forget to cast
sample[j] = static_cast<typename T::MeasurementVectorType
::ValueType>(cvmat.at<float>(i,j));
}
// PushBack the new sample
output->PushBack(sample);
}
// return the output
return output;
}
......
......@@ -26,7 +26,7 @@
//include opencv
#include <opencv.hpp> // opencv general include file
#include <ml/ml.hpp> // opencv machine learning include file
#include <ml/ml.hpp> // opencv machine learning include file
namespace otb
{
......
......@@ -78,8 +78,8 @@ RandomForestsMachineLearningModel<TInputValue,TOutputValue>
priors, // the array of priors
m_CalculateVariableImportance, // calculate variable importance
m_MaxNumberOfVariables, // number of variables randomly selected at node and used to find the best split(s).
m_MaxNumberOfTrees, // max number of trees in the forest
m_ForestAccuracy, // forrest accuracy
m_MaxNumberOfTrees, // max number of trees in the forest
m_ForestAccuracy, // forrest accuracy
m_TerminationCriteria // termination cirteria
);
......@@ -90,7 +90,7 @@ RandomForestsMachineLearningModel<TInputValue,TOutputValue>
//train the RT model
m_RFModel->train(samples, CV_ROW_SAMPLE, labels,
cv::Mat(), cv::Mat(), var_type, cv::Mat(), params);
cv::Mat(), cv::Mat(), var_type, cv::Mat(), params);
}
template <class TInputValue, class TOutputValue>
......
......@@ -27,7 +27,7 @@
//include opencv
#include <opencv.hpp> // opencv general include file
#include <ml/ml.hpp> // opencv machine learning include file
#include <ml/ml.hpp> // opencv machine learning include file
namespace otb
{
......
......@@ -90,10 +90,10 @@ void
SVMMachineLearningModel<TInputValue,TOutputValue>
::Save(const std::string & filename, const std::string & name)
{
if (name == "")
m_SVMModel->save(filename.c_str(), 0);
else
m_SVMModel->save(filename.c_str(), name.c_str());
if (name == "")
m_SVMModel->save(filename.c_str(), 0);
else
m_SVMModel->save(filename.c_str(), name.c_str());
}
template <class TInputValue, class TOutputValue>
......@@ -102,9 +102,9 @@ SVMMachineLearningModel<TInputValue,TOutputValue>
::Load(const std::string & filename, const std::string & name)
{
if (name == "")
m_SVMModel->load(filename.c_str(), 0);
m_SVMModel->load(filename.c_str(), 0);
else
m_SVMModel->load(filename.c_str(), name.c_str());
m_SVMModel->load(filename.c_str(), name.c_str());
}
template <class TInputValue, class TOutputValue>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment