Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Babyfut
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PR-Baby-A18
Babyfut
Commits
f03412e5
Commit
f03412e5
authored
Dec 13, 2018
by
Antoine Lima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug when no picam detected
parent
66c779b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
core/replay.py
core/replay.py
+15
-6
No files found.
core/replay.py
View file @
f03412e5
...
...
@@ -3,7 +3,7 @@
"""
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""
import
subprocess
from
threading
import
Thread
,
Event
from
Babyfut.babyfut
import
getContent
,
ON_RASP
...
...
@@ -17,12 +17,15 @@ class Replay(Thread):
Thread
.
__init__
(
self
)
self
.
replayPath
=
getContent
(
'Replay {}.mp4'
.
format
(
side
.
name
))
self
.
shutdown
=
False
if
ON_RASP
:
self
.
camera_detected
=
Replay
.
detectCam
()
self
.
start_flag
=
Event
()
self
.
stop_flag
=
Event
()
self
.
stopped_flag
=
Event
()
if
ON_RASP
:
if
self
.
isCamAvailable
()
:
self
.
cam
=
picamera
.
PiCamera
()
self
.
cam
.
resolution
=
Settings
[
'picam.resolution'
]
self
.
cam
.
framerate
=
Settings
[
'picam.fps'
]
...
...
@@ -31,11 +34,11 @@ class Replay(Thread):
self
.
stream
=
picamera
.
PiCameraCircularIO
(
self
.
cam
,
seconds
=
Settings
[
'replay.duration'
])
def
start_recording
(
self
):
if
ON_RASP
:
if
self
.
isCamAvailable
()
:
self
.
start_flag
.
set
()
def
stop_recording
(
self
):
if
ON_RASP
:
if
self
.
isCamAvailable
()
:
self
.
stop_flag
.
set
()
self
.
stopped_flag
.
wait
()
...
...
@@ -77,5 +80,11 @@ class Replay(Thread):
return
getContent
(
'Replay Left.mp4'
)
@
staticmethod
def
isCamAvailable
():
return
ON_RASP
# and other checks (ToDo)
def
detectCam
():
camdet
=
subprocess
.
check_output
([
"vcgencmd"
,
"get_camera"
])
return
int
(
chr
(
camdet
[
-
2
]))
@
staticmethod
def
isCamAvailable
(
self
=
None
):
detected
=
self
.
camera_detected
if
self
!=
None
else
Replay
.
detectCam
()
return
ON_RASP
and
detected
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