Skip to content

Commit af26ce3

Browse files
catreevpisarev
authored andcommitted
Bioinspired module: remove printSetup to avoid unnecessary printing in the console, fix some typos. (#905)
1 parent 8a23411 commit af26ce3

File tree

3 files changed

+31
-46
lines changed

3 files changed

+31
-46
lines changed

modules/bioinspired/include/opencv2/bioinspired/retina.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ class CV_EXPORTS_W Retina : public Algorithm {
226226
- warning, Exceptions are thrown if read XML file is not valid
227227
@param retinaParameterFile the parameters filename
228228
@param applyDefaultSetupOnFailure set to true if an error must be thrown on error
229-
You can retreive the current parameers structure using method Retina::getParameters and update
230-
it before running method Retina::setup
229+
230+
You can retrieve the current parameters structure using the method Retina::getParameters and update
231+
it before running method Retina::setup.
231232
*/
232233
CV_WRAP virtual void setup(String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true)=0;
233234

modules/bioinspired/src/retina.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ class RetinaImpl : public Retina
8686
* Main constructor with most commun use setup : create an instance of color ready retina model
8787
* @param inputSize : the input frame size
8888
*/
89-
RetinaImpl(Size inputSize);
89+
RetinaImpl(const Size inputSize);
9090

9191
/**
9292
* Complete Retina filter constructor which allows all basic structural parameters definition
93-
* @param inputSize : the input frame size
93+
* @param inputSize : the input frame size
9494
* @param colorMode : the chosen processing mode : with or without color processing
9595
* @param colorSamplingMethod: specifies which kind of color sampling will be used
9696
* @param useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can be used
9797
* @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
9898
* @param samplingStrenght: only usefull if param useRetinaLogSampling=true, specifies the strenght of the log scale that is applied
9999
*/
100-
RetinaImpl(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const float reductionFactor=1.0f, const float samplingStrenght=10.0f);
100+
RetinaImpl(const Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const float reductionFactor=1.0f, const float samplingStrenght=10.0f);
101101

102102
virtual ~RetinaImpl();
103103
/**
@@ -115,7 +115,7 @@ class RetinaImpl : public Retina
115115
* => if the xml file does not exist, then default setup is applied
116116
* => warning, Exceptions are thrown if read XML file is not valid
117117
* @param retinaParameterFile : the parameters filename
118-
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
118+
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
119119
*/
120120
void setup(String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true);
121121

@@ -125,7 +125,7 @@ class RetinaImpl : public Retina
125125
* => if the xml file does not exist, then default setup is applied
126126
* => warning, Exceptions are thrown if read XML file is not valid
127127
* @param fs : the open Filestorage which contains retina parameters
128-
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
128+
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
129129
*/
130130
void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true);
131131

@@ -134,7 +134,7 @@ class RetinaImpl : public Retina
134134
* => if the xml file does not exist, then default setup is applied
135135
* => warning, Exceptions are thrown if read XML file is not valid
136136
* @param newParameters : a parameters structures updated with the new target configuration
137-
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
137+
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
138138
*/
139139
void setup(RetinaParameters newParameters);
140140

@@ -411,9 +411,6 @@ void RetinaImpl::setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailur
411411
printf("Retina::setup: wrong/unappropriate xml parameter file : error report :`n=>%s\n", e.what());
412412
printf("=> keeping current parameters\n");
413413
}
414-
415-
// report current configuration
416-
printf("%s\n", printSetup().c_str());
417414
}
418415

419416
void RetinaImpl::setup(RetinaParameters newConfiguration)
@@ -615,7 +612,7 @@ const Mat RetinaImpl::getParvoRAW() const {
615612
return Mat((int)_retinaFilter->getContours().size(), 1, CV_32F, (void*)get_data(_retinaFilter->getContours()));
616613
}
617614

618-
// private method called by constructirs
615+
// private method called by constructors
619616
void RetinaImpl::_init(const cv::Size inputSz, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const float reductionFactor, const float samplingStrenght)
620617
{
621618
// basic error check
@@ -637,9 +634,6 @@ void RetinaImpl::_init(const cv::Size inputSz, const bool colorMode, int colorSa
637634

638635
// init retina
639636
_retinaFilter->clearAllBuffers();
640-
641-
// report current configuration
642-
printf("%s\n", printSetup().c_str());
643637
}
644638

645639
void RetinaImpl::_convertValarrayBuffer2cvMat(const std::valarray<float> &grayMatrixToConvert, const unsigned int nbRows, const unsigned int nbColumns, const bool colorMode, OutputArray outBuffer)

modules/bioinspired/src/transientareassegmentationmodule.cpp

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ namespace cv
8686
namespace bioinspired
8787
{
8888

89-
class TransientAreasSegmentationModuleImpl :
90-
protected BasicRetinaFilter
89+
class TransientAreasSegmentationModuleImpl : protected BasicRetinaFilter
9190
{
9291
public:
9392

@@ -105,7 +104,7 @@ class TransientAreasSegmentationModuleImpl :
105104
/**
106105
* @return the size of the manage input and output images
107106
*/
108-
Size getSize(){return cv::Size(getNBcolumns(), getNBrows());};
107+
Size getSize(){return cv::Size(getNBcolumns(), getNBrows());}
109108

110109
/**
111110
* try to open an XML segmentation parameters file to adjust current segmentation instance setup
@@ -189,19 +188,19 @@ class TransientAreasSegmentationModuleImpl :
189188
* access function
190189
* @return the local motion energy level picture (experimental, not usefull)
191190
*/
192-
inline const std::valarray<float> &getLocalMotionPicture() const {return _localMotion;};
191+
inline const std::valarray<float> &getLocalMotionPicture() const {return _localMotion;}
193192

194193
/**
195194
* access function
196195
* @return the neighborhood motion energy level picture (experimental, not usefull)
197196
*/
198-
inline const std::valarray<float> &getNeighborhoodMotionPicture() const {return _neighborhoodMotion;};
197+
inline const std::valarray<float> &getNeighborhoodMotionPicture() const {return _neighborhoodMotion;}
199198

200199
/**
201200
* access function
202201
* @return the motion energy context level picture (experimental, not usefull)
203202
*/
204-
inline const std::valarray<float> &getMotionContextPicture() const {return _contextMotionEnergy;};
203+
inline const std::valarray<float> &getMotionContextPicture() const {return _contextMotionEnergy;}
205204

206205
struct cv::bioinspired::SegmentationParameters _segmentationParameters;
207206
// template buffers and related acess pointers
@@ -220,25 +219,25 @@ class TransientAreasSegmentationModuleImpl :
220219
// Buffer conversion utilities
221220
void _convertValarrayBuffer2cvMat(const std::valarray<bool> &grayMatrixToConvert, const unsigned int nbRows, const unsigned int nbColumns, OutputArray outBuffer);
222221
bool _convertCvMat2ValarrayBuffer(InputArray inputMat, std::valarray<float> &outputValarrayMatrix);
223-
222+
224223
const TransientAreasSegmentationModuleImpl & operator = (const TransientAreasSegmentationModuleImpl &);
225224
};
226225

227226
class TransientAreasSegmentationModuleImpl_: public TransientAreasSegmentationModule
228227
{
229228
public:
230-
TransientAreasSegmentationModuleImpl_(const Size size):_segmTool(size){};
231-
inline virtual Size getSize(){return _segmTool.getSize();};
232-
inline virtual void write( cv::FileStorage& fs ) const{_segmTool.write(fs);};
233-
inline virtual void setup(String segmentationParameterFile, const bool applyDefaultSetupOnFailure){_segmTool.setup(segmentationParameterFile, applyDefaultSetupOnFailure);};
234-
inline virtual void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure){_segmTool.setup(fs, applyDefaultSetupOnFailure);};
235-
inline virtual void setup(SegmentationParameters newParameters){_segmTool.setup(newParameters);};
236-
inline virtual const String printSetup(){return _segmTool.printSetup();};
237-
inline virtual struct SegmentationParameters getParameters(){return _segmTool.getParameters();};
238-
inline virtual void write( String fs ) const{_segmTool.write(fs);};
239-
inline virtual void run(InputArray inputToSegment, const int channelIndex){_segmTool.run(inputToSegment, channelIndex);};
240-
inline virtual void getSegmentationPicture(OutputArray transientAreas){return _segmTool.getSegmentationPicture(transientAreas);};
241-
inline virtual void clearAllBuffers(){_segmTool.clearAllBuffers();};
229+
TransientAreasSegmentationModuleImpl_(const Size size):_segmTool(size){}
230+
inline virtual Size getSize(){return _segmTool.getSize();}
231+
inline virtual void write( cv::FileStorage& fs ) const{_segmTool.write(fs);}
232+
inline virtual void setup(String segmentationParameterFile, const bool applyDefaultSetupOnFailure){_segmTool.setup(segmentationParameterFile, applyDefaultSetupOnFailure);}
233+
inline virtual void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure){_segmTool.setup(fs, applyDefaultSetupOnFailure);}
234+
inline virtual void setup(SegmentationParameters newParameters){_segmTool.setup(newParameters);}
235+
inline virtual const String printSetup(){return _segmTool.printSetup();}
236+
inline virtual struct SegmentationParameters getParameters(){return _segmTool.getParameters();}
237+
inline virtual void write( String fs ) const{_segmTool.write(fs);}
238+
inline virtual void run(InputArray inputToSegment, const int channelIndex){_segmTool.run(inputToSegment, channelIndex);}
239+
inline virtual void getSegmentationPicture(OutputArray transientAreas){return _segmTool.getSegmentationPicture(transientAreas);}
240+
inline virtual void clearAllBuffers(){_segmTool.clearAllBuffers();}
242241

243242
private:
244243
TransientAreasSegmentationModuleImpl _segmTool;
@@ -250,7 +249,7 @@ class TransientAreasSegmentationModuleImpl_: public TransientAreasSegmentationM
250249
*/
251250
Ptr<TransientAreasSegmentationModule> createTransientAreasSegmentationModule(Size inputSize){
252251
return makePtr<TransientAreasSegmentationModuleImpl_>(inputSize);
253-
};
252+
}
254253

255254
// Constructor and destructors
256255
TransientAreasSegmentationModuleImpl::TransientAreasSegmentationModuleImpl(const Size size)
@@ -288,8 +287,8 @@ void TransientAreasSegmentationModuleImpl::clearAllBuffers()
288287

289288
struct SegmentationParameters TransientAreasSegmentationModuleImpl::getParameters()
290289
{
291-
return _segmentationParameters;
292-
};
290+
return _segmentationParameters;
291+
}
293292

294293
// setup from XML file
295294
void TransientAreasSegmentationModuleImpl::setup(String segmentationParameterFile, const bool applyDefaultSetupOnFailure)
@@ -350,9 +349,6 @@ void TransientAreasSegmentationModuleImpl::setup(cv::FileStorage &fs, const bool
350349
std::cout<<"SegmentationModule::setup: wrong/unappropriate xml parameter file : error report :`n=>"<<e.what()<<std::endl;
351350
std::cout<<"=> keeping current parameters"<<std::endl;
352351
}
353-
354-
// report current configuration
355-
printf("%s\n", printSetup().c_str());
356352
}
357353

358354
// setup parameters for the 2 filters that allow the segmentation
@@ -592,9 +588,3 @@ bool TransientAreasSegmentationModuleImpl::_convertCvMat2ValarrayBuffer(InputArr
592588
}
593589

594590
}} //namespaces end : cv and bioinspired
595-
596-
597-
598-
599-
600-

0 commit comments

Comments
 (0)