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
468a4a11
Commit
468a4a11
authored
Apr 30, 2018
by
Thiago Santini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves feedback when timing out
parent
875928b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
13 deletions
+30
-13
EyeRecToo/src/Camera.cpp
EyeRecToo/src/Camera.cpp
+22
-13
EyeRecToo/src/Camera.h
EyeRecToo/src/Camera.h
+8
-0
No files found.
EyeRecToo/src/Camera.cpp
View file @
468a4a11
...
...
@@ -140,10 +140,10 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
{
QMutexLocker
setCameraLocker
(
&
setCameraMutex
);
reset
();
reset
();
QList
<
QCameraViewfinderSettings
>
settingsList
;
QString
msg
=
"No camera selected"
;
QString
msg
=
"No camera selected"
;
QList
<
QCameraViewfinderSettings
>
settingsList
;
if
(
cameraInfo
.
isNull
())
{
currentCameraInfo
=
QCameraInfo
();
currentViewfinderSettings
=
QCameraViewfinderSettings
();
...
...
@@ -343,7 +343,8 @@ void Camera::timedout()
{
qWarning
()
<<
id
<<
"timedout; reopening..."
;
retriesLeft
--
;
// initialize the countdown
retry
();
reset
();
retry
();
}
void
Camera
::
retry
()
...
...
@@ -354,15 +355,23 @@ void Camera::retry()
currentCameraInfo
=
QCameraInfo
();
currentViewfinderSettings
=
QCameraViewfinderSettings
();
if
(
retriesLeft
<
maxRetries
&&
retriesLeft
>=
0
)
{
setCamera
(
cameraInfo
,
viewfinderSettings
);
if
(
!
currentCameraInfo
.
isNull
())
return
;
currentCameraInfo
=
cameraInfo
;
currentViewfinderSettings
=
viewfinderSettings
;
retriesLeft
--
;
QTimer
::
singleShot
(
1000
,
this
,
SLOT
(
retry
()));
}
if
(
retriesLeft
<
maxRetries
&&
retriesLeft
>=
0
)
{
if
(
isAvailable
(
cameraInfo
))
setCamera
(
cameraInfo
,
viewfinderSettings
);
if
(
!
currentCameraInfo
.
isNull
())
return
;
currentCameraInfo
=
cameraInfo
;
currentViewfinderSettings
=
viewfinderSettings
;
retriesLeft
--
;
QTimer
::
singleShot
(
1000
,
this
,
SLOT
(
retry
()));
}
QString
msg
=
QString
(
"%1: "
).
arg
(
cameraInfo
.
deviceName
());
if
(
retriesLeft
<
0
)
msg
.
append
(
"lost."
);
else
msg
.
append
(
QString
(
"reopening (%1/%2) ..."
).
arg
(
maxRetries
-
retriesLeft
).
arg
(
maxRetries
));
emit
noCamera
(
msg
);
}
void
Camera
::
searchDefaultCamera
()
...
...
EyeRecToo/src/Camera.h
View file @
468a4a11
...
...
@@ -278,6 +278,14 @@ private:
static
QMutex
setCameraMutex
;
void
searchDefaultCamera
();
bool
isAvailable
(
const
QCameraInfo
&
cameraInfo
)
{
QList
<
QCameraInfo
>
cameras
=
QCameraInfo
::
availableCameras
();
for
(
auto
c
=
cameras
.
begin
();
c
!=
cameras
.
end
();
c
++
)
{
if
(
c
->
description
()
==
cameraInfo
.
description
()
&&
c
->
deviceName
()
==
cameraInfo
.
deviceName
())
return
true
;
}
return
false
;
}
QString
makeSettingsFileName
()
{
return
QString
(
"%1/cfg/camera-parameters/%2.ini"
).
arg
(
QCoreApplication
::
applicationDirPath
()).
arg
(
currentCameraInfo
.
deviceName
());
}
bool
loadCameraParameter
(
const
QSettings
&
settings
,
const
QString
&
parameter
,
double
&
value
)
...
...
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