/* * Arguments.cpp * * Copyright (c) 2008 Machine Perception Laboratory * University of California San Diego. * * Authors: Andrew Salamon * * Please read the disclaimer and notes about redistribution * at the end of this file. * */ #include #include #include #include #include "CERT_filetypes.h" namespace CERT { class Arguments { public: static bool processArgs( int argc, char *argv[], const std::string &defaultConfigPath = std::string("./CERT.cfg") ); static void usage( char *name ); static bool ready(); ///< True if arguments have been successfully processed. static void cleanup(); ///< Should be called just before exiting the program. static bool inputIsFaces(); ///< If this is true, faces in input images have have already been found and cropped. static bool sequential(); ///< Set to true if the images are part of a sequence, e.g. video. static bool outputPatches(); ///< If this is set to true, write face patches out to files in patchDir. static std::string patchDir(); static int maxTries(); static bool tabDelim(); static bool outputToFile(); static std::string outputPath(); static std::ostream &outputStream(); ///< If outputToFile is true, then stream will be to a file at outputPath, otherwise it will be cout. static std::string configPath(); static const std::vector< std::string > &paths(); static Images::filetype patchFiletype(); static bool GKRTraining(); ///< True if the GKR plugin should train a model (requires a model path) static std::string GKRModelPath(); ///< Path to read or write a GKR model. static int numberOfThreads(); ///< The number of threads of CERT processing we should run. Zero means to use our best guess. private: static Arguments &getArgs(); private: Arguments(); ~Arguments(); bool _processArgs( int argc, char *argv[], const std::string &defaultConfigPath ); bool getFileArgument( int argc, char *argv[], int &argIndex, std::string &filename, bool writeFlag, const std::string option, const std::string fileTitle, std::string &errorMsg ); void _cleanup(); private: bool _ready; bool _inputIsFaces; bool _sequential; bool _outputPatches; std::string _patchDir; int _maxTries; bool _tabDelim; bool _outputToFile; std::string _outputPath; std::ofstream _outputStream; std::string _configPath; std::string _defaultConfigPath; std::vector< std::string > _paths; Images::filetype _patchFiletype; bool _GKRTraining; std::string _GKRModelPath; int _threads; }; } /* * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */