Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shutter_speed/wait before capture in record. #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pptk/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import inspect
import warnings
import time

_viewer_dir = os.path.dirname(inspect.getfile(inspect.currentframe()))
if ~os.path.isabs(_viewer_dir):
Expand Down Expand Up @@ -341,7 +342,7 @@ def play(self, poses, ts=[], tlim=[-numpy.inf, numpy.inf], repeat=False,
self.__send(msg)

def record(self, folder, poses, ts=[], tlim=[-numpy.inf, numpy.inf],
interp='cubic_natural', shutter_speed=numpy.inf, fps=24,
interp='cubic_natural', shutter_speed=None, fps=24,
prefix='frame_', ext='png'):
"""

Expand All @@ -354,6 +355,7 @@ def record(self, folder, poses, ts=[], tlim=[-numpy.inf, numpy.inf],
ts: Same as in :meth:`pptk.viewer.play`
tlim: Same as in :meth:`pptk.viewer.play`
interp: Same as in :meth:`pptk.viewer.play`
shutter_speed (optional): Time before capturing
fps: Frames per second
prefix: Resulting image file names are prefixed with this string
ext: Image format
Expand Down Expand Up @@ -398,6 +400,9 @@ def record(self, folder, poses, ts=[], tlim=[-numpy.inf, numpy.inf],
struct.pack('2f', t, t) + \
struct.pack('?', False)
self.__send(msg)
# give viewer time to finish rendering
if shutter_speed is not None:
time.sleep(shutter_speed)
filename = prefix \
+ ('%0' + str(num_digits) + 'd') % (i + 1) + '.' + ext
filename = os.path.join(folder, filename)
Expand Down