Commit b0d2fcbc authored by Thomas Dowrick's avatar Thomas Dowrick

Move DuplicateOverlayWindow from surgery-davinci

parent f44f12fd
Pipeline #1926 failed with stages
in 3 minutes and 50 seconds
......@@ -149,3 +149,49 @@ class OverlayOnVideoFeedCropRecord(OverlayBaseApp):
self.save_frame = False
self.video_writer.close()
logging.debug("Recording stopped.")
class DuplicateOverlayWindow(OverlayOnVideoFeedCropRecord):
"""
Set the background of vtk_overlay_window to duplicate
that of another vtk_overlay_window.
Example usage:
video_source = 0
source_window = OverlayOnVideoFeedCropRecord(video_source)
duplicate_window = DuplicateOverlayWindow()
duplicate_window.set_source_window(source_window)
"""
def __init__(self):
#pylint: disable=super-init-not-called
self.vtk_overlay_window = VTKOverlayWindow()
self.update_rate = 30
self.img = None
self.timer = None
self.source_window = None
def set_source_window(self, source_window):
""" Set the source window.
:param source_window: The window that contains the image to copy. """
self.source_window = source_window
def update(self):
""" Update the frame with a new background image."""
self.img = self.source_window.vtk_overlay_window.input
self.vtk_overlay_window.set_video_image(self.img)
self.vtk_overlay_window._RenderWindow.Render()
def on_record_start(self):
""" Don't want to call the base class version, so override."""
def on_record_stop(self):
""" Don't want to call the base class version, so override."""
def set_roi(self):
""" Don't want to call the base class version, so override."""
......@@ -98,5 +98,29 @@ def test_OverlayOnVideoFeedCropRecord_set_roi(mock_crop, setup_qt):
expected_shape = (roi[1][0] - roi[0][0], roi[1][1] - roi[0][1])
assert overlay_app.vtk_overlay_window.input.shape[:2] == expected_shape
def test_DuplicateOverlayWindow(setup_qt):
input_file = 'tests/data/100x50_100_frames.avi'
overlay_app = coa.OverlayOnVideoFeed(input_file)
duplicate = coa.DuplicateOverlayWindow()
duplicate.set_source_window(overlay_app)
overlay_app.update()
duplicate.update()
np.testing.assert_array_equal(overlay_app.img, duplicate.vtk_overlay_window.input)
def test_DuplicateOverlayWindowWithCrop(setup_qt):
input_file = 'tests/data/100x50_100_frames.avi'
overlay_app = coa.OverlayOnVideoFeedCropRecord(input_file)
duplicate = coa.DuplicateOverlayWindow()
duplicate.set_source_window(overlay_app)
overlay_app.update()
duplicate.update()
np.testing.assert_array_equal(overlay_app.img, duplicate.vtk_overlay_window.input)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment