Remove all using directives for STL namespace and members
authorAndrey Kamaev <andrey.kamaev@itseez.com>
Sun, 24 Feb 2013 16:14:01 +0000 (20:14 +0400)
committerLeszek Swirski <leszek@swirski.co.uk>
Wed, 27 Nov 2013 14:46:47 +0000 (14:46 +0000)
Made all STL usages explicit to be able automatically find all usages of
particular class or function.

(cherry picked from commit 2a6fb2867e2fc639e0675eed8abb1688de4539ec)
(only cherry picked "apps/trancascade")

14 files changed:
apps/traincascade/HOGfeatures.cpp
apps/traincascade/HOGfeatures.h
apps/traincascade/boost.cpp
apps/traincascade/boost.h
apps/traincascade/cascadeclassifier.cpp
apps/traincascade/cascadeclassifier.h
apps/traincascade/features.cpp
apps/traincascade/haarfeatures.cpp
apps/traincascade/haarfeatures.h
apps/traincascade/imagestorage.cpp
apps/traincascade/imagestorage.h
apps/traincascade/lbpfeatures.h
apps/traincascade/traincascade.cpp
apps/traincascade/traincascade_features.h

index 9a562fc..8bbdee6 100644 (file)
@@ -4,6 +4,7 @@
 #include "HOGfeatures.h"
 #include "cascadeclassifier.h"
 
+using namespace std;
 
 CvHOGFeatureParams::CvHOGFeatureParams()
 {
index a7f33f6..329c607 100644 (file)
@@ -26,13 +26,13 @@ public:
     virtual void writeFeatures( FileStorage &fs, const Mat& featureMap ) const;
 protected:
     virtual void generateFeatures();
-    virtual void integralHistogram(const Mat &img, vector<Mat> &histogram, Mat &norm, int nbins) const;
+    virtual void integralHistogram(const Mat &img, std::vector<Mat> &histogram, Mat &norm, int nbins) const;
     class Feature
     {
     public:
         Feature();
         Feature( int offset, int x, int y, int cellW, int cellH );
-        float calc( const vector<Mat> &_hists, const Mat &_normSum, size_t y, int featComponent ) const;
+        float calc( const std::vector<Mat> &_hists, const Mat &_normSum, size_t y, int featComponent ) const;
         void write( FileStorage &fs ) const;
         void write( FileStorage &fs, int varIdx ) const;
 
@@ -43,10 +43,10 @@ protected:
             int p0, p1, p2, p3;
         } fastRect[N_CELLS];
     };
-    vector<Feature> features;
+    std::vector<Feature> features;
 
     Mat normSum; //for nomalization calculation (L1 or L2)
-    vector<Mat> hist;
+    std::vector<Mat> hist;
 };
 
 inline float CvHOGEvaluator::operator()(int varIdx, int sampleIdx) const
@@ -57,7 +57,7 @@ inline float CvHOGEvaluator::operator()(int varIdx, int sampleIdx) const
     return features[featureIdx].calc( hist, normSum, sampleIdx, componentIdx);
 }
 
-inline float CvHOGEvaluator::Feature::calc( const vector<Mat>& _hists, const Mat& _normSum, size_t y, int featComponent ) const
+inline float CvHOGEvaluator::Feature::calc( const std::vector<Mat>& _hists, const Mat& _normSum, size_t y, int featComponent ) const
 {
     float normFactor;
     float res;
index 4f91d5a..6d11655 100644 (file)
@@ -160,10 +160,10 @@ CvCascadeBoostParams::CvCascadeBoostParams( int _boostType,
 
 void CvCascadeBoostParams::write( FileStorage &fs ) const
 {
-    String boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST :
+    string boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST :
                           boost_type == CvBoost::REAL ? CC_REAL_BOOST :
                           boost_type == CvBoost::LOGIT ? CC_LOGIT_BOOST :
-                          boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : String();
+                          boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : string();
     CV_Assert( !boostTypeStr.empty() );
     fs << CC_BOOST_TYPE << boostTypeStr;
     fs << CC_MINHITRATE << minHitRate;
@@ -175,7 +175,7 @@ void CvCascadeBoostParams::write( FileStorage &fs ) const
 
 bool CvCascadeBoostParams::read( const FileNode &node )
 {
-    String boostTypeStr;
+    string boostTypeStr;
     FileNode rnode = node[CC_BOOST_TYPE];
     rnode >> boostTypeStr;
     boost_type = !boostTypeStr.compare( CC_DISCRETE_BOOST ) ? CvBoost::DISCRETE :
@@ -213,10 +213,10 @@ void CvCascadeBoostParams::printDefaults() const
 
 void CvCascadeBoostParams::printAttrs() const
 {
-    String boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST :
+    string boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST :
                           boost_type == CvBoost::REAL ? CC_REAL_BOOST :
                           boost_type == CvBoost::LOGIT  ? CC_LOGIT_BOOST :
-                          boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : String();
+                          boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : string();
     CV_Assert( !boostTypeStr.empty() );
     cout << "boostType: " << boostTypeStr << endl;
     cout << "minHitRate: " << minHitRate << endl;
@@ -226,7 +226,7 @@ void CvCascadeBoostParams::printAttrs() const
     cout << "maxWeakCount: " << weak_count << endl;
 }
 
-bool CvCascadeBoostParams::scanAttr( const String prmName, const String val)
+bool CvCascadeBoostParams::scanAttr( const string prmName, const string val)
 {
     bool res = true;
 
index 16f7c2c..2a08048 100644 (file)
@@ -17,7 +17,7 @@ struct CvCascadeBoostParams : CvBoostParams
     bool read( const FileNode &node );
     virtual void printDefaults() const;
     virtual void printAttrs() const;
-    virtual bool scanAttr( const String prmName, const String val);
+    virtual bool scanAttr( const std::string prmName, const std::string val);
 };
 
 struct CvCascadeBoostTrainData : CvDTreeTrainData
index 00674ff..66f6876 100644 (file)
@@ -24,10 +24,10 @@ CvCascadeParams::CvCascadeParams( int _stageType, int _featureType ) : stageType
 
 void CvCascadeParams::write( FileStorage &fs ) const
 {
-    String stageTypeStr = stageType == BOOST ? CC_BOOST : String();
+    string stageTypeStr = stageType == BOOST ? CC_BOOST : string();
     CV_Assert( !stageTypeStr.empty() );
     fs << CC_STAGE_TYPE << stageTypeStr;
-    String featureTypeStr = featureType == CvFeatureParams::HAAR ? CC_HAAR :
+    string featureTypeStr = featureType == CvFeatureParams::HAAR ? CC_HAAR :
                             featureType == CvFeatureParams::LBP ? CC_LBP :
                             featureType == CvFeatureParams::HOG ? CC_HOG :
                             0;
@@ -41,7 +41,7 @@ bool CvCascadeParams::read( const FileNode &node )
 {
     if ( node.empty() )
         return false;
-    String stageTypeStr, featureTypeStr;
+    string stageTypeStr, featureTypeStr;
     FileNode rnode = node[CC_STAGE_TYPE];
     if ( !rnode.isString() )
         return false;
@@ -96,7 +96,7 @@ void CvCascadeParams::printAttrs() const
     cout << "sampleHeight: " << winSize.height << endl;
 }
 
-bool CvCascadeParams::scanAttr( const String prmName, const String val )
+bool CvCascadeParams::scanAttr( const string prmName, const string val )
 {
     bool res = true;
     if( !prmName.compare( "-stageType" ) )
@@ -126,9 +126,9 @@ bool CvCascadeParams::scanAttr( const String prmName, const String val )
 
 //---------------------------- CascadeClassifier --------------------------------------
 
-bool CvCascadeClassifier::train( const String _cascadeDirName,
-                                const String _posFilename,
-                                const String _negFilename,
+bool CvCascadeClassifier::train( const string _cascadeDirName,
+                                const string _posFilename,
+                                const string _negFilename,
                                 int _numPos, int _numNeg,
                                 int _precalcValBufSize, int _precalcIdxBufSize,
                                 int _numStages,
@@ -399,7 +399,7 @@ bool CvCascadeClassifier::readStages( const FileNode &node)
 #define ICV_HAAR_PARENT_NAME            "parent"
 #define ICV_HAAR_NEXT_NAME              "next"
 
-void CvCascadeClassifier::save( const String filename, bool baseFormat )
+void CvCascadeClassifier::save( const string filename, bool baseFormat )
 {
     FileStorage fs( filename, FileStorage::WRITE );
 
@@ -491,7 +491,7 @@ void CvCascadeClassifier::save( const String filename, bool baseFormat )
     fs << "}";
 }
 
-bool CvCascadeClassifier::load( const String cascadeDirName )
+bool CvCascadeClassifier::load( const string cascadeDirName )
 {
     FileStorage fs( cascadeDirName + CC_PARAMS_FILENAME, FileStorage::READ );
     if ( !fs.isOpened() )
index 6890068..3eb50b5 100644 (file)
@@ -77,7 +77,7 @@ public:
 
     void printDefaults() const;
     void printAttrs() const;
-    bool scanAttr( const String prmName, const String val );
+    bool scanAttr( const std::string prmName, const std::string val );
 
     int stageType;
     int featureType;
@@ -87,9 +87,9 @@ public:
 class CvCascadeClassifier
 {
 public:
-    bool train( const String _cascadeDirName,
-                const String _posFilename,
-                const String _negFilename,
+    bool train( const std::string _cascadeDirName,
+                const std::string _posFilename,
+                const std::string _negFilename,
                 int _numPos, int _numNeg,
                 int _precalcValBufSize, int _precalcIdxBufSize,
                 int _numStages,
@@ -99,8 +99,8 @@ public:
                 bool baseFormatSave = false );
 private:
     int predict( int sampleIdx );
-    void save( const String cascadeDirName, bool baseFormat = false );
-    bool load( const String cascadeDirName );
+    void save( const std::string cascadeDirName, bool baseFormat = false );
+    bool load( const std::string cascadeDirName );
     bool updateTrainingSet( double& acceptanceRatio );
     int fillPassedSamples( int first, int count, bool isPositive, int64& consumed );
 
@@ -117,7 +117,7 @@ private:
     Ptr<CvCascadeBoostParams> stageParams;
 
     Ptr<CvFeatureEvaluator> featureEvaluator;
-    vector< Ptr<CvCascadeBoost> > stageClassifiers;
+    std::vector< Ptr<CvCascadeBoost> > stageClassifiers;
     CvCascadeImageReader imgReader;
     int numStages, curNumSamples;
     int numPos, numNeg;
index effa4dc..9629509 100644 (file)
@@ -24,7 +24,7 @@ CvParams::CvParams() : name( "params" ) {}
 void CvParams::printDefaults() const
 { cout << "--" << name << "--" << endl; }
 void CvParams::printAttrs() const {}
-bool CvParams::scanAttr( const String, const String ) { return false; }
+bool CvParams::scanAttr( const string, const string ) { return false; }
 
 
 //---------------------------- FeatureParams --------------------------------------
index 0298b42..9f8bce0 100644 (file)
@@ -25,9 +25,9 @@ void CvHaarFeatureParams::init( const CvFeatureParams& fp )
 void CvHaarFeatureParams::write( FileStorage &fs ) const
 {
     CvFeatureParams::write( fs );
-    String modeStr = mode == BASIC ? CC_MODE_BASIC :
+    string modeStr = mode == BASIC ? CC_MODE_BASIC :
                      mode == CORE ? CC_MODE_CORE :
-                     mode == ALL ? CC_MODE_ALL : String();
+                     mode == ALL ? CC_MODE_ALL : string();
     CV_Assert( !modeStr.empty() );
     fs << CC_MODE << modeStr;
 }
@@ -40,7 +40,7 @@ bool CvHaarFeatureParams::read( const FileNode &node )
     FileNode rnode = node[CC_MODE];
     if( !rnode.isString() )
         return false;
-    String modeStr;
+    string modeStr;
     rnode >> modeStr;
     mode = !modeStr.compare( CC_MODE_BASIC ) ? BASIC :
            !modeStr.compare( CC_MODE_CORE ) ? CORE :
@@ -58,13 +58,13 @@ void CvHaarFeatureParams::printDefaults() const
 void CvHaarFeatureParams::printAttrs() const
 {
     CvFeatureParams::printAttrs();
-    String mode_str = mode == BASIC ? CC_MODE_BASIC :
+    string mode_str = mode == BASIC ? CC_MODE_BASIC :
                        mode == CORE ? CC_MODE_CORE :
                        mode == ALL ? CC_MODE_ALL : 0;
     cout << "mode: " <<  mode_str << endl;
 }
 
-bool CvHaarFeatureParams::scanAttr( const String prmName, const String val)
+bool CvHaarFeatureParams::scanAttr( const string prmName, const string val)
 {
     if ( !CvFeatureParams::scanAttr( prmName, val ) )
     {
index 6473902..472822b 100644 (file)
@@ -23,7 +23,7 @@ public:
 
     virtual void printDefaults() const;
     virtual void printAttrs() const;
-    virtual bool scanAttr( const String prm, const String val);
+    virtual bool scanAttr( const std::string prm, const std::string val);
 
     int mode;
 };
@@ -64,7 +64,7 @@ protected:
         } fastRect[CV_HAAR_FEATURE_MAX];
     };
 
-    vector<Feature> features;
+    std::vector<Feature> features;
     Mat  sum;         /* sum images (each row represents image) */
     Mat  tilted;      /* tilted sum images (each row represents image) */
     Mat  normfactor;  /* normalization factor */
index 0f749f9..9faf84a 100644 (file)
@@ -7,7 +7,9 @@
 #include <iostream>
 #include <fstream>
 
-bool CvCascadeImageReader::create( const String _posFilename, const String _negFilename, Size _winSize )
+using namespace std;
+
+bool CvCascadeImageReader::create( const string _posFilename, const string _negFilename, Size _winSize )
 {
     return posReader.create(_posFilename) && negReader.create(_negFilename, _winSize);
 }
@@ -22,21 +24,21 @@ CvCascadeImageReader::NegReader::NegReader()
     stepFactor  = 0.5F;
 }
 
-bool CvCascadeImageReader::NegReader::create( const String _filename, Size _winSize )
+bool CvCascadeImageReader::NegReader::create( const string _filename, Size _winSize )
 {
-    String dirname, str;
+    string dirname, str;
     std::ifstream file(_filename.c_str());
     if ( !file.is_open() )
         return false;
 
     size_t pos = _filename.rfind('\\');
     char dlmrt = '\\';
-    if (pos == String::npos)
+    if (pos == string::npos)
     {
         pos = _filename.rfind('/');
         dlmrt = '/';
     }
-    dirname = pos == String::npos ? "" : _filename.substr(0, pos) + dlmrt;
+    dirname = pos == string::npos ? "" : _filename.substr(0, pos) + dlmrt;
     while( !file.eof() )
     {
         std::getline(file, str);
@@ -64,8 +66,8 @@ bool CvCascadeImageReader::NegReader::nextImg()
         round = round % (winSize.width * winSize.height);
         last %= count;
 
-        _offset.x = min( (int)round % winSize.width, src.cols - winSize.width );
-        _offset.y = min( (int)round / winSize.width, src.rows - winSize.height );
+        _offset.x = std::min( (int)round % winSize.width, src.cols - winSize.width );
+        _offset.y = std::min( (int)round / winSize.width, src.rows - winSize.height );
         if( !src.empty() && src.type() == CV_8UC1
                 && offset.x >= 0 && offset.y >= 0 )
             break;
@@ -126,7 +128,7 @@ CvCascadeImageReader::PosReader::PosReader()
     vec = 0;
 }
 
-bool CvCascadeImageReader::PosReader::create( const String _filename )
+bool CvCascadeImageReader::PosReader::create( const string _filename )
 {
     if ( file )
         fclose( file );
index 91a4e5e..dd08e66 100644 (file)
@@ -8,7 +8,7 @@ using namespace cv;
 class CvCascadeImageReader
 {
 public:
-    bool create( const String _posFilename, const String _negFilename, Size _winSize );
+    bool create( const std::string _posFilename, const std::string _negFilename, Size _winSize );
     void restart() { posReader.restart(); }
     bool getNeg(Mat &_img) { return negReader.get( _img ); }
     bool getPos(Mat &_img) { return posReader.get( _img ); }
@@ -19,7 +19,7 @@ private:
     public:
         PosReader();
         virtual ~PosReader();
-        bool create( const String _filename );
+        bool create( const std::string _filename );
         bool get( Mat &_img );
         void restart();
 
@@ -35,12 +35,12 @@ private:
     {
     public:
         NegReader();
-        bool create( const String _filename, Size _winSize );
+        bool create( const std::string _filename, Size _winSize );
         bool get( Mat& _img );
         bool nextImg();
 
         Mat     src, img;
-        vector<String> imgFilenames;
+        std::vector<std::string> imgFilenames;
         Point   offset, point;
         float   scale;
         float   scaleFactor;
index 30c3537..d4397c4 100644 (file)
@@ -34,7 +34,7 @@ protected:
         Rect rect;
         int p[16];
     };
-    vector<Feature> features;
+    std::vector<Feature> features;
 
     Mat sum;
 };
index 5a969f4..dfb49b5 100644 (file)
@@ -9,7 +9,7 @@ using namespace std;
 int main( int argc, char* argv[] )
 {
     CvCascadeClassifier classifier;
-    String cascadeDirName, vecName, bgName;
+    string cascadeDirName, vecName, bgName;
     int numPos    = 2000;
     int numNeg    = 1000;
     int numStages = 20;
index 019a4b9..dde0f1a 100644 (file)
@@ -33,7 +33,7 @@
 float calcNormFactor( const Mat& sum, const Mat& sqSum );
 
 template<class Feature>
-void _writeFeatures( const vector<Feature> features, FileStorage &fs, const Mat& featureMap )
+void _writeFeatures( const std::vector<Feature> features, FileStorage &fs, const Mat& featureMap )
 {
     fs << FEATURES << "[";
     const Mat_<int>& featureMap_ = (const Mat_<int>&)featureMap;
@@ -58,8 +58,8 @@ public:
     // from|to screen
     virtual void printDefaults() const;
     virtual void printAttrs() const;
-    virtual bool scanAttr( const String prmName, const String val );
-    String name;
+    virtual bool scanAttr( const std::string prmName, const std::string val );
+    std::string name;
 };
 
 class CvFeatureParams : public CvParams