#include <queue>
using namespace std;
+ using namespace cv;
static const char* stageTypes[] = { CC_BOOST };
static const char* featureTypes[] = { CC_HAAR, CC_LBP, CC_HOG };
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;
{
if ( node.empty() )
return false;
- String stageTypeStr, featureTypeStr;
+ string stageTypeStr, featureTypeStr;
FileNode rnode = node[CC_STAGE_TYPE];
if ( !rnode.isString() )
return false;
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" ) )
//---------------------------- 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,
const CvCascadeBoostParams& _stageParams,
bool baseFormatSave )
{
+ // Start recording clock ticks for training time output
+ const clock_t begin_time = clock();
+
if( _cascadeDirName.empty() || _posFilename.empty() || _negFilename.empty() )
CV_Error( CV_StsBadArg, "_cascadeDirName or _bgfileName or _vecFileName is NULL" );
fs << FileStorage::getDefaultObjectName(stageFilename) << "{";
tempStage->write( fs, Mat() );
fs << "}";
+
+ // Output training time up till now
+ float seconds = float( clock () - begin_time ) / CLOCKS_PER_SEC;
+ int days = int(seconds) / 60 / 60 / 24;
+ int hours = (int(seconds) / 60 / 60) % 24;
+ int minutes = (int(seconds) / 60) % 60;
+ int seconds_left = int(seconds) % 60;
+ cout << "Training until now has taken " << days << " days " << hours << " hours " << minutes << " minutes " << seconds_left <<" seconds." << endl;
}
if(stageClassifiers.size() == 0)
if( predict( i ) == 1.0F )
{
getcount++;
+ printf("%s current samples: %d\r", isPositive ? "POS":"NEG", getcount);
break;
}
}
#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 );
fs << "}";
}
- bool CvCascadeClassifier::load( const String cascadeDirName )
+ bool CvCascadeClassifier::load( const string cascadeDirName )
{
FileStorage fs( cascadeDirName + CC_PARAMS_FILENAME, FileStorage::READ );
if ( !fs.isOpened() )