12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /**
- * @file ClusterOnline.cpp
- * @brief interface for online clustering
- * @author Erik Rodner
- * @date 02/13/2008
- */
- #ifdef NOVISUAL
- #include <vislearning/nice_nonvis.h>
- #else
- #include <vislearning/nice.h>
- #endif
- #include <iostream>
- #include <fstream>
- #include "vislearning/math/cluster/ClusterOnline.h"
- using namespace OBJREC;
- using namespace std;
- // refactor-nice.pl: check this substitution
- // old: using namespace ice;
- using namespace NICE;
- ClusterOnline::ClusterOnline()
- {
- }
- ClusterOnline::~ClusterOnline()
- {
- }
- void ClusterOnline::init ()
- {
- clusters.clear();
- weights.clear();
- }
- void ClusterOnline::cluster ( const VVector & features,
- VVector & prototypes,
- std::vector<double> & _weights,
- std::vector<int> & assignment )
- {
- init();
- assignment.clear();
- prototypes.clear();
- _weights.clear();
- for ( VVector::const_iterator i = features.begin();
- i != features.end(); i++ )
- {
- // refactor-nice.pl: check this substitution
- // old: const Vector & x = *i;
- const NICE::Vector & x = *i;
- // calling virtual function !
- int nearest_cluster = updateClusters ( x );
- assignment.push_back ( nearest_cluster );
- }
- prototypes.insert ( prototypes.begin(), clusters.begin(), clusters.end() );
- _weights.insert ( _weights.begin(), weights.begin(), weights.end() );
- }
|