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
d2dfdd6f
Commit
d2dfdd6f
authored
Oct 24, 2018
by
Antoine Lima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a PiCam bug when it wasn't on the pi
parent
1776ccaa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
17 deletions
+31
-17
main.py
main.py
+7
-0
modules/game.py
modules/game.py
+12
-5
replay.py
replay.py
+12
-12
No files found.
main.py
View file @
d2dfdd6f
...
...
@@ -121,3 +121,10 @@ if __name__=='__main__':
#threadArduinoRight.stop()
threadArduinoLeft
.
join
()
#threadArduinoRight.join()
if
ReplayThread
.
isCamAvailable
():
threadReplay
=
ReplayThread
(
Side
.
Left
)
threadReplay
.
start
()
myapp
.
dispatchMessage
({
'replayThread'
:
threadReplay
},
toType
=
GameModule
)
if
ReplayThread
.
isCamAvailable
():
threadReplay
.
stop
()
threadReplay
.
join
()
modules/game.py
View file @
d2dfdd6f
...
...
@@ -56,6 +56,8 @@ class GameModule(Module):
# Button connections
self
.
ui
.
btnScore1
.
clicked
.
connect
(
lambda
:
self
.
goal
(
Side
.
Left
))
self
.
ui
.
btnScore2
.
clicked
.
connect
(
lambda
:
self
.
goal
(
Side
.
Right
))
self
.
replayer
=
None
def
load
(
self
):
logging
.
debug
(
'Loading GameModule'
)
...
...
@@ -65,7 +67,8 @@ class GameModule(Module):
self
.
ui
.
lcdChrono
.
display
(
QTime
(
0
,
0
).
toString
(
"hh:mm:ss"
))
self
.
showingReplay
=
False
self
.
replayer
.
start_recording
()
if
self
.
replayer
:
self
.
replayer
.
start_recording
()
self
.
gameoverChecker
=
GameOverChecker
(
'score'
,
10
)
if
all
([
len
(
val
)
==
0
for
val
in
self
.
players
.
values
()]):
...
...
@@ -79,7 +82,8 @@ class GameModule(Module):
logging
.
debug
(
'Unloading GameModule'
)
del
self
.
gameStartTime
self
.
timerUpdateChrono
.
stop
()
self
.
replayer
.
stop_recording
()
if
self
.
replayer
:
self
.
replayer
.
stop_recording
()
def
other
(
self
,
**
kwargs
):
logging
.
debug
(
'Other GameModule'
)
...
...
@@ -139,9 +143,11 @@ class GameModule(Module):
# Show replay
# May require `sudo apt-get install qtmultimedia5-examples` in order to install the right libraries
replayFile
=
self
.
replayer
.
stop_recording
()
if
self
.
replayer
:
replayFile
=
self
.
replayer
.
stop_recording
()
if
not
(
Settings
[
'replay.show'
]
and
os
.
path
.
exists
(
replayFile
)):
if
not
(
self
.
replayer
and
Settings
[
'replay.show'
]
and
os
.
path
.
exists
(
replayFile
)):
self
.
updateScores
()
else
:
self
.
showingReplay
=
True
...
...
@@ -158,7 +164,8 @@ class GameModule(Module):
self
.
ui
.
videoWidget
.
setFullScreen
(
False
);
self
.
showingReplay
=
False
self
.
updateScores
()
self
.
replayer
.
start_recording
()
if
self
.
replayer
:
self
.
replayer
.
start_recording
()
def
handleCancel
(
self
):
self
.
switchModule
(
modules
.
MenuModule
)
...
...
replay.py
View file @
d2dfdd6f
...
...
@@ -23,16 +23,18 @@ class Replay(Thread):
self
.
replayPath
=
MainWin
.
getContent
(
'Replay {}.mp4'
.
format
(
side
.
name
))
self
.
shutdown
=
False
self
.
cam
=
picamera
.
PiCamera
()
self
.
cam
.
resolution
=
Settings
[
'picam.resolution'
]
self
.
cam
.
framerate
=
Settings
[
'picam.fps'
]
self
.
cam
.
hflip
=
Settings
[
'picam.hflip'
]
self
.
cam
.
vflip
=
Settings
[
'picam.vflip'
]
self
.
stream
=
picamera
.
PiCameraCircularIO
(
self
.
cam
,
seconds
=
Settings
[
'replay.duration'
])
self
.
start_flag
=
Event
()
self
.
stop_flag
=
Event
()
self
.
stopped_flag
=
Event
()
if
onRasp
:
self
.
cam
=
picamera
.
PiCamera
()
self
.
cam
.
resolution
=
Settings
[
'picam.resolution'
]
self
.
cam
.
framerate
=
Settings
[
'picam.fps'
]
self
.
cam
.
hflip
=
Settings
[
'picam.hflip'
]
self
.
cam
.
vflip
=
Settings
[
'picam.vflip'
]
self
.
stream
=
picamera
.
PiCameraCircularIO
(
self
.
cam
,
seconds
=
Settings
[
'replay.duration'
])
def
start_recording
(
self
):
if
onRasp
:
self
.
start_flag
.
set
()
...
...
@@ -54,17 +56,13 @@ class Replay(Thread):
def
run
(
self
):
while
not
self
.
shutdown
:
print
(
'1'
)
self
.
start_flag
.
wait
()
print
(
'2'
)
if
not
self
.
shutdown
:
print
(
'3'
)
self
.
cam
.
start_recording
(
self
.
stream
,
Settings
[
'picam.format'
])
try
:
while
not
self
.
stop_flag
.
is_set
():
self
.
cam
.
wait_recording
(
1
)
print
(
'4'
)
finally
:
self
.
cam
.
stop_recording
()
...
...
@@ -72,8 +70,10 @@ class Replay(Thread):
self
.
stream
.
copy_to
(
self
.
replayPath
)
self
.
stream
.
clear
()
self
.
stopped_flag
.
set
()
print
(
'5'
)
self
.
cam
.
close
()
self
.
stream
.
close
()
print
(
'6'
)
\ No newline at end of file
@
staticmethod
def
isCamAvailable
():
return
onRasp
# and other checks (ToDo)
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