diff --git a/apps/haartraining/createsamples.cpp b/apps/haartraining/createsamples.cpp index dd15a5ffd1..a1a11e0b53 100644 --- a/apps/haartraining/createsamples.cpp +++ b/apps/haartraining/createsamples.cpp @@ -50,6 +50,7 @@ #include #include #include +#include using namespace std; @@ -218,28 +219,22 @@ int main( int argc, char* argv[] ) printf( "Done\n" ); } - else if( imagename && bgfilename && infoname && pngoutput) + else if( imagename && bgfilename && infoname) { - printf( "Create training set from a single image and a collection of backgrounds.\n" - "Output format: %s\n" - "Annotations are in a separate directory\n", - (( pngoutput ) ? "JPG" : "PNG") ); - - PngDatasetGenerator creator( infoname ); - creator.create( imagename, bgcolor, bgthreshold, bgfilename, num, - invert, maxintensitydev, maxxangle, maxyangle, maxzangle, - showsamples, width, height ); - - printf( "Done\n" ); - } - else if( imagename && bgfilename && infoname ) - { - printf( "Create test samples from single image applying distortions...\n" + printf( "Create data set from single image applying distortions...\n" "Output format: %s\n", - (( pngoutput ) ? "JPG" : "PNG") ); + (( pngoutput ) ? "PNG" : "JPG") ); - JpgDatasetGrenerator creator( infoname ); - creator.create( imagename, bgcolor, bgthreshold, bgfilename, num, + std::auto_ptr creator; + if( pngoutput ) + { + creator = std::auto_ptr( new PngDatasetGenerator( infoname ) ); + } + else + { + creator = std::auto_ptr( new JpgDatasetGenerator( infoname ) ); + } + creator->create( imagename, bgcolor, bgthreshold, bgfilename, num, invert, maxintensitydev, maxxangle, maxyangle, maxzangle, showsamples, width, height ); diff --git a/apps/haartraining/cvhaartraining.cpp b/apps/haartraining/cvhaartraining.cpp index 27483e6cd4..31abfff6da 100644 --- a/apps/haartraining/cvhaartraining.cpp +++ b/apps/haartraining/cvhaartraining.cpp @@ -3029,12 +3029,12 @@ DatasetGenerator::~DatasetGenerator() } -JpgDatasetGrenerator::JpgDatasetGrenerator(const char* filename) - :DatasetGenerator(IOutput::createOutput(filename,IOutput::JPG_TEST_SET)) +JpgDatasetGenerator::JpgDatasetGenerator( const char* filename ) + :DatasetGenerator( IOutput::createOutput( filename, IOutput::JPG_DATASET ) ) { } -CvSize JpgDatasetGrenerator::scaleObjectSize(const CvSize& bgImgSize, +CvSize JpgDatasetGenerator::scaleObjectSize( const CvSize& bgImgSize, const CvSize& , const CvSize& sampleSize) const { @@ -3074,13 +3074,13 @@ CvRect DatasetGenerator::getObjectPosition(const CvSize& bgImgSize, PngDatasetGenerator::PngDatasetGenerator(const char* filename) - :DatasetGenerator(IOutput::createOutput(filename,IOutput::PNG_TRAINING_SET)) + :DatasetGenerator( IOutput::createOutput( filename, IOutput::PNG_DATASET ) ) { } CvSize PngDatasetGenerator::scaleObjectSize( const CvSize& bgImgSize, - const CvSize& imgSize, - const CvSize& ) const + const CvSize& imgSize, + const CvSize& ) const { float scale; diff --git a/apps/haartraining/cvhaartraining.h b/apps/haartraining/cvhaartraining.h index 77e4923353..84a5643e7b 100644 --- a/apps/haartraining/cvhaartraining.h +++ b/apps/haartraining/cvhaartraining.h @@ -227,10 +227,10 @@ private: }; /* Provides the functionality of test set generating */ -class JpgDatasetGrenerator: public DatasetGenerator +class JpgDatasetGenerator: public DatasetGenerator { public: - JpgDatasetGrenerator(const char* filename); + JpgDatasetGenerator(const char* filename); private: CvSize scaleObjectSize(const CvSize& bgImgSize, const CvSize& , diff --git a/apps/haartraining/cvsamplesoutput.cpp b/apps/haartraining/cvsamplesoutput.cpp index 83eae58d6b..a2b7e263c7 100644 --- a/apps/haartraining/cvsamplesoutput.cpp +++ b/apps/haartraining/cvsamplesoutput.cpp @@ -34,10 +34,10 @@ IOutput* IOutput::createOutput(const char *filename, { IOutput* output = 0; switch (type) { - case IOutput::PNG_TRAINING_SET: + case IOutput::PNG_DATASET: output = new PngDatasetOutput(); break; - case IOutput::JPG_TEST_SET: + case IOutput::JPG_DATASET: output = new JpgDatasetOutput(); break; default: diff --git a/apps/haartraining/ioutput.h b/apps/haartraining/ioutput.h index eccebc1165..aef35ba900 100644 --- a/apps/haartraining/ioutput.h +++ b/apps/haartraining/ioutput.h @@ -11,7 +11,7 @@ struct CvRect; class IOutput { public: - enum OutputType {PNG_TRAINING_SET, JPG_TEST_SET}; + enum OutputType {PNG_DATASET, JPG_DATASET}; public: virtual bool write( const CvMat& img, const CvRect& boundingBox ) =0;