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
e6d9d343
Commit
e6d9d343
authored
Mar 05, 2018
by
Thiago Santini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tries to load default camera if none was available in the config
parent
f5cb85c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
4 deletions
+40
-4
EyeRecToo/src/Camera.cpp
EyeRecToo/src/Camera.cpp
+36
-2
EyeRecToo/src/Camera.h
EyeRecToo/src/Camera.h
+4
-2
No files found.
EyeRecToo/src/Camera.cpp
View file @
e6d9d343
...
...
@@ -23,7 +23,7 @@ Camera::Camera(QString id, QObject *parent)
connect
(
ui
,
SIGNAL
(
setCamera
(
QCameraInfo
)),
this
,
SLOT
(
setCamera
(
QCameraInfo
))
);
connect
(
ui
,
SIGNAL
(
setViewfinderSettings
(
QCameraViewfinderSettings
)),
this
,
SLOT
(
setViewfinderSettings
(
QCameraViewfinderSettings
))
);
connect
(
ui
,
SIGNAL
(
setColorCode
(
int
)),
this
,
SLOT
(
setColorCode
(
int
))
);
settings
=
new
QSettings
(
gCfgDir
+
"/"
+
id
+
" Camera"
,
QSettings
::
IniFormat
);
settings
=
new
QSettings
(
gCfgDir
+
"/"
+
id
+
" Camera"
,
QSettings
::
IniFormat
);
}
Camera
::~
Camera
()
...
...
@@ -257,7 +257,10 @@ void Camera::loadCfg()
set
(
settings
,
"colorCode"
,
colorCode
);
setCamera
(
info
,
viewFinderSetting
);
setCamera
(
info
,
viewFinderSetting
);
if
(
info
.
isNull
()
)
// failed to load something, search for default cameras
searchDefaultCamera
();
}
void
Camera
::
timedout
()
...
...
@@ -285,3 +288,34 @@ void Camera::retry()
QTimer
::
singleShot
(
1000
,
this
,
SLOT
(
retry
()));
}
}
void
Camera
::
searchDefaultCamera
()
{
/* TODO:
* 1) consider searching for the cameras periodically -- e.g., if the
* plugs the eye tracker *after* we are running, nothing will happen.
*
* 2) extend this so the user can add his own default cameras
*/
QRegularExpression
re
;
if
(
id
.
contains
(
"eye"
,
Qt
::
CaseInsensitive
)
)
{
if
(
id
.
contains
(
"right"
,
Qt
::
CaseInsensitive
)
)
re
.
setPattern
(
"Pupil Cam. ID0"
);
if
(
id
.
contains
(
"left"
,
Qt
::
CaseInsensitive
)
)
re
.
setPattern
(
"Pupil Cam. ID1"
);
}
if
(
id
.
contains
(
"field"
,
Qt
::
CaseInsensitive
)
)
re
.
setPattern
(
"Pupil Cam. ID2"
);
QList
<
QCameraInfo
>
cameras
=
QCameraInfo
::
availableCameras
();
for
(
int
i
=
0
;
i
<
cameras
.
size
();
i
++
)
{
if
(
re
.
match
(
cameras
[
i
].
deviceName
()).
hasMatch
())
{
setCamera
(
cameras
[
i
]);
if
(
!
currentCameraInfo
.
isNull
())
return
;
}
}
}
EyeRecToo/src/Camera.h
View file @
e6d9d343
...
...
@@ -12,6 +12,7 @@
#include <QComboBox>
#include <QLabel>
#include <QGridLayout>
#include <QRegularExpression>
#include "opencv/cv.h"
...
...
@@ -170,10 +171,11 @@ private:
int
retriesLeft
;
int
maxRetries
;
static
QMutex
setCameraMutex
;
static
QMutex
setCameraMutex
;
void
searchDefaultCamera
();
private
slots
:
void
reset
();
void
reset
();
};
#endif // CAMERA_H
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