• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SciKit-Surgery / scikit-surgerytutorial01 / 10090860352

25 Jul 2024 08:34AM UTC coverage: 35.714% (+26.5%) from 9.218%
10090860352

Pull #38

github

web-flow
Update doc/00_Introduction.rst
Pull Request #38: 37 - Resolving QWidget issues

1 of 24 new or added lines in 3 files covered. (4.17%)

27 existing lines in 3 files now uncovered.

30 of 84 relevant lines covered (35.71%)

0.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.0
/sksurgerytutorial01/vtkoverlay_with_movement_app.py
1
"""
2
Script to create a viewer window with a moving surface
3
model overlaid in a live video feed
4

5
USAGE:
6
python vtkoverlay_with_movement_app.py
7
"""
8

UNCOV
9
import sys
2✔
NEW
10
from PySide6.QtWidgets import QApplication
2✔
UNCOV
11
from sksurgeryutils.common_overlay_apps import OverlayBaseWidget
2✔
12

UNCOV
13
class OverlayApp(OverlayBaseWidget):
2✔
14
    """Inherits from OverlayBaseWidget, and adds a minimal
15
    implementation of update_view. """
16

UNCOV
17
    def update_view(self):
2✔
18
        """Update the background renderer with a new frame,
19
        move the model and render"""
20
        _, image = self.video_source.read()
×
21

22
        #add a method to move the rendered models
23
        self._move_model()
×
24

25
        self.vtk_overlay_window.set_video_image(image)
×
26
        # Allows the interactor to initialize itself.
NEW
27
        self.vtk_overlay_window.Initialize()
×
NEW
28
        self.vtk_overlay_window.Start()  # Start the event loop.
×
UNCOV
29
        self.vtk_overlay_window.Render()
×
30

UNCOV
31
    def _move_model(self):
2✔
32
        """Internal method to move the rendered models in
33
        some interesting way"""
34
        #Iterate through the rendered models
35
        for actor in \
×
36
                self.vtk_overlay_window.get_foreground_renderer().GetActors():
37
            #get the current orientation
38
            orientation = actor.GetOrientation()
×
39
            #increase the rotation around the z-axis by 1.0 degrees
40
            orientation = [orientation[0], orientation[1], orientation[2] + 1.0]
×
41
            #add update the model's orientation
42
            actor.SetOrientation(orientation)
×
43

44

UNCOV
45
if __name__ == '__main__':
2✔
46
    app = QApplication([])
×
47

NEW
48
    VIDEO_SOURCE = 0
×
NEW
49
    viewer = OverlayApp(VIDEO_SOURCE)
×
50

NEW
51
    MODEL_DIR = '../models'
×
NEW
52
    viewer.add_vtk_models_from_dir(MODEL_DIR)
×
53

54
    viewer.show()
×
55
    viewer.start()
×
56

NEW
57
    sys.exit(app.exec())
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc