05Robot 3.0

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

ceyetrackerfilter.h
Go to the documentation of this file.
1
7 #include <QObject>
8 #include <QVector>
9 #include <QPointF>
10 #include <QRectF>
11 #include <QEvent>
12 #include <QElapsedTimer>
13 #include <QAbstractButton>
14 #include "cxmlio.h"
15 #include "common.h"
16
41 #ifndef CEYETRACKERFILTER_H
42 #define CEYETRACKERFILTER_H
43 class cEyeTrackerFilter;
47 struct sMousePos
48 {
49 QPoint point;
50 Qt::KeyboardModifiers modifiers;
51 int64_t time;
52 QAbstractButton *button;
53 };
57 struct sAtomGesture
58 {
65 enum eGestureType{IN_PROGRESS=0,
66 OTHER,
67 V_LINE_UP,
68 V_LINE_DOWN,
69 H_LINE_LEFT,
70 H_LINE_RIGHT,
71 GAZE,
72 EYE_BLINK,
73 GENERIC_CLICK,
74 COMPLEX_GESTURE_DETECTED
75 };
76 eGestureType gestureType;
77 QRect boundingBox;
78 sMousePos start;
79 sMousePos end;
80
81 };
91 struct boundingBoxInfo
92 {
93 QRect region;
94 int64_t delta_t;
95 int isMonotonicX;
96 int isMonotonicY;
97 bool gazeDetection;
98 QVector<sMousePos> trace;
99 };
100
113 class cGestureDirectoryEntry{
114 public:
118 enum eConditionType{NONE=0,
119 EQUAL_SIZE,
120 EQUAL_START_END,
121 SAME_BUTTON_END
122 };
123 private:
124 QVector<sAtomGesture::eGestureType> chain;
125 QString name_;
126 int id_;
127 Qt::MouseButton mouseButton_;
128 int keyboardShortcut_;
129 Qt::KeyboardModifier keyboardModifiers_;
130 int max_duration_;
131 eConditionType conditionType;
132 QRect boundigBox_;
133 QPoint clickPoint_;
134
135 public:
139 cGestureDirectoryEntry():id_(-1){}
155 cGestureDirectoryEntry(int _ID, const QString& _name, const QVector<sAtomGesture::eGestureType>& _chain, eConditionType _conditopnType, Qt::MouseButton clickEvent, int keyboardShortcut, Qt::KeyboardModifier keyboardModifiers=Qt::NoModifier, int max_duration=-1);
162 bool compare(QVector<sAtomGesture> atomGestures, double tolerance);
166 QString getName() const;
170 int getID() const;
174 QPoint getPoint() const;
178 QRect getBoundingBox() const {return boundigBox_;}
182 Qt::MouseButton getMouseButton() const;
186 void setMouseButton(const Qt::MouseButton &mouseButton);
191 int getKeyboardShortcut() const;
192
197 Qt::KeyboardModifier getKeyboardModifiers() const;
203 void setKeyboardShortcut(int keyboardShortcut,const Qt::KeyboardModifier &keyboardModifiers);
204
205
206 };
207
208
213 class cEyeTrackerFilter : public cXmlIO
214 {
215 Q_OBJECT
216
217 QElapsedTimer timer_;
218 QElapsedTimer timerMouseLeave_;
219 QVector<sMousePos> mouseTrace_;
220 QVector<sAtomGesture> atomGestures_;
221 sAtomGesture previousGesture_;
222
227 ADD_PROPERTY(tangential_coefs, double)
228 Q_CLASSINFO("tangential_coefs", "minimum=0;maximum=.5;singleStep=0.05;");
232 ADD_PROPERTY(use_gaze2click, bool)
237 ADD_PROPERTY(gaze_timeout, int)
242 ADD_PROPERTY(gaze_tolerance, int)
246 ADD_PROPERTY(minimum_gesture_segment_length_ratio,double)
247 Q_CLASSINFO("minimum_gesture_segment_length_ratio", "minimum=1;maximum=100;singleStep=0.1;");
248
252 ADD_PROPERTY(use_complex_gestures, bool)
256 ADD_PROPERTY(leave_window_timeout, int)
260 ADD_PROPERTY(gesture_tolerance,int)
261 private:
262 QObject* currentSenderObject_;
263 QWidget* currentTopWidget_=0;
264 QPoint currentLocalMousePos_;
265 QWidget* parentWindow_;
266 QVector<cGestureDirectoryEntry> gDirectory;//< list of detected atomic gestures, processed by detectComplexGesture routine
267 int64_t max_time_=0;
268 sAtomGesture::eGestureType processTrace();
269 QVector<sMousePos> truncateMonotonicPeriod(QVector<sMousePos> trace, sAtomGesture::eGestureType previousGesture);
270 protected:
279 sAtomGesture::eGestureType detectGesture(sAtomGesture::eGestureType confirmType);
287 sAtomGesture::eGestureType detectComplexGesture();
291 void clearBuffers();
298 void addAtomGesture(const sAtomGesture &newGesture);
305 boundingBoxInfo boundingBox(int64_t timeHorizont=-1);
311 sAtomGesture atomGesturesClassifier(const boundingBoxInfo &info);
312
313 public:
326 explicit cEyeTrackerFilter(const QVector<cGestureDirectoryEntry>& gDirectory, QWidget *mouseGrabberWidget, int xmlID=0);
333 bool eventFilter(QObject *watched, QEvent *event);
334
335 enum logSource{MOUSE_MOVE, MOUSE_CLICK, HOVER_LEAVE, HOVER_ENTER, ATOM_GESTURE_EVENT, COMPLEX_GESTURE_EVENT, CONFIRM_EVENT, USER=100};
336
337 signals:
344 void complexGesture(int ID, QRect bb, QPoint point, QString name);
345
346 void logEvent(cEyeTrackerFilter::logSource ID, int x, int y, int additional, QString info);
347 public slots:
348 };
349
350
363 class cComplexGestureEvent : public QEvent
364 {
365 public:
370 cComplexGestureEvent(const cGestureDirectoryEntry& entry);
371
372 virtual ~cComplexGestureEvent()
373 {}
374
381 static QEvent::Type type()
382 {
383 if (customEventType == QEvent::None)
384 {
385 int generatedType = QEvent::registerEventType();
386 customEventType = static_cast<QEvent::Type>(generatedType);
387 }
388 return customEventType;
389 }
390
394 QPoint pos() const;
399 void setPos(const QPoint &pos);
400
405 QRect boundingBox() const;
409 void setBoundingBox(const QRect &boundingBox);
410
414 int gestureID() const;
418 void setGestureID(int gestureID);
419
423 QString gestureName() const;
428 void setGestureName(const QString &gestureName);
429
430 private:
431 static QEvent::Type customEventType;
432 QPoint pos_;
433 QRect boundingBox_;
434 int gestureID_;
435 QString gestureName_;
436
437 };
438
439
440
441 #endif // CEYETRACKERFILTER_H
442
sAtomGesture::OTHER
Informs that no gesture can be recognized.
Definition: ceyetrackerfilter.h:66
boundingBoxInfo
The structure stores descriptors of mouse cursor trace.
Definition: ceyetrackerfilter.h:91
boundingBoxInfo::isMonotonicY
int isMonotonicY
0 - the Y coordinates were not monotonic in vertical direction, -1 - monotonically decreasing in hori...
Definition: ceyetrackerfilter.h:96
ADD_PROPERTY
#define ADD_PROPERTY(member, _type)
Definition: common.h:14
sAtomGesture::end
sMousePos end
The last point of mouse cursor trace.
Definition: ceyetrackerfilter.h:79
cEyeTrackerFilter
The cEyeTrackerFilter class.
Definition: ceyetrackerfilter.h:213
cxmlio.h
cComplexGestureEvent::~cComplexGestureEvent
virtual ~cComplexGestureEvent()
Definition: ceyetrackerfilter.h:372
boundingBoxInfo::trace
QVector< sMousePos > trace
Mouse cursor trace, used only for debugging purposes.
Definition: ceyetrackerfilter.h:98
cComplexGestureEvent::type
static QEvent::Type type()
overridden function from QEvent class
Definition: ceyetrackerfilter.h:381
sAtomGesture::V_LINE_DOWN
Vertical line was detected.
Definition: ceyetrackerfilter.h:68
boundingBoxInfo::gazeDetection
bool gazeDetection
The field informs whether the trajectory is restricted by bounding box of size smaller than property ...
Definition: ceyetrackerfilter.h:97
sAtomGesture::V_LINE_UP
Vertical line was detected.
Definition: ceyetrackerfilter.h:67
sAtomGesture
The structure represents an atom gesture data and defines eGestureType enumerator.
Definition: ceyetrackerfilter.h:57
sAtomGesture::gestureType
eGestureType gestureType
Type of gesture performed (eGestureType)
Definition: ceyetrackerfilter.h:76
sMousePos::time
int64_t time
Time of event occurrence in (ms)
Definition: ceyetrackerfilter.h:51
sAtomGesture::start
sMousePos start
The initial point of mouse cursor trace.
Definition: ceyetrackerfilter.h:78
sAtomGesture::eGestureType
eGestureType
enumerator representing gesturesTypes
Definition: ceyetrackerfilter.h:65
sAtomGesture::boundingBox
QRect boundingBox
The bounding box of mouse cursor trace.
Definition: ceyetrackerfilter.h:77
sMousePos::modifiers
Qt::KeyboardModifiers modifiers
The keyboard modifiers (ie. shift, ctrl, alt)
Definition: ceyetrackerfilter.h:50
sMousePos::button
QAbstractButton * button
Pointer to top QAbstractButton under mouse cursor at point. If no button was found it is nullptr...
Definition: ceyetrackerfilter.h:52
sAtomGesture::GENERIC_CLICK
Mouse clicked the value can be passed by cEyeTrackerFilter::eventFilter function. ...
Definition: ceyetrackerfilter.h:73
cXmlIO
Delivers XML file serialisation and deserialisation methods for modules.
Definition: cxmlio.h:22
cComplexGestureEvent
Event class for passing complex gesture events recognized by cEyeTrackerFilter filter.
Definition: ceyetrackerfilter.h:363
boundingBoxInfo::isMonotonicX
int isMonotonicX
0 - the X coordinates were not monotonic in horizontal direction, -1 - monotonically decreasing in ho...
Definition: ceyetrackerfilter.h:95
cGestureDirectoryEntry::eConditionType
eConditionType
The enumerator of additional condition checked when proper atom gestures chain is detected...
Definition: ceyetrackerfilter.h:118
cGestureDirectoryEntry
The class represents single entry describing complex gesture.
Definition: ceyetrackerfilter.h:113
cGestureDirectoryEntry::EQUAL_START_END
The distance between first point and the last point of the complex gesture should be below be lower t...
Definition: ceyetrackerfilter.h:120
sMousePos::point
QPoint point
Cursor position in pixels in main widget coordinates.
Definition: ceyetrackerfilter.h:49
sAtomGesture::H_LINE_RIGHT
Horizontal line was detected.
Definition: ceyetrackerfilter.h:70
common.h
sAtomGesture::GAZE
Gaze event detected.
Definition: ceyetrackerfilter.h:71
boundingBoxInfo::region
QRect region
Bounding box of mouse cursor trace.
Definition: ceyetrackerfilter.h:93
sAtomGesture::H_LINE_LEFT
Horizontal line was detected.
Definition: ceyetrackerfilter.h:69
cEyeTrackerFilter::logSource
logSource
Definition: ceyetrackerfilter.h:335
boundingBoxInfo::delta_t
int64_t delta_t
Trace duration in (ms)
Definition: ceyetrackerfilter.h:94
cGestureDirectoryEntry::cGestureDirectoryEntry
cGestureDirectoryEntry()
The default constructor, should not be used, it sets event ID to -1. IDs<0 are ignored.
Definition: ceyetrackerfilter.h:139
cGestureDirectoryEntry::getBoundingBox
QRect getBoundingBox() const
Gets the bounding box of whole complex gesture trace of the last compared trace.
Definition: ceyetrackerfilter.h:178
cGestureDirectoryEntry::EQUAL_SIZE
All segments (bounding boxes) has to have similar length. The maximum difference has to be lower than...
Definition: ceyetrackerfilter.h:119
sMousePos
The structure represents a point of mouse cursor trace.
Definition: ceyetrackerfilter.h:47
sAtomGesture::EYE_BLINK
Eye blink - not implemented yet.
Definition: ceyetrackerfilter.h:72