LocalizationResult.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * @file LocalizationResult.h
  3. * @brief classification result, what else?
  4. * @author Erik Rodner
  5. * @date 02/13/2008
  6. */
  7. #ifndef LocalizationResultINCLUDE
  8. #define LocalizationResultINCLUDE
  9. #include <vislearning/nice_nonvis.h>
  10. #include <string>
  11. #include <vector>
  12. #include <assert.h>
  13. #include "ClassificationResult.h"
  14. #include "ClassNames.h"
  15. #include "core/basics/Persistent.h"
  16. #include <core/image/Region.h>
  17. #include <core/image/RectT.h>
  18. namespace OBJREC {
  19. class SingleLocalizationResult
  20. {
  21. private:
  22. /** used for depth ordering */
  23. int controlPoints;
  24. int xi, yi, xa, ya;
  25. bool hasRegionInformation_bool;
  26. NICE::Region reg;
  27. public:
  28. ClassificationResult *r;
  29. SingleLocalizationResult ( ClassificationResult *r, const NICE::Region & reg, int controlPoints = 0 );
  30. SingleLocalizationResult ( ClassificationResult *r, int xi, int yi, int xa, int ya );
  31. ~SingleLocalizationResult ();
  32. void getBoundingBox ( int & xi, int & yi, int & xa, int & ya ) const;
  33. void getBoundingBox ( NICE::RectT<int> & rectangle ) const;
  34. void getCentroid ( double & x, double & y ) const;
  35. bool hasRegionInformation () const { return hasRegionInformation_bool; };
  36. int getControlPoints () const { return controlPoints; };
  37. const NICE::Region & getRegion () const { assert (hasRegionInformation_bool); return reg; };
  38. void addPoint ( int x, int y ) { assert(hasRegionInformation_bool); reg.add(x,y); };
  39. double getBBOverlapMeasure ( const SingleLocalizationResult & slr ) const;
  40. double getBBOverlapMeasureMin ( const SingleLocalizationResult & slr ) const;
  41. };
  42. class LocalizationResult : public std::vector<SingleLocalizationResult *>, public NICE::Persistent
  43. {
  44. private:
  45. const ClassNames *cn;
  46. NICE::Image *labeledImage;
  47. public:
  48. bool hasLabeledImage;
  49. int xsize;
  50. int ysize;
  51. enum {
  52. FILEFORMAT_PASCAL2006_RESULT = 0,
  53. FILEFORMAT_PASCAL2006_GROUNDTRUTH,
  54. FILEFORMAT_POLYGON
  55. };
  56. LocalizationResult ( int xsize = -1, int ysize = -1 );
  57. LocalizationResult ( const ClassNames *cn, int xsize = -1, int ysize = -1);
  58. LocalizationResult ( const ClassNames *cn, const NICE::Image & img, int classno );
  59. LocalizationResult ( const ClassNames *cn, const NICE::ColorImage & img );
  60. ~LocalizationResult ();
  61. void sortEmpricalDepth();
  62. void sortDescendingConfidence();
  63. void getLabeledImageCache ( NICE::Image & mark ) const;
  64. void calcLabeledImage ( NICE::Image & mark, int backgroundClassNo ) const;
  65. void setMap ( const NICE::Image & labeledImage );
  66. void displayBoxes ( NICE::ColorImage & img,
  67. const ClassNames *cn = NULL,
  68. bool display_confidence = true,
  69. bool invert = false,
  70. int width = 1) const;
  71. void restore (std::istream & is, int format = 0);
  72. void store (std::ostream & os, int format = 0) const;
  73. void clear ();
  74. int getMaxClassno () { assert(cn != NULL); return cn->getMaxClassno(); };
  75. };
  76. } // namespace
  77. #endif