Skip to content

Commit

Permalink
Add shutter_speed/wait before capture in record.
Browse files Browse the repository at this point in the history
The rendering needs some time to settle after moving the camera.
This adds a sleep after moving to the next camera position and
before capturing.
  • Loading branch information
floroeske committed Apr 23, 2020
1 parent 697c09a commit 466a7e5
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 466a7e5

Please sign in to comment.