-
Notifications
You must be signed in to change notification settings - Fork 0
/
Blinker.h
163 lines (134 loc) · 4.01 KB
/
Blinker.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include "stdafx.h"
#include <iostream>
using namespace std;
/************************************************************************
Technische Univeristaet Wien -
188.469 Visual Analysis of Human Motion (LU 1,0) 2009W
Project: Real Time Eye Tracking and Blink Detection with USB Cameras
Team: Matej Nezveda
Agnieszka Wojdecka
************************************************************************/
#include <string>
#include <algorithm>
#include <sstream>
#include <stdexcept>
// OpenCV
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
// include
#include "CWindow.h"
#include "CWebcam.h"
#include "CDetection.h"
// FLTK
#include <FL/Fl.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Button.H>
#include <FL/fl_ask.H>
/************************************************************
* Diese Klasse ermöglicht das Extrahieren von Kopf- und
* Augenbereich in einem Video zum Detektieren eines Augen-
* blinzen. Wird ein Blinzeln erkannt, wird ein Aktion - in
* diesem Fall das Schiessen eines Fotos - ausgelöst.
* Für die Anwendung ist der Anschluss an eine Webcam notwendig.
*
* version: 0.1
* autor: Agnieszka Wojdecka
* e-mail: a0501682@unet.univie.ac.at
**************************************************************/
class Blinker:public Fl_Double_Window{
public:
/*
Constructor. Defaultwerte fuer Breite, 700, Hoehe, 400, Titel "Blinker".
*/
Blinker(int, int, const char*);
/*
Destructor.
*/
~Blinker();
/*
Diese Methode erzeugt die Fensterapplikation.
*/
void creatWin();
protected:
private:
/*
Uebersteigt der Inhalt die Dimensionen des Fensters,
wird das ordnungsgerechte Betrachten des Inhalts ueber
Scroll-Balken ermoeglich.
*/
Fl_Scroll* scroll;
Fl_Scroll* scroll_snapshot;
/*
Button, dessen Druecken einen Verbindungsaufbau zu einer
bestehenden Webcam ausloest.
*/
Fl_Button* cam_opener;
/*
Container fuer die Wiedergabe des Videomaterials.
Ist eingebettet in scroll.
*/
CWindow* win_frame;
CWindow* win_snapshot;
/*
Speichert bei Wiedergabe des Videos Bild fuer Bild.
*/
IplImage* img_frame;
IplImage* img_snapshot;
/*
Ermoeglicht den Verbindugnsaufbau und das Zugreifen auf Daten einer Webcam.
*/
CWebcam cap;
/*
Dieses Flag wird auf true gesetzt, wenn eine Verbindung
zu einer Webcam aufgebaut werden konnte, und ueber diese
Frames ausgespielt werden koennen.
*/
bool flag_play;
CDetection* detection;
/*
Bei bestehendem Verbindungsaufbau zur Webcam und Ausspielen von Videodaten wird ueber
die Callbackmethode openCam_CB Videomaterial im Container scroll ausgegeben.
*/
void openCam();
/*
Callbackmethode fuer den Verbindungsaufbau zur Webcam und Ausspielen der Videodaten
wird von openCam aufgerufen. Knopft cam_opener wird deaktiviert.
*/
void openCam_CB();
/*
Statische Methode, die den Aufruf fuer einen Timeout Callback
der Callback-Methode play_CB ermoeglicht.
*/
static void play_CB_stat(void*);
/*
Wird alle 0.01 Sekunden aufgerufen um ein neues Bild des Videostroms
zu holen und auszugeben.
*/
void play_CB();
typedef struct BlinkerUser{
IplImage* img;
CvHistogram* hist;
BlinkerUser( IplImage* i = (IplImage*)0, CvHistogram* h = (CvHistogram*)0 ) {
int hdims = 16; /* TODO: make that static in CDetection */
float hranges_arr[2] = {0,180};
float * hranges = hranges_arr;
img = cvCreateImage( cvGetSize(i), i->depth, i->nChannels );
cvCopyImage(i,img);
hist = cvCreateHist( 1, &hdims,
CV_HIST_ARRAY,
&hranges, 1 );
cvCopyHist(h,&hist);
}
/*~BlinkerUser() {
if(img)cvReleaseImage(&img);
if(hist)cvReleaseHist(&hist);
}*/
};
vector<BlinkerUser> user;
int isNewUser( IplImage* );
};