/** * @file LocalizationResult.h * @brief classification result, what else? * @author Erik Rodner * @date 02/13/2008 */ #ifndef LocalizationResultINCLUDE #define LocalizationResultINCLUDE #include "core/image/ImageT.h" #include "core/vector/VectorT.h" #include "core/vector/MatrixT.h" #include #include #include #include "ClassificationResult.h" #include "ClassNames.h" #include "core/basics/Persistent.h" #include #include namespace OBJREC { class SingleLocalizationResult { private: /** used for depth ordering */ int controlPoints; int xi, yi, xa, ya; bool hasRegionInformation_bool; NICE::Region reg; public: ClassificationResult *r; SingleLocalizationResult ( ClassificationResult *r, const NICE::Region & reg, int controlPoints = 0 ); SingleLocalizationResult ( ClassificationResult *r, int xi, int yi, int xa, int ya ); ~SingleLocalizationResult (); void getBoundingBox ( int & xi, int & yi, int & xa, int & ya ) const; void getBoundingBox ( NICE::RectT & rectangle ) const; void getCentroid ( double & x, double & y ) const; bool hasRegionInformation () const { return hasRegionInformation_bool; }; int getControlPoints () const { return controlPoints; }; const NICE::Region & getRegion () const { assert (hasRegionInformation_bool); return reg; }; void addPoint ( int x, int y ) { assert(hasRegionInformation_bool); reg.add(x,y); }; double getBBOverlapMeasure ( const SingleLocalizationResult & slr ) const; double getBBOverlapMeasureMin ( const SingleLocalizationResult & slr ) const; }; class LocalizationResult : public std::vector, public NICE::Persistent { private: const ClassNames *cn; NICE::Image *labeledImage; public: typedef std::vector::iterator iterator; typedef std::vector::const_iterator const_iterator; bool hasLabeledImage; int xsize; int ysize; enum { FILEFORMAT_PASCAL2006_RESULT = 0, FILEFORMAT_PASCAL2006_GROUNDTRUTH, FILEFORMAT_POLYGON }; LocalizationResult ( int xsize = -1, int ysize = -1 ); LocalizationResult ( const ClassNames *cn, int xsize = -1, int ysize = -1); LocalizationResult ( const ClassNames *cn, const NICE::Image & img, int classno ); LocalizationResult ( const ClassNames *cn, const NICE::ColorImage & img ); ~LocalizationResult (); void sortEmpricalDepth(); void sortDescendingConfidence(); void getLabeledImageCache ( NICE::Image & mark ) const; void calcLabeledImage ( NICE::Image & mark, int backgroundClassNo ) const; void setMap ( const NICE::Image & labeledImage ); void displayBoxes ( NICE::ColorImage & img, const ClassNames *cn = NULL, bool display_confidence = true, bool invert = false, int width = 1) const; void restore (std::istream & is, int format = 0); void store (std::ostream & os, int format = 0) const; void clear (); int getMaxClassno () { assert(cn != NULL); return cn->getMaxClassno(); }; }; } // namespace #endif