-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhsom.cpp
More file actions
53 lines (42 loc) · 1.17 KB
/
hsom.cpp
File metadata and controls
53 lines (42 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "hsom.h"
namespace somtk {
HSOM::HSOM( SOMPtr som, ClassifierPtr classifier ) :
som( som ),
classifier( classifier )
{}
HSOM::~HSOM(){}
void HSOM::generateHistogram( SuspectPtr suspect )
{
foreach( FeaturePtr feature, suspect->features() )
suspect->histogram()->increment( som->closestFeature( feature ) );
}
void HSOM::train( SuspectLibraryPtr suspectLibrary,
QMap<QString, QVariant> somParameters,
QMap<QString, QVariant> classifierParameters )
{
/// @todo: This should probably take a library not a list of suspects
//try
//{
QVector< FeaturePtr > features = suspectLibrary->extractFeatures();
som->train( somParameters, features );
foreach( SuspectPtr suspect, suspectLibrary->suspects() )
{
generateHistogram( suspect );
}
classifier->train( suspectLibrary, classifierParameters );
//}
//catch( SOMError err )
//{
// throw err;
//}
//catch( ... )
//{
// throw;
//}
}
void HSOM::classify( SuspectPtr suspect )
{
generateHistogram( suspect );
classifier->classify( suspect );
}
} // namespace hsom