#include namespace icl{ // {{{ RGBPixelRating class RGBPixelRating : public PixelRating{ public: RGBPixelRating(const icl8u ref[3], const icl8u thresh[3]){ for(int i=0;i<3;i++){ this->thresh[i] = thresh[i]; this->ref[i]=ref[i]; } } virtual bool rate(icl8u r, icl8u g, icl8u b){ return abs(ref[0]-r) < thresh[0] && abs(ref[1]-g) < thresh[1] && abs(ref[2]-b) < thresh[2]; } protected: icl8u thresh[3],ref[3]; }; // }}} // {{{ RatingGroupOR struct RatingGroupOR : public PixelRatingGroup{ virtual bool combineRatings(const vector &ratings){ for(vector::const_iterator it = ratings.begin();it!=ratings.end(); ++it){ if(*it)return true; } return false; } }; // }}} // {{{ RatingGroupAND struct RatingGroupAND : public PixelRatingGroup{ virtual bool combineRatings(const vector &ratings){ for(vector::const_iterator it = ratings.begin();it!=ratings.end(); ++it){ if(!(*it))return false; } return true; } }; // }}} // {{{ DefaultColorBlobSearcher DefaultColorBlobSearcher::DefaultColorBlobSearcher(const Size &imageSize):m_oImageSize(imageSize){ // {{{ open } // }}} DefaultColorBlobSearcher::~DefaultColorBlobSearcher(){ // {{{ open } // }}} void DefaultColorBlobSearcher::prepareForNewImage(Img8u *poImage, Img8u *poMask){ // {{{ open (void)poImage; (void)poMask; for(int i=0;i::search(poImage,poMask); } // }}} int DefaultColorBlobSearcher::addSubSearcher(const vector &rs, const vector &gs, const vector &bs, const icl8u thresholds[3], DefaultColorBlobSearcher::RatingCombinationType rct, DefaultColorBlobSearcher::CenterEstimationType cet){ // {{{ open PixelRatingGroup *rg; if(rct == rctOR) rg = new RatingGroupOR(); else rg = new RatingGroupAND(); icl8u ref[3]; for(unsigned int i=0;iaddPR(new RGBPixelRating(ref,thresholds)); } addPR(rg); m_vecCet.push_back(cet); return getNumPR() -1; } // }}} const Size &DefaultColorBlobSearcher::getImageSize() const { // {{{ open return m_oImageSize; } // }}} void DefaultColorBlobSearcher::setImageSize(const Size &size){ // {{{ open if(m_oImageSize != size){ m_oImageSize = size; unsigned int nPixelRatings = m_vecXMedianLists.size(); m_vecXMedianLists.clear(); m_vecYMedianLists.clear(); for(unsigned int i=0;i