From 89ba085f9da7c3a7fef0eee92e4360ccee5092ab Mon Sep 17 00:00:00 2001 From: Ilya Gruzinov Date: Wed, 18 Nov 2020 15:32:58 +0300 Subject: [PATCH] Fix #81: Calibration didnt passed to captures received in playback module (#82) * Fix #81: Calibration didnt passed to captures received in playback module * Add comment * Small fix to k4a_module * Experiment with cache * Experiment with cache * Remove warning * Add debug messages * More logging * Revert module changes * test * Debug * Revert changes * Revert changes * Formatter --- pyk4a/playback.py | 4 ++-- tests/functional/test_playback.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/pyk4a/playback.py b/pyk4a/playback.py index e969c83..424324d 100644 --- a/pyk4a/playback.py +++ b/pyk4a/playback.py @@ -155,7 +155,7 @@ def get_next_capture(self): result, capture_handle = k4a_module.playback_get_next_capture(self._handle, self.thread_safe) self._verify_stream_error(result) return PyK4ACapture( - calibration=self._calibration, + calibration=self.calibration, capture_handle=capture_handle, color_format=self.configuration["color_format"], thread_safe=self.thread_safe, @@ -166,7 +166,7 @@ def get_previouse_capture(self): result, capture_handle = k4a_module.playback_get_previous_capture(self._handle, self.thread_safe) self._verify_stream_error(result) return PyK4ACapture( - calibration=self._calibration, + calibration=self.calibration, capture_handle=capture_handle, color_format=self.configuration["color_format"], thread_safe=self.thread_safe, diff --git a/tests/functional/test_playback.py b/tests/functional/test_playback.py index e1cef48..13af5d1 100644 --- a/tests/functional/test_playback.py +++ b/tests/functional/test_playback.py @@ -103,3 +103,24 @@ def test_seek_by_device_time(playback: PyK4APlayback): playback.seek(1, origin=SeekOrigin.DEVICE_TIME) # TODO add correct timestamp from datablock here capture = playback.get_next_capture() assert capture.color is not None + + +class TestGetCapture: + @staticmethod + def test_get_next_capture(playback: PyK4APlayback): + playback.open() + capture = playback.get_next_capture() + assert capture is not None + assert capture.depth is not None + assert capture.color is not None + assert capture._calibration is not None # Issue #81 + + @staticmethod + def test_get_previouse_capture(playback: PyK4APlayback): + playback.open() + playback.seek(0, origin=SeekOrigin.END) + capture = playback.get_previouse_capture() + assert capture is not None + assert capture.depth is not None + assert capture.color is not None + assert capture._calibration is not None # Issue #81