forked from adore-hrzz/nao-sound-classification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCModule.h
83 lines (63 loc) · 1.83 KB
/
SCModule.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef SCMODULE_H
#define SCMODULE_H
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <unistd.h>
#include <time.h>
#include <boost/shared_ptr.hpp>
#include <alcommon/almodule.h>
#include <alcommon/alproxy.h>
#include <alcommon/albroker.h>
#include <alvalue/alvalue.h>
#include <alaudio/alsoundextractor.h>
#include <alproxies/almemoryproxy.h>
#include <opencv2/core/core.hpp>
#include <opencv2/ml/ml.hpp>
#include "features.h"
#include "noiseFilter.h"
using namespace std;
using namespace AL;
using namespace cv;
class SCModule : public ALSoundExtractor
{
private:
bool flagRecord;
bool flagRealTime;
bool flagClassify;
bool flagNoise;
bool flagReady;
int noInput;
float treshold;
int windowSamples;
int subWindow;
int samplerate;
string classParams;
map<int,int> classResults;
map<int, string> classNames;
int numDone;
CvGBTrees model;
vector<vector <double>> recordedAudio;
vector<double> recordedNoise;
int numAudio;
ALMemoryProxy fProxyToALMemory;
public:
SCModule(boost::shared_ptr<ALBroker> pBroker, std::string pName);
virtual ~SCModule();
virtual void init();
ALValue soundAcqusition(const ALValue&duration);
void process(const int & nbOfChannels,
const int & nbrOfSamplesByChannel,
const AL_SOUND_FORMAT * buffer,
const ALValue & timeStamp);
void initRTClassification(const AL::ALValue &modelPath, const AL::ALValue &featString, const AL::ALValue &responses);
void startRTClassification();
void stopRTClassification();
void soundClassification(const std::string &key,
const AL::ALValue &value,
const AL::ALValue &message);
};
#endif // SCMODULE_H