-
Notifications
You must be signed in to change notification settings - Fork 1
/
haarcascade.h
143 lines (127 loc) · 4.49 KB
/
haarcascade.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* QtHaar, Viola-Jones implementation in Qt.
* Copyright (C) 2015 Gonzalo Exequiel Pedone
*
* QtHaar 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.
*
* QtHaar 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 QtHaar. If not, see <http://www.gnu.org/licenses/>.
*
* Email : hipersayan DOT x AT gmail DOT com
* Web-Site: http://github.com/hipersayanX/QtHaar
*/
#ifndef HAARCASCADE_H
#define HAARCASCADE_H
#include <QMutex>
#include "haarstage.h"
class HaarCascade;
class HaarCascadeHID
{
public:
explicit HaarCascadeHID(const HaarCascade &cascade,
int startX,
int endX,
int startY,
int endY,
int windowWidth,
int windowHeight,
int oWidth,
const quint32 *integral,
const quint32 *tiltedIntegral,
qreal step,
qreal invArea,
qreal scale,
bool cannyPruning,
const quint32 **p,
const quint64 **pq,
const quint32 **ip,
const quint32 **icp,
QList<QRect> *roi,
QMutex *mutex);
~HaarCascadeHID();
static void run(HaarCascadeHID *cascade);
private:
int m_count;
HaarStageHID **m_stages;
int m_startX;
int m_endX;
int m_startY;
int m_endY;
int m_windowWidth;
int m_windowHeight;
int m_oWidth;
qreal m_step;
qreal m_invArea;
bool m_isTree;
bool m_cannyPruning;
const quint32 *m_p[4];
const quint64 *m_pq[4];
const quint32 *m_ip[4];
const quint32 *m_icp[4];
QList<QRect> *m_roi;
QMutex *m_mutex;
};
class HaarCascade: public QObject
{
Q_OBJECT
Q_PROPERTY(QString name
READ name
WRITE setName
RESET resetName
NOTIFY nameChanged)
Q_PROPERTY(QSize windowSize
READ windowSize
WRITE setWindowSize
RESET resetWindowSize
NOTIFY windowSizeChanged)
Q_PROPERTY(HaarStageVector stages
READ stages
WRITE setStages
RESET resetStages
NOTIFY stagesChanged)
Q_PROPERTY(QString errorString
READ errorString
NOTIFY errorStringChanged)
public:
explicit HaarCascade(QObject *parent = NULL);
HaarCascade(const HaarCascade &other);
~HaarCascade();
Q_INVOKABLE QString name() const;
Q_INVOKABLE QString &name();
Q_INVOKABLE QSize windowSize() const;
Q_INVOKABLE QSize &windowSize();
Q_INVOKABLE HaarStageVector stages() const;
Q_INVOKABLE HaarStageVector &stages();
Q_INVOKABLE QString errorString() const;
Q_INVOKABLE bool load(const QString &fileName);
HaarCascade &operator =(const HaarCascade &other);
bool operator ==(const HaarCascade &other) const;
bool operator !=(const HaarCascade &other) const;
private:
QString m_name;
QSize m_windowSize;
HaarStageVector m_stages;
QString m_errorString;
bool m_isTree;
signals:
void nameChanged(const QString &name);
void windowSizeChanged(const QSize &windowSize);
void stagesChanged(const HaarStageVector &stages);
void errorStringChanged(const QString &errorString);
public slots:
void setName(const QString &name);
void setWindowSize(const QSize &windowSize);
void setStages(const HaarStageVector &stages);
void resetName();
void resetWindowSize();
void resetStages();
friend class HaarCascadeHID;
};
#endif // HAARCASCADE_H