-
Notifications
You must be signed in to change notification settings - Fork 0
/
handrecognizer.h
executable file
·54 lines (47 loc) · 1.24 KB
/
handrecognizer.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
#ifndef HANDRECOGNIZER_H
#define HANDRECOGNIZER_H
#include <queue>
#include <QRect>
#include <QImage>
#include <QMutex>
#include "NeuralNet/neuralnetwork.h"
#include "NeuralNet/distributedrecurrentnetwork.h"
#include "NeuralNet/distributedneuralnetwork.h"
#include "grayscaleimage.h"
#include "colorimage.h"
using namespace std;
using namespace NeuralNET;
#define SCALE_SIZE 128
#define N SCALE_SIZE*SCALE_SIZE
#define N_SIDE SCALE_SIZE
#define OUT_N 1
#define HIDDEN_N_SIDE 4
#define HIDDEN_N HIDDEN_N_SIDE*HIDDEN_N_SIDE*11
#define HIDDEN_N2 7
#define HAND_TRESHOLD 0.9
#define SAVEIMAGE_BUFFER_SIZE 300
#define USE_RECURRENT
class HandRecognizer
{
#ifdef USE_RECURRENT
RecurrentNetwork * net;
#else
NeuralNetwork * net;
#endif
int index;
float hand_p;
QRect handRect;
inline void resetHand(){hand_p = 0;}
bool isSimilarRect(QRect r1, QRect r2);
vector<string> saveImageBuffer;
QMutex fftLock;
public:
QMutex rectQueueLock;
HandRecognizer();
void processRects(queue<pair<QRect,uint> > * q, GrayScaleImage * img_ref, GrayScaleImage * img);
inline bool isHand(){return hand_p>HAND_TRESHOLD;}
inline QRect getHandRect(){return handRect;}
inline float getHandP(){return hand_p;}
void reset();
};
#endif // HANDRECOGNIZER_H