/* * Gaussian Kernel Regression model container class * * Author: Andrew Salamon * * Copyright (c) 2008 Machine Perception Laboratory * University of California San Diego. * * 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. * */ #ifndef __GKR_MODELS_H__ #define __GKR_MODELS_H__ #include #include #include #include #ifdef XCODE #include #include #else #include "simplematrix.hpp" #include "simplematrix_ser.hpp" #endif #include #include //#include //#include //#include //#include //#include //#include //#include //#include #include #include "GKR_Model.h" #include "GKR_Trainer.h" namespace GKR { /** Gaussian Kernel Regression model container class. * This class contains a set of models, one for each AU being processed. * It's intended to be the public interface to all three GKR post processing steps. */ class Models { public: typedef std::map< std::string, std::vector > CKFmap; ///< Keys are AU labels, there must be six floats for each: alpha, beta, S_x, S_y, S_0, Y_0 public: Models(); ~Models(); void setLabels( const std::vector &_labels ); void setFlags( bool _train, bool _GKR, bool _log, bool _temp ); void setTraining( bool _training ); bool getTraining(); void setGKR( bool _GKR ); bool getGKR(); void setLogistic( bool _logistic ); bool getLogistic(); void setTemporal( bool _temporal ); bool getTemporal(); void loadModels( const std::string &path ); void saveModels( const std::string &path ); bool setCKFValues( CKFmap &values ); bool loadCKFValues( const std::string &path ); ///< Load CKF values from a boost serialized file. /// Can throw badPose or badAUData exceptions. std::vector addFrame( const std::vector &pose, const std::vector &aus, bool didFindFace ); void train(); ///< Train all models based on data added from all addFrame calls. void clearTraining(); private: bool training; bool GKR; bool logistic; bool temporal; std::vector labels; std::map< std::string, Model > models; Trainer trainer; }; /** Exception class used by GKR::Models. */ class badPose : std::invalid_argument { public: badPose() : invalid_argument( "Wrong number of pose data values in GKR Models." ) { } }; /** Exception class used by GKR::Models. */ class badAUData : std::invalid_argument { public: badAUData() : invalid_argument( "Wrong number of AU data values in GKR Models." ) { } }; } // end namespace GKR #endif