/* * mp_CERT_Public * * Author: Andrew Salamon * Date: Fri Nov 2 2007 * * Copyright (c) 2007 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. * */ #include "mp_CERT_Public.h" #include "mp_CERT.h" #ifdef DEMO #include #include "DemoAndLicensing.h" #endif static const MP_CERT_Public::Square empty = { 0.0, 0.0, 0.0, 0.0, 0.0 }; std::string MP_CERT_Public::getVersion() { return MP_CERT::getVersion(); } std::string MP_CERT_Public::getBuildString() { return MP_CERT::getBuildString(); } MP_CERT_Public::MP_CERT_Public( bool multiThreaded ) : cert(NULL) { #ifdef DEMO CERT::DemoAndLicensing *demo = CERT::DemoAndLicensing::sharedDemo(); if( demo->isDemo() ) { if( demo->hasDemoEnded() ) { demo->notifyUserDemoEnded(); std::ostringstream ostr; ostr << "The evaluation period ended on " << demo->demoEndDate() << std::endl; throw DemoException( ostr.str() ); } } else { if( !demo->startDemo() ) { demo->notifyUserDemoNotAllowed(); std::ostringstream ostr; ostr << "Unable to start an evaluation period." << std::endl; throw DemoException( ostr.str() ); } } demo->notifyUserDemoLeft(); #endif cert = new MP_CERT( multiThreaded ); } MP_CERT_Public::~MP_CERT_Public() { if( cert ) delete cert; } void MP_CERT_Public::loadPlugins() { if( cert ) cert->loadPlugins(); } void MP_CERT_Public::processTask() { if( cert ) cert->processTask(); } CERT::Task & MP_CERT_Public::getTask() { ASSERT(cert); return cert->getTask(); } void MP_CERT_Public::calcAUs( RImage &rimage, const std::string &path ) { if( cert ) cert->calcAUs( rimage, path ); } void MP_CERT_Public::calcAUsFromFace( RImage &face ) { if( cert ) cert->calcAUsFromFace( face ); } bool MP_CERT_Public::didFindFace() { if( cert ) return cert->didFindFace(); else return false; } RImage MP_CERT_Public::getPatch() { if( cert ) return cert->getPatch(); else return RImage(); } std::vector MP_CERT_Public::eyes() { if( cert ) return cert->eyes(); else return std::vector(); } void MP_CERT_Public::clear() { if( cert ) cert->clear(); } std::map< std::string, mp_AUResults > MP_CERT_Public::getFrequencies() { if( cert ) return cert->getFrequencies(); else return std::map< std::string, mp_AUResults >(); } bool MP_CERT_Public::addCategoryFromDirectory( std::string cat, const std::string &dir ) { if( cert ) return cert->addCategoryFromDirectory( cat, dir ); else return false; } std::vector MP_CERT_Public::resultsForCategory( const std::string &cat ) { if( cert ) return cert->resultsForCategory( cat ); else return std::vector(); } ObjectWithFeatures * MP_CERT_Public::getLargestFace() { if( cert ) return cert->getLargestFace(); else return NULL; } void MP_CERT_Public::setFaceEstimate( int x, int y, int size, int scale ) { if( cert ) cert->setFaceEstimate( x, y, size, scale ); } MP_CERT_Public::Square MP_CERT_Public::lastFoundFace() { if( cert ) { MP_CERT::certSquare face = cert->lastFoundFace(); MP_CERT_Public::Square res; res.x = face.x; res.y = face.y; res.width = face.width; res.height = face.height; res.scale = face.scale; return res; } else return empty; } void MP_CERT_Public::setSequential( bool seq ) { if( cert ) cert->setSequential( seq ); } bool MP_CERT_Public::getSequential() { if( cert ) return cert->getSequential(); else return false; } void MP_CERT_Public::setMaxTry( int max ) { if( cert ) cert->setMaxTry( max ); } int MP_CERT_Public::getMaxTry() { if( cert ) return cert->getMaxTry(); else return false; } bool MP_CERT_Public::getInputIsFaces() { if( cert ) return cert->getInputIsFaces(); else return false; } void MP_CERT_Public::setInputIsFaces( bool _faces ) { if( cert ) cert->setInputIsFaces( _faces ); } void MP_CERT_Public::setMaxScale( int max ) { if( cert ) cert->setMaxScale( max ); } int MP_CERT_Public::getMaxScale() { if( cert ) return cert->getMaxScale(); else return 20; } void MP_CERT_Public::setMinScale( int min ) { if( cert ) cert->setMinScale( min ); } int MP_CERT_Public::getMinScale() { if( cert ) return cert->getMinScale(); else return 0; }