SemSegObliqueTree.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * @file SemSegObliqueTree.h
  3. * @brief Semantic Segmentation using Oblique Trees
  4. * @author Sven Sickert
  5. * @date 10/17/2014
  6. */
  7. #ifndef SEMSEGOBLIQUETEEINCLUDE
  8. #define SEMSEGOBLIQUETEEINCLUDE
  9. // nice-core includes
  10. // nice-vislearning includes
  11. #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
  12. // nice-semseg includes
  13. #include "SemanticSegmentation.h"
  14. namespace OBJREC
  15. {
  16. class SemSegObliqueTree : public SemanticSegmentation
  17. {
  18. private:
  19. /** pointer to config file */
  20. const NICE::Config *conf;
  21. /** save / load trained classifier */
  22. bool saveLoadData;
  23. /** 0 - RGB, 1 - HSV, 2 - CIELab */
  24. int colorMode;
  25. /** file location of trained classifier */
  26. std::string fileLocation;
  27. /** classifier for categorization */
  28. FeaturePoolClassifier *fpc;
  29. /**
  30. * @brief pre-processing: resulting channels with values in the range [0,1] for RGB, HSV or GREY
  31. * @param ce current cached example
  32. * @param isColor color mode
  33. */
  34. void preprocessChannels ( CachedExample *ce, bool isColor ) const;
  35. public:
  36. /** simple constructor */
  37. SemSegObliqueTree ();
  38. /** config constructor */
  39. SemSegObliqueTree ( const NICE::Config *conf,
  40. const ClassNames *classNames );
  41. /** simple destructor */
  42. virtual ~SemSegObliqueTree();
  43. /**
  44. * @brief Setup internal variables and objects used
  45. * @param conf Configuration file to specify variable settings
  46. * @param s_confSection Section in configuration file
  47. */
  48. void initFromConfig (
  49. const NICE::Config *_conf,
  50. const std::string & s_confSection = "SemSegObliqueTree" );
  51. /**
  52. * @brief training function / learn classifier
  53. * @param md the data set
  54. */
  55. void train ( const MultiDataset *md );
  56. /**
  57. * @brief classification function
  58. @param ce image data
  59. @param segresult result of the semantic segmentation with a label
  60. for each pixel
  61. @param probabilities multi-channel image with one channel for
  62. each class and corresponding probabilities for each pixel
  63. */
  64. void semanticseg ( CachedExample *ce,
  65. NICE::ImageT<int> &segresult,
  66. NICE::MultiChannelImageT<double> &probabilities );
  67. ///////////////////// INTERFACE PERSISTENT /////////////////////
  68. // interface specific methods for store and restore
  69. ///////////////////// INTERFACE PERSISTENT /////////////////////
  70. /**
  71. * @brief Load segmentation object from external file (stream)
  72. */
  73. virtual void restore ( std::istream & is, int format = 0 );
  74. /**
  75. * @brief Save segmentation-object to external file (stream)
  76. */
  77. virtual void store( std::ostream & os, int format = 0 ) const;
  78. /**
  79. * @brief Clear segmentation-object object
  80. */
  81. virtual void clear ();
  82. };
  83. } // namespace
  84. #endif