Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thiago Santini
EyeRecToo
Commits
e0749d56
Commit
e0749d56
authored
Dec 17, 2017
by
Thiago Santini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scrolls log on new messages
parent
ea1d372e
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
82 additions
and
73 deletions
+82
-73
EyeRecToo/EyeRecToo.pro
EyeRecToo/EyeRecToo.pro
+3
-3
EyeRecToo/src/CameraWidget.cpp
EyeRecToo/src/CameraWidget.cpp
+12
-6
EyeRecToo/src/DataRecorder.cpp
EyeRecToo/src/DataRecorder.cpp
+1
-1
EyeRecToo/src/EyeImageProcessor.cpp
EyeRecToo/src/EyeImageProcessor.cpp
+3
-4
EyeRecToo/src/EyeImageProcessor.h
EyeRecToo/src/EyeImageProcessor.h
+1
-1
EyeRecToo/src/FieldImageProcessor.cpp
EyeRecToo/src/FieldImageProcessor.cpp
+18
-0
EyeRecToo/src/LogWidget.cpp
EyeRecToo/src/LogWidget.cpp
+2
-1
EyeRecToo/src/LogWidget.h
EyeRecToo/src/LogWidget.h
+1
-0
EyeRecToo/src/MainWindow.cpp
EyeRecToo/src/MainWindow.cpp
+4
-1
EyeRecToo/src/pupil-detection/PupilDetectionMethod.cpp
EyeRecToo/src/pupil-detection/PupilDetectionMethod.cpp
+34
-1
EyeRecToo/src/pupil-detection/PupilDetectionMethod.h
EyeRecToo/src/pupil-detection/PupilDetectionMethod.h
+3
-0
EyeRecToo/src/pupil-tracking/PupiTtrackingMethod.cpp
EyeRecToo/src/pupil-tracking/PupiTtrackingMethod.cpp
+0
-55
No files found.
EyeRecToo/EyeRecToo.pro
View file @
e0749d56
...
@@ -46,7 +46,7 @@ SOURCES +=\
...
@@ -46,7 +46,7 @@ SOURCES +=\
$$
{
TOP
}
/
src
/
CommandManager
.
cpp
\
$$
{
TOP
}
/
src
/
CommandManager
.
cpp
\
$$
{
TOP
}
/
src
/
ERWidget
.
cpp
\
$$
{
TOP
}
/
src
/
ERWidget
.
cpp
\
src
/
pupil
-
tracking
/
PupiTtrackingMethod
.
cpp
\
src
/
pupil
-
tracking
/
PupiTtrackingMethod
.
cpp
\
src
/
pupil
-
tracking
/
PuReT
y
.
cpp
\
src
/
pupil
-
tracking
/
PuRe
S
T
.
cpp
\
src
/
pupil
-
detection
/
PuRe
.
cpp
\
src
/
pupil
-
detection
/
PuRe
.
cpp
\
src
/
Evaluation
.
cpp
src
/
Evaluation
.
cpp
...
@@ -80,9 +80,9 @@ HEADERS += \
...
@@ -80,9 +80,9 @@ HEADERS += \
$$
{
TOP
}
/
src
/
CommandManager
.
h
\
$$
{
TOP
}
/
src
/
CommandManager
.
h
\
$$
{
TOP
}
/
src
/
ERWidget
.
h
\
$$
{
TOP
}
/
src
/
ERWidget
.
h
\
$$
{
TOP
}
/
src
/
pupil
-
tracking
/
PupilTrackingMethod
.
h
\
$$
{
TOP
}
/
src
/
pupil
-
tracking
/
PupilTrackingMethod
.
h
\
src
/
pupil
-
tracking
/
PuReTy
.
h
\
src
/
pupil
-
detection
/
PuRe
.
h
\
src
/
pupil
-
detection
/
PuRe
.
h
\
src
/
Evaluation
.
h
src
/
Evaluation
.
h
\
src
/
pupil
-
tracking
/
PuReST
.
h
FORMS
+=
\
FORMS
+=
\
$$
{
TOP
}
/
src
/
MainWindow
.
ui
\
$$
{
TOP
}
/
src
/
MainWindow
.
ui
\
...
...
EyeRecToo/src/CameraWidget.cpp
View file @
e0749d56
...
@@ -12,7 +12,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
...
@@ -12,7 +12,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
eROI
(
QPoint
(
0
,
0
)),
eROI
(
QPoint
(
0
,
0
)),
settingROI
(
false
),
settingROI
(
false
),
lastUpdate
(
0
),
lastUpdate
(
0
),
updateIntervalMs
(
5
0
),
updateIntervalMs
(
8
0
),
maxAgeMs
(
300
),
maxAgeMs
(
300
),
cameraCalibrationSampleRequested
(
false
),
cameraCalibrationSampleRequested
(
false
),
ui
(
new
Ui
::
CameraWidget
)
ui
(
new
Ui
::
CameraWidget
)
...
@@ -24,7 +24,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
...
@@ -24,7 +24,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
switch
(
type
)
{
switch
(
type
)
{
case
ImageProcessor
::
Eye
:
case
ImageProcessor
::
Eye
:
ui
->
viewFinder
->
setToolTip
(
"You can select a region of interest by clicking and holding the
righ
t mouse button."
);
ui
->
viewFinder
->
setToolTip
(
"You can select a region of interest by clicking and holding the
lef
t mouse button."
);
break
;
break
;
case
ImageProcessor
::
Field
:
case
ImageProcessor
::
Field
:
ui
->
viewFinder
->
setToolTip
(
"After starting the collection you can select points by clicking in this view with the left mouse button."
);
ui
->
viewFinder
->
setToolTip
(
"After starting the collection you can select points by clicking in this view with the left mouse button."
);
...
@@ -123,7 +123,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
...
@@ -123,7 +123,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
imageProcessor
,
SIGNAL
(
newROI
(
QPointF
,
QPointF
))
);
imageProcessor
,
SIGNAL
(
newROI
(
QPointF
,
QPointF
))
);
// Initial roi
// Initial roi
setROI
(
QPointF
(
0
,
0
),
QPointF
(
1
,
1
)
);
setROI
(
QPointF
(
0
.15
,
0
.1
),
QPointF
(
0.85
,
0.9
)
);
QMetaObject
::
invokeMethod
(
camera
,
"loadCfg"
);
QMetaObject
::
invokeMethod
(
camera
,
"loadCfg"
);
}
}
...
@@ -322,10 +322,10 @@ void CameraWidget::stopRecording()
...
@@ -322,10 +322,10 @@ void CameraWidget::stopRecording()
void
CameraWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
void
CameraWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{
{
if
(
ui
->
viewFinder
->
underMouse
())
{
if
(
ui
->
viewFinder
->
underMouse
())
{
if
(
event
->
button
()
==
Qt
::
LeftButton
)
if
(
event
->
button
()
==
Qt
::
LeftButton
&&
type
==
ImageProcessor
::
Field
)
emit
newClick
(
gTimer
.
elapsed
(),
ui
->
viewFinder
->
mapFromGlobal
(
this
->
mapToGlobal
(
event
->
pos
())),
ui
->
viewFinder
->
size
());
emit
newClick
(
gTimer
.
elapsed
(),
ui
->
viewFinder
->
mapFromGlobal
(
this
->
mapToGlobal
(
event
->
pos
())),
ui
->
viewFinder
->
size
());
if
(
event
->
button
()
==
Qt
::
Righ
tButton
)
{
if
(
event
->
button
()
==
Qt
::
Lef
tButton
&&
type
==
ImageProcessor
::
Eye
)
{
sROI
=
ui
->
viewFinder
->
mapFrom
(
this
,
event
->
pos
());
sROI
=
ui
->
viewFinder
->
mapFrom
(
this
,
event
->
pos
());
validatePoint
(
sROI
);
validatePoint
(
sROI
);
sROI
.
setX
(
sROI
.
x
()
/
ui
->
viewFinder
->
width
());
sROI
.
setX
(
sROI
.
x
()
/
ui
->
viewFinder
->
width
());
...
@@ -350,7 +350,7 @@ void CameraWidget::mouseMoveEvent(QMouseEvent *event)
...
@@ -350,7 +350,7 @@ void CameraWidget::mouseMoveEvent(QMouseEvent *event)
void
CameraWidget
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
void
CameraWidget
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
{
if
(
event
->
button
()
==
Qt
::
Righ
tButton
)
{
if
(
event
->
button
()
==
Qt
::
Lef
tButton
&&
type
==
ImageProcessor
::
Eye
)
{
eROI
=
ui
->
viewFinder
->
mapFrom
(
this
,
event
->
pos
());
eROI
=
ui
->
viewFinder
->
mapFrom
(
this
,
event
->
pos
());
validatePoint
(
eROI
);
validatePoint
(
eROI
);
eROI
.
setX
(
eROI
.
x
()
/
ui
->
viewFinder
->
width
());
eROI
.
setX
(
eROI
.
x
()
/
ui
->
viewFinder
->
width
());
...
@@ -471,6 +471,12 @@ void CameraWidget::onCameraCalibrationFinished(bool success)
...
@@ -471,6 +471,12 @@ void CameraWidget::onCameraCalibrationFinished(bool success)
void
CameraWidget
::
updateWidgetSize
(
const
int
&
width
,
const
int
&
height
)
void
CameraWidget
::
updateWidgetSize
(
const
int
&
width
,
const
int
&
height
)
{
{
if
(
this
->
type
==
ImageProcessor
::
Eye
)
this
->
setMaximumSize
(
320
,
240
);
if
(
this
->
type
==
ImageProcessor
::
Field
)
this
->
setMaximumSize
(
640
,
360
);
return
;
// Logic to limit the size of the camera widgets
// Logic to limit the size of the camera widgets
QSize
newFrameSize
=
{
width
,
height
};
QSize
newFrameSize
=
{
width
,
height
};
if
(
frameSize
==
newFrameSize
)
if
(
frameSize
==
newFrameSize
)
...
...
EyeRecToo/src/DataRecorder.cpp
View file @
e0749d56
...
@@ -133,7 +133,7 @@ void DataRecorder::storeData(T &data)
...
@@ -133,7 +133,7 @@ void DataRecorder::storeData(T &data)
videoIdx
++
;
videoIdx
++
;
}
}
if
(
gPerformanceMonitor
.
shouldDrop
(
pmIdx
,
gTimer
.
elapsed
()
-
data
.
timestamp
,
1
000
)
)
if
(
gPerformanceMonitor
.
shouldDrop
(
pmIdx
,
gTimer
.
elapsed
()
-
data
.
timestamp
,
2
000
)
)
return
;
return
;
if
(
videoWriter
->
isOpened
())
if
(
videoWriter
->
isOpened
())
...
...
EyeRecToo/src/EyeImageProcessor.cpp
View file @
e0749d56
...
@@ -27,7 +27,7 @@ EyeImageProcessor::EyeImageProcessor(QString id, QObject *parent)
...
@@ -27,7 +27,7 @@ EyeImageProcessor::EyeImageProcessor(QString id, QObject *parent)
pmIdx
=
gPerformanceMonitor
.
enrol
(
id
,
"Image Processor"
);
pmIdx
=
gPerformanceMonitor
.
enrol
(
id
,
"Image Processor"
);
pupilTrackingMethod
=
new
PuReT
y
();
pupilTrackingMethod
=
new
PuRe
S
T
();
}
}
void
EyeImageProcessor
::
updateConfig
()
void
EyeImageProcessor
::
updateConfig
()
...
@@ -54,8 +54,8 @@ EyeImageProcessor::~EyeImageProcessor()
...
@@ -54,8 +54,8 @@ EyeImageProcessor::~EyeImageProcessor()
void
EyeImageProcessor
::
process
(
Timestamp
timestamp
,
const
Mat
&
frame
)
void
EyeImageProcessor
::
process
(
Timestamp
timestamp
,
const
Mat
&
frame
)
{
{
// TODO: parametrize frame drop due to lack of processing power
// TODO: parametrize frame drop due to lack of processing power
//
if ( gPerformanceMonitor.shouldDrop(pmIdx, gTimer.elapsed() - timestamp, 50) )
if
(
gPerformanceMonitor
.
shouldDrop
(
pmIdx
,
gTimer
.
elapsed
()
-
timestamp
,
50
)
)
//
return;
return
;
QMutexLocker
locker
(
&
cfgMutex
);
QMutexLocker
locker
(
&
cfgMutex
);
...
@@ -79,7 +79,6 @@ void EyeImageProcessor::process(Timestamp timestamp, const Mat &frame)
...
@@ -79,7 +79,6 @@ void EyeImageProcessor::process(Timestamp timestamp, const Mat &frame)
data
.
pupil
=
Pupil
();
data
.
pupil
=
Pupil
();
data
.
validPupil
=
false
;
data
.
validPupil
=
false
;
if
(
pupilDetectionMethod
!=
NULL
)
{
if
(
pupilDetectionMethod
!=
NULL
)
{
Rect
userROI
=
Rect
(
Rect
userROI
=
Rect
(
Point
(
sROI
.
x
()
*
data
.
input
.
cols
,
sROI
.
y
()
*
data
.
input
.
rows
),
Point
(
sROI
.
x
()
*
data
.
input
.
cols
,
sROI
.
y
()
*
data
.
input
.
rows
),
Point
(
eROI
.
x
()
*
data
.
input
.
cols
,
eROI
.
y
()
*
data
.
input
.
rows
)
Point
(
eROI
.
x
()
*
data
.
input
.
cols
,
eROI
.
y
()
*
data
.
input
.
rows
)
...
...
EyeRecToo/src/EyeImageProcessor.h
View file @
e0749d56
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#endif
#endif
#include "pupil-detection/PupilDetectionMethod.h"
#include "pupil-detection/PupilDetectionMethod.h"
#include "pupil-tracking/PuReT
y
.h"
#include "pupil-tracking/PuRe
S
T.h"
#include "pupil-tracking/PupilTrackingMethod.h"
#include "pupil-tracking/PupilTrackingMethod.h"
#include "utils.h"
#include "utils.h"
...
...
EyeRecToo/src/FieldImageProcessor.cpp
View file @
e0749d56
...
@@ -7,6 +7,9 @@ using namespace aruco;
...
@@ -7,6 +7,9 @@ using namespace aruco;
static
int
gFieldDataId
=
qRegisterMetaType
<
FieldData
>
(
"FieldData"
);
static
int
gFieldDataId
=
qRegisterMetaType
<
FieldData
>
(
"FieldData"
);
static
int
markerDetectionCounter
=
0
;
static
int
redetectMarkerCounter
=
1
;
FieldImageProcessor
::
FieldImageProcessor
(
QString
id
,
QObject
*
parent
)
FieldImageProcessor
::
FieldImageProcessor
(
QString
id
,
QObject
*
parent
)
:
id
(
id
),
:
id
(
id
),
sROI
(
QPointF
(
0
,
0
)),
sROI
(
QPointF
(
0
,
0
)),
...
@@ -91,6 +94,20 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
...
@@ -91,6 +94,20 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
}
}
if
(
cfg
.
markerDetectionMethod
==
"aruco"
||
gCalibrating
)
{
if
(
cfg
.
markerDetectionMethod
==
"aruco"
||
gCalibrating
)
{
#define LIMIT_MARKER_DETECTION
#ifdef LIMIT_MARKER_DETECTION
if
(
markerDetectionCounter
==
redetectMarkerCounter
)
{
detectMarkers
(
downscaled
,
dict
,
corners
,
ids
,
detectorParameters
);
if
(
cfg
.
processingDownscalingFactor
>
1
)
{
// Upscale if necessary
for
(
unsigned
int
i
=
0
;
i
<
ids
.
size
();
i
++
)
for
(
unsigned
int
j
=
0
;
j
<
corners
[
i
].
size
();
j
++
)
corners
[
i
][
j
]
=
cfg
.
processingDownscalingFactor
*
corners
[
i
][
j
];
}
markerDetectionCounter
=
0
;
}
else
markerDetectionCounter
++
;
#else
detectMarkers
(
downscaled
,
dict
,
corners
,
ids
,
detectorParameters
);
detectMarkers
(
downscaled
,
dict
,
corners
,
ids
,
detectorParameters
);
if
(
cfg
.
processingDownscalingFactor
>
1
)
{
// Upscale if necessary
if
(
cfg
.
processingDownscalingFactor
>
1
)
{
// Upscale if necessary
...
@@ -98,6 +115,7 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
...
@@ -98,6 +115,7 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
for
(
unsigned
int
j
=
0
;
j
<
corners
[
i
].
size
();
j
++
)
for
(
unsigned
int
j
=
0
;
j
<
corners
[
i
].
size
();
j
++
)
corners
[
i
][
j
]
=
cfg
.
processingDownscalingFactor
*
corners
[
i
][
j
];
corners
[
i
][
j
]
=
cfg
.
processingDownscalingFactor
*
corners
[
i
][
j
];
}
}
#endif
}
}
// Filling the marker data
// Filling the marker data
...
...
EyeRecToo/src/LogWidget.cpp
View file @
e0749d56
...
@@ -18,7 +18,8 @@ LogWidget::~LogWidget()
...
@@ -18,7 +18,8 @@ LogWidget::~LogWidget()
void
LogWidget
::
appendMessage
(
const
QString
&
msg
)
void
LogWidget
::
appendMessage
(
const
QString
&
msg
)
{
{
ui
->
log
->
appendPlainText
(
msg
.
trimmed
());
ui
->
log
->
appendPlainText
(
msg
.
trimmed
()
);
ui
->
log
->
verticalScrollBar
()
->
setValue
(
ui
->
log
->
verticalScrollBar
()
->
maximum
()
);
}
}
void
LogWidget
::
on_usrMsg_returnPressed
()
void
LogWidget
::
on_usrMsg_returnPressed
()
...
...
EyeRecToo/src/LogWidget.h
View file @
e0749d56
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <QMainWindow>
#include <QMainWindow>
#include <QKeyEvent>
#include <QKeyEvent>
#include <QScrollBar>
#include <QDebug>
#include <QDebug>
#include "ERWidget.h"
#include "ERWidget.h"
...
...
EyeRecToo/src/MainWindow.cpp
View file @
e0749d56
...
@@ -46,7 +46,9 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -46,7 +46,9 @@ MainWindow::MainWindow(QWidget *parent) :
* properly by CoInitializing it in the main thread.
* properly by CoInitializing it in the main thread.
*/
*/
volatile
QList
<
QCameraInfo
>
tmp
=
QCameraInfo
::
availableCameras
();
volatile
QList
<
QCameraInfo
>
tmp
=
QCameraInfo
::
availableCameras
();
Q_UNUSED
(
tmp
);
Q_UNUSED
(
tmp
);
gPerformanceMonitor
.
setFrameDrop
(
true
);
/*
/*
* Asynchronous elements
* Asynchronous elements
...
@@ -142,6 +144,7 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -142,6 +144,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect
(
&
commandManager
,
SIGNAL
(
unfreezeCameraImages
()),
connect
(
&
commandManager
,
SIGNAL
(
unfreezeCameraImages
()),
this
,
SLOT
(
unfreezeCameraImages
())
);
this
,
SLOT
(
unfreezeCameraImages
())
);
#else
#else
gPerformanceMonitor
.
setFrameDrop
(
false
);
evaluation
=
new
Evaluation
();
evaluation
=
new
Evaluation
();
evaluation
->
show
();
evaluation
->
show
();
QMetaObject
::
invokeMethod
(
evaluation
,
"run"
,
Qt
::
QueuedConnection
);
QMetaObject
::
invokeMethod
(
evaluation
,
"run"
,
Qt
::
QueuedConnection
);
...
...
EyeRecToo/src/pupil-detection/PupilDetectionMethod.cpp
View file @
e0749d56
...
@@ -12,7 +12,7 @@ Rect PupilDetectionMethod::coarsePupilDetection(const Mat &frame, const float &m
...
@@ -12,7 +12,7 @@ Rect PupilDetectionMethod::coarsePupilDetection(const Mat &frame, const float &m
// We can afford to work on a very small input for haar features, but retain the aspect ratio
// We can afford to work on a very small input for haar features, but retain the aspect ratio
float
xr
=
frame
.
cols
/
(
float
)
workingWidth
;
float
xr
=
frame
.
cols
/
(
float
)
workingWidth
;
float
yr
=
frame
.
rows
/
(
float
)
workingHeight
;
float
yr
=
frame
.
rows
/
(
float
)
workingHeight
;
float
r
=
m
in
(
xr
,
yr
);
float
r
=
m
ax
(
xr
,
yr
);
Mat
downscaled
;
Mat
downscaled
;
resize
(
frame
,
downscaled
,
Size
(),
1
/
r
,
1
/
r
,
CV_INTER_LINEAR
);
resize
(
frame
,
downscaled
,
Size
(),
1
/
r
,
1
/
r
,
CV_INTER_LINEAR
);
...
@@ -405,6 +405,38 @@ float PupilDetectionMethod::outlineContrastConfidence(const Mat &frame, const Pu
...
@@ -405,6 +405,38 @@ float PupilDetectionMethod::outlineContrastConfidence(const Mat &frame, const Pu
return
validCount
/
(
float
)
evaluated
;
return
validCount
/
(
float
)
evaluated
;
}
}
float
PupilDetectionMethod
::
angularSpreadConfidence
(
const
vector
<
Point
>
&
points
,
const
Point2f
&
center
)
{
enum
{
Q0
=
0
,
Q1
=
1
,
Q2
=
2
,
Q3
=
3
,
};
std
::
bitset
<
4
>
anchorPointSlices
;
anchorPointSlices
.
reset
();
for
(
auto
p
=
points
.
begin
();
p
!=
points
.
end
();
p
++
)
{
if
(
p
->
x
-
center
.
x
<
0
)
{
if
(
p
->
y
-
center
.
y
<
0
)
anchorPointSlices
.
set
(
Q0
);
else
anchorPointSlices
.
set
(
Q3
);
}
else
{
if
(
p
->
y
-
center
.
y
<
0
)
anchorPointSlices
.
set
(
Q1
);
else
anchorPointSlices
.
set
(
Q2
);
}
}
return
anchorPointSlices
.
count
()
/
(
float
)
anchorPointSlices
.
size
();
}
float
PupilDetectionMethod
::
aspectRatioConfidence
(
const
Pupil
&
pupil
)
{
return
pupil
.
minorAxis
()
/
(
float
)
pupil
.
majorAxis
();
}
float
PupilDetectionMethod
::
edgeRatioConfidence
(
const
Mat
&
edgeImage
,
const
Pupil
&
pupil
,
vector
<
Point
>
&
edgePoints
,
const
int
&
band
)
float
PupilDetectionMethod
::
edgeRatioConfidence
(
const
Mat
&
edgeImage
,
const
Pupil
&
pupil
,
vector
<
Point
>
&
edgePoints
,
const
int
&
band
)
{
{
if
(
!
pupil
.
valid
())
if
(
!
pupil
.
valid
())
...
@@ -416,3 +448,4 @@ float PupilDetectionMethod::edgeRatioConfidence(const Mat &edgeImage, const Pupi
...
@@ -416,3 +448,4 @@ float PupilDetectionMethod::edgeRatioConfidence(const Mat &edgeImage, const Pupi
findNonZero
(
inBandEdges
,
edgePoints
);
findNonZero
(
inBandEdges
,
edgePoints
);
return
min
<
float
>
(
edgePoints
.
size
()
/
pupil
.
circumference
(),
1.0
);
return
min
<
float
>
(
edgePoints
.
size
()
/
pupil
.
circumference
(),
1.0
);
}
}
EyeRecToo/src/pupil-detection/PupilDetectionMethod.h
View file @
e0749d56
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include <string>
#include <string>
#include <deque>
#include <deque>
#include <bitset>
#include <opencv2/core.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc.hpp>
...
@@ -108,6 +109,8 @@ public:
...
@@ -108,6 +109,8 @@ public:
// Generic confidence metrics
// Generic confidence metrics
static
float
outlineContrastConfidence
(
const
cv
::
Mat
&
frame
,
const
Pupil
&
pupil
,
const
int
&
bias
=
5
);
static
float
outlineContrastConfidence
(
const
cv
::
Mat
&
frame
,
const
Pupil
&
pupil
,
const
int
&
bias
=
5
);
static
float
edgeRatioConfidence
(
const
cv
::
Mat
&
edgeImage
,
const
Pupil
&
pupil
,
std
::
vector
<
cv
::
Point
>
&
edgePoints
,
const
int
&
band
=
5
);
static
float
edgeRatioConfidence
(
const
cv
::
Mat
&
edgeImage
,
const
Pupil
&
pupil
,
std
::
vector
<
cv
::
Point
>
&
edgePoints
,
const
int
&
band
=
5
);
static
float
angularSpreadConfidence
(
const
std
::
vector
<
cv
::
Point
>
&
points
,
const
cv
::
Point2f
&
center
);
static
float
aspectRatioConfidence
(
const
Pupil
&
pupil
);
//Pupil test(const cv::Mat &frame, const cv::Rect &roi, Pupil pupil) { return pupil; }
//Pupil test(const cv::Mat &frame, const cv::Rect &roi, Pupil pupil) { return pupil; }
protected:
protected:
...
...
EyeRecToo/src/pupil-tracking/PupiTtrackingMethod.cpp
View file @
e0749d56
...
@@ -64,7 +64,6 @@ void PupilTrackingMethod::run(const Timestamp &ts, const cv::Mat &frame, const c
...
@@ -64,7 +64,6 @@ void PupilTrackingMethod::run(const Timestamp &ts, const cv::Mat &frame, const c
predictMaxPupilDiameter
();
predictMaxPupilDiameter
();
if
(
previousPupil
.
confidence
==
NO_CONFIDENCE
)
{
if
(
previousPupil
.
confidence
==
NO_CONFIDENCE
)
{
//pupil = pupilDetectionMethod.runWithConfidence(frame, roi, -1, predictedMaxPupilDiameter);
pupil
=
pupilDetectionMethod
.
runWithConfidence
(
frame
,
roi
,
-
1
,
-
1
);
pupil
=
pupilDetectionMethod
.
runWithConfidence
(
frame
,
roi
,
-
1
,
-
1
);
}
else
{
}
else
{
run
(
frame
,
roi
,
previousPupil
,
pupil
);
run
(
frame
,
roi
,
previousPupil
,
pupil
);
...
@@ -72,58 +71,4 @@ void PupilTrackingMethod::run(const Timestamp &ts, const cv::Mat &frame, const c
...
@@ -72,58 +71,4 @@ void PupilTrackingMethod::run(const Timestamp &ts, const cv::Mat &frame, const c
registerPupil
(
ts
,
pupil
);
registerPupil
(
ts
,
pupil
);
return
;
return
;
/*
int minPupilDiameterPx = -1;
int maxPupilDiameterPx = -1;
if ( ! previousPupils.empty() ) {
float meanDiameterPx = std::accumulate( previousPupils.begin(), previousPupils.end(), 0,
[](int sum, const TrackedPupil &p) { return sum + max<int>( p.size.width, p.size.height ); } ) / (float) previousPupils.size();
minPupilDiameterPx = 0.75 * meanDiameterPx;
maxPupilDiameterPx = 1.25 * meanDiameterPx;
}
if ( previousPupil.confidence == NO_CONFIDENCE ) {
pupil = pupilDetectionMethod.runWithConfidence(frame, roi, minPupilDiameterPx, maxPupilDiameterPx);
if (previousPupils.size() > 15) {
if (pupil.diameter() <= maxPupilDiameterPx)
updatePreviousPupil(ts, pupil);
else
pupil.clear();
} else
updatePreviousPupil(ts, pupil);
return;
}
QFuture<Pupil> future;
if (ts - lastDetection > maxTrackingWithoutDetectionTime) {
float previousDiameter = max<float>( previousPupil.size.width, previousPupil.size.height );
future = QtConcurrent::run(&pupilDetectionMethod, &PupilDetectionMethod::runWithConfidence, frame, roi, 0.9*previousDiameter, 1.1*previousDiameter);
parallelDetection = true;
}
run(frame, roi, previousPupil, pupil);
if (parallelDetection) {
parallelDetection = false;
lastDetection = ts;
Pupil detectedPupil = future.result();
if (detectedPupil.confidence > pupil.confidence)
pupil = detectedPupil;
} else {
if ( pupil.confidence < minDetectionConfidence)
pupil = pupilDetectionMethod.runWithConfidence(frame, roi);
}
if ( pupil.confidence > minDetectionConfidence) {
if (previousPupils.size() > 15) {
if (pupil.diameter() <= maxPupilDiameterPx)
updatePreviousPupil(ts, pupil);
else
pupil.clear();
} else
updatePreviousPupil(ts, pupil);
}
*/
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment