Commit 4685f0e9 authored by Alexandre Benoit's avatar Alexandre Benoit

corrected xml parameters file management in the retina interface

parent 77cfdab3
...@@ -116,22 +116,22 @@ public: ...@@ -116,22 +116,22 @@ public:
/** /**
* Main constructor with most commun use setup : create an instance of color ready retina model * Main constructor with most commun use setup : create an instance of color ready retina model
* @param parametersSaveFile : the filename of the xml file that records the used retina parametes setup
* @param inputSize : the input frame size * @param inputSize : the input frame size
* @param parametersSaveFile : the filename of the xml file that records the default retina parameters setup, if empty, then, no default parameter file will be written
*/ */
Retina(const std::string parametersSaveFile, Size inputSize); Retina(Size inputSize, const std::string parametersSaveFile="");
/** /**
* Complete Retina filter constructor which allows all basic structural parameters definition * Complete Retina filter constructor which allows all basic structural parameters definition
* @param parametersSaveFile : the filename of the xml file that records the used retina parametes setup
* @param inputSize : the input frame size * @param inputSize : the input frame size
* @param parametersSaveFile : the filename of the xml file that records the default retina parameters setup, if empty, then, no default parameter file will be written
* @param colorMode : the chosen processing mode : with or without color processing * @param colorMode : the chosen processing mode : with or without color processing
* @param colorSamplingMethod: specifies which kind of color sampling will be used * @param colorSamplingMethod: specifies which kind of color sampling will be used
* @param useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can be used * @param useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can be used
* @param reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction factor of the output frame (as the center (fovea) is high resolution and corners can be underscaled, then a reduction of the output is allowed without precision leak * @param reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction factor of the output frame (as the center (fovea) is high resolution and corners can be underscaled, then a reduction of the output is allowed without precision leak
* @param samplingStrenght: only usefull if param useRetinaLogSampling=true, specifies the strenght of the log scale that is applied * @param samplingStrenght: only usefull if param useRetinaLogSampling=true, specifies the strenght of the log scale that is applied
*/ */
Retina(const std::string parametersSaveFile, Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0); Retina(Size inputSize, const std::string parametersSaveFile, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0);
virtual ~Retina(); virtual ~Retina();
...@@ -266,7 +266,7 @@ protected: ...@@ -266,7 +266,7 @@ protected:
const bool _convertCvMat2ValarrayBuffer(const cv::Mat inputMatToConvert, std::valarray<float> &outputValarrayMatrix); const bool _convertCvMat2ValarrayBuffer(const cv::Mat inputMatToConvert, std::valarray<float> &outputValarrayMatrix);
//! private method called by constructors, gathers their parameters and use them in a unified way //! private method called by constructors, gathers their parameters and use them in a unified way
void _init(const std::string parametersSaveFile, Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0); void _init(const std::string parametersSaveFileName, Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0);
}; };
......
...@@ -75,13 +75,13 @@ ...@@ -75,13 +75,13 @@
namespace cv namespace cv
{ {
Retina::Retina(const std::string parametersSaveFile, const cv::Size inputSize) Retina::Retina(const cv::Size inputSize, const std::string parametersSaveFile)
{ {
_retinaFilter = 0; _retinaFilter = 0;
_init(parametersSaveFile, inputSize, true, RETINA_COLOR_BAYER, false); _init(parametersSaveFile, inputSize, true, RETINA_COLOR_BAYER, false);
} }
Retina::Retina(const std::string parametersSaveFile, const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght) Retina::Retina(const cv::Size inputSize, const std::string parametersSaveFile, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
{ {
_retinaFilter = 0; _retinaFilter = 0;
_init(parametersSaveFile, inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght); _init(parametersSaveFile, inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
...@@ -303,9 +303,9 @@ void Retina::getMagno(std::valarray<float> &){_retinaFilter->getMovingContours() ...@@ -303,9 +303,9 @@ void Retina::getMagno(std::valarray<float> &){_retinaFilter->getMovingContours()
void Retina::getParvo(std::valarray<float> &){_retinaFilter->getContours();} void Retina::getParvo(std::valarray<float> &){_retinaFilter->getContours();}
// private method called by constructirs // private method called by constructirs
void Retina::_init(const std::string parametersSaveFile, const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght) void Retina::_init(const std::string parametersSaveFileName, const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
{ {
_parametersSaveFileName = parametersSaveFile; _parametersSaveFileName = parametersSaveFileName;
// basic error check // basic error check
if (inputSize.height*inputSize.width <= 0) if (inputSize.height*inputSize.width <= 0)
...@@ -320,22 +320,24 @@ void Retina::_init(const std::string parametersSaveFile, const cv::Size inputSiz ...@@ -320,22 +320,24 @@ void Retina::_init(const std::string parametersSaveFile, const cv::Size inputSiz
delete _retinaFilter; delete _retinaFilter;
_retinaFilter = new RetinaFilter(inputSize.height, inputSize.width, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght); _retinaFilter = new RetinaFilter(inputSize.height, inputSize.width, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
// prepare the parameter XML tree // prepare the default parameter XML file with default setup
_parametersSaveFile.open(parametersSaveFile, cv::FileStorage::WRITE ); if (_parametersSaveFileName.size()>0)
{
_parametersSaveFile<<"InputSize"<<"{"; _parametersSaveFile.open(parametersSaveFileName, cv::FileStorage::WRITE );
_parametersSaveFile<<"height"<<inputSize.height;
_parametersSaveFile<<"width"<<inputSize.width;
_parametersSaveFile<<"}";
// clear all retina buffers _parametersSaveFile<<"InputSize"<<"{";
// apply default setup _parametersSaveFile<<"height"<<inputSize.height;
setupOPLandIPLParvoChannel(); _parametersSaveFile<<"width"<<inputSize.width;
setupIPLMagnoChannel(); _parametersSaveFile<<"}";
// write current parameters to params file // clear all retina buffers
_parametersSaveFile.release(); // apply default setup
setupOPLandIPLParvoChannel();
setupIPLMagnoChannel();
// write current parameters to params file
_parametersSaveFile.release();
}
// init retina // init retina
_retinaFilter->clearAllBuffers(); _retinaFilter->clearAllBuffers();
......
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