/* * Deception * * Author: Andrew Salamon * Date: Thu June 18, 2010 * * Copyright (c) 2010 Machine Perception Technologies * * 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 __MPT_DECEPTION__ #define __MPT_DECEPTION__ #include #include #include #include "svm_rbf.h" #include "linear_svm.h" #ifdef XCODE #include #else #include "rimage.h" #endif namespace mpt { typedef std::vector vectorD1D; typedef std::vector< vectorD1D > vectorD2D; typedef std::vector< vectorD2D > vectorD3D; template void printVec( const std::vector &vec, std::ostream &os = std::cout ) { for( unsigned int i = 0; i < vec.size(); ++i ) { os << vec[i] << ' '; } os << std::endl; } /** Deception * Setup, run one set of au values (interpolate method), repeat, return results. */ class Deception { public: Deception( const std::string &w2_path, const std::string &path2 ); virtual ~Deception(); void start(); void interpolate( const vectorD1D &aus, bool faceFound ); double currentValue(); // the rest of this should be private but isn't so I can test it void accumulate( const vectorD1D &aus ); vectorD3D ai_jw(); vectorD2D integratedGaborFilters( const vectorD2D &aus, const vectorD1D &s1, const std::vector &T ); vectorD1D makeCosineFilters( double F0, double a, std::vector &T ); vectorD1D newhist( const vectorD3D &AI, double d, int b ); vectorD1D smoothHistograms( const vectorD3D &ai, int BB, double d0, double dx, double w ); vectorD1D loadHistogram( const std::string &path ); double decision( std::vector histogram ); ///< Gets passed through to the svm, but useful for testing. private: unsigned int count; bool interpolating; unsigned int lastCount; vectorD1D lastFrame; vectorD1D getAUvector( const vectorD2D &aus, unsigned int index ); void IntegratedGaborFilters( double F0, double a ); int sign( double val ); #ifdef DEBUG void debugWriteAUSeries( const std::string &file ); void debugWriteGabors( const std::string &file, const vectorD3D &AI ); void debugWriteHistogram( const std::string &file, const vectorD1D &histograms, double val ); #endif private: vectorD2D auSeries; // collected time series of AU values linear_svm svm; int firstFrame; }; // end Deception } // end namespace mpt #endif