Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
leversc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
leversc
Commits
8c501851
Commit
8c501851
authored
Mar 9, 2022
by
ac (tb)
Browse files
Options
Downloads
Patches
Plain Diff
added leversc spinMovie.py
parent
bd0143b1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Python/leversc/spinMovie.py
+68
-0
68 additions, 0 deletions
src/Python/leversc/spinMovie.py
with
68 additions
and
0 deletions
src/Python/leversc/spinMovie.py
0 → 100644
+
68
−
0
View file @
8c501851
"""
Python sample for using the leversc multichannel 3-d viewer to generate a video
mark winter and andrew r. cohen
this script generates an mp4. it was tested on windows, but may work on other platforms.
it relies on scikit-video (pip install scikit-video) and ffmpeg (you must download and install)
"""
import
numpy
as
np
,
matplotlib
.
pyplot
as
plt
from
leversc
import
leversc
import
time
import
skvideo
# note - you must download ffmpeg and enter the path to the bin folder here!
skvideo
.
setFFmpegPath
(
'
C:
\\
Users
\\
ANDYR
\\
git
\\
ffmpeg-master-latest-win64-gpl
\\
bin
'
)
import
skvideo.io
def
setMovieUI
(
lsc
):
"""
setMovieUI(lsc) - sets the ui elements for screen capture
lsc - leversc class instance
"""
# wait for leversc to finish any image render before we set ui
# so all pending ui updates are completed before our changes
while
(
not
lsc1
.
drawComplete
()):
time
.
sleep
(
0.1
)
# pull ui dictionary, modify and then write it back
# this allows us to properly use the property setter, and also allows
# bulk property changes
ui
=
lsc
.
uiParams
ui
[
'
webToolbar
'
]
=
'
none
'
ui
[
'
clockButton
'
]
=
'
none
'
ui
[
'
sidebar
'
]
=
'
none
'
lsc
.
uiParams
=
ui
# show the .LEVER sample image
strDB
=
'
../../sampleImages/lscSampleImage.LEVER
'
(
im
,
CONSTANTS
)
=
leversc
.
readImage
(
strDB
)
lsc1
=
leversc
(
im
=
im
,
imD
=
CONSTANTS
)
# hint - i like to set a breakpoint here in the debugger and adjust the leversc viewer window
# so the aspect ratio and view settings looks right for my movie
pass
# set UI to look better for movie capture
setMovieUI
(
lsc1
)
# hint - you may want to check that your UI windows looks good after turning off the elements
# via setMovieUI
pass
outputFile
=
'
sampleVolume.mp4
'
# set pix_fmt to yuv420p because windows media player has trouble with default mp4 setting
# note - VLC plays the default so if you have trouble, try that
writer
=
skvideo
.
io
.
FFmpegWriter
(
outputFile
,
outputdict
=
{
"
-pix_fmt
"
:
"
yuv420p
"
})
# spin the volume, capturing and writing frames
angles
=
np
.
linspace
(
0
,
np
.
pi
,
50
);
for
theta
in
angles
:
# set the rotation matrix
lsc1
.
viewParams
[
'
worldRot
'
]
=
[
np
.
cos
(
theta
),
0
,
np
.
sin
(
theta
),
0
,
0
,
1
,
0
,
0
,
-
np
.
sin
(
theta
),
0
,
np
.
cos
(
theta
),
0
,
0
,
0
,
0
,
1
]
# alternative rotations / zoom adjustments / etc. as needed
# ...
# now grab image
im
=
lsc1
.
captureImage
()
writer
.
writeFrame
(
im
)
writer
.
close
()
pass
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment