ClusterOnline.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @file ClusterOnline.cpp
  3. * @brief interface for online clustering
  4. * @author Erik Rodner
  5. * @date 02/13/2008
  6. */
  7. #ifdef NOVISUAL
  8. #include <vislearning/nice_nonvis.h>
  9. #else
  10. #include <vislearning/nice.h>
  11. #endif
  12. #include <iostream>
  13. #include <fstream>
  14. #include "vislearning/math/cluster/ClusterOnline.h"
  15. using namespace OBJREC;
  16. using namespace std;
  17. // refactor-nice.pl: check this substitution
  18. // old: using namespace ice;
  19. using namespace NICE;
  20. ClusterOnline::ClusterOnline()
  21. {
  22. }
  23. ClusterOnline::~ClusterOnline()
  24. {
  25. }
  26. void ClusterOnline::init ()
  27. {
  28. clusters.clear();
  29. weights.clear();
  30. }
  31. void ClusterOnline::cluster ( const VVector & features,
  32. VVector & prototypes,
  33. std::vector<double> & _weights,
  34. std::vector<int> & assignment )
  35. {
  36. init();
  37. assignment.clear();
  38. prototypes.clear();
  39. _weights.clear();
  40. for ( VVector::const_iterator i = features.begin();
  41. i != features.end(); i++ )
  42. {
  43. // refactor-nice.pl: check this substitution
  44. // old: const Vector & x = *i;
  45. const NICE::Vector & x = *i;
  46. // calling virtual function !
  47. int nearest_cluster = updateClusters ( x );
  48. assignment.push_back ( nearest_cluster );
  49. }
  50. prototypes.insert ( prototypes.begin(), clusters.begin(), clusters.end() );
  51. _weights.insert ( _weights.begin(), weights.begin(), weights.end() );
  52. }