-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageprocessor.h
executable file
·88 lines (74 loc) · 2.53 KB
/
imageprocessor.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
84
85
86
87
88
/*
* HandControl - Hand gesture recognition
* Copyright (C) 2010 Michal Hozza ([email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IMAGEPROCESSOR_H
#define IMAGEPROCESSOR_H
#include <QImage>
#include <QColor>
#include <QThread>
#include <QFuture>
#include <QtConcurrentRun>
#include <QMutex>
#include <queue>
#include <utils.h>
#include "handrecognizer.h"
#include "kalmanfilter.h"
using namespace std;
#define TRESHOLD 7
#define RATIO 24
#define MAX_FRAMES 40
#define PIXEL_RADIUS 4
#define MIN_RECT_SIZE 40
#define MAX_RECT_SIZE 240
class ImageProcessor
{
GrayScaleImage *oldImage, img, *expandedImgX, *expandedImg;
int images,images2;
bool imgChanged;
unsigned sum;
QMutex imgLock;
HandRecognizer * handRecognizer;
queue<pair<QRect,uint> > rectQueue;
int index;
KalmanFilter * kf;
template<class T> inline void exchange(T &a, T &b)
{
T t = a;
a = b;
b = t;
}
template<class T> inline T median3(T a, T b, T c)
{
if(b>a) exchange(a,b);
if(c>a) exchange(a,c);
if(c>b) exchange(b,c);
return b;
}
void prepareImg(GrayScaleImage &, int ,int ,int ,int );
void medianFilterX(int sy, int ex, int ey, GrayScaleImage * imgIn, GrayScaleImage * imgOut);
void medianFilterY(int sx, int ex, int ey, GrayScaleImage * imgIn, GrayScaleImage * imgOut);
void expandPixelsX(int sy, int ex, int ey, GrayScaleImage * imgIn, GrayScaleImage * imgOut);
void expandPixelsY(int sx, int ex, int ey, GrayScaleImage * imgIn, GrayScaleImage * imgOut);
QRect segment(unsigned x, unsigned y, uchar color, GrayScaleImage * image, QRect rect);
public:
bool useKalmanFilter;
ImageProcessor(int width, int height, HandRecognizer * handRecognizer);
~ImageProcessor();
GrayScaleImage processImage(const GrayScaleImage &image);
inline bool imageChanged(){return imgChanged;}
};
#endif // IMAGEPROCESSOR_H