From ea8eced67dc75b90eef6f79a7134a5a447cce4d0 Mon Sep 17 00:00:00 2001 From: Miguel Xochicale Date: Fri, 5 Jul 2024 15:40:11 +0100 Subject: [PATCH] fixes #37 --- doc/00_Introduction.rst | 64 ++++--------------- requirements-dev.txt | 1 - requirements.txt | 6 +- sksurgerytutorial01/vtk_aruco_app.py | 15 +++-- sksurgerytutorial01/vtkoverlay_app.py | 15 +++-- .../vtkoverlay_with_movement_app.py | 15 +++-- tests/conftest.py | 4 +- tests/test_sksurgerytorial01.py | 7 +- 8 files changed, 54 insertions(+), 73 deletions(-) diff --git a/doc/00_Introduction.rst b/doc/00_Introduction.rst index a1c43e6..57b4f99 100644 --- a/doc/00_Introduction.rst +++ b/doc/00_Introduction.rst @@ -42,62 +42,24 @@ guide the user in creating an augmented reality application in around 70 lines o Installation ~~~~~~~~~~~~ -Step 1: -You'll need SciKit-SurgeryUtils installed on your system. Provided you have Python installed on -your system you should be able to run ... -:: - - pip install scikit-surgeryutils - -to install SciKit-SurgeryUtils and its dependencies (including SciKit-SurgeryCore). -For the third part of the tutorial you'll also need SciKit-SurgeryArUcoTracker - -:: - pip install scikit-surgeryarucotracker +Packages, other requirements, and virtual environments +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If you don't have Python installed, we -recommend downloading an installer for your platform directly from `python.org`_. - -Virtual environments +Python virtual environments ~~~~~~~~~~~~ Virtualenv, venv, conda or pyenv can be used to create virtual environments to manage python packages. -You can use conda env by installing conda for your OS (`conda_installation`_) and use the following yml file with all dependencies. +If you don't have Python installed, we recommend downloading an installer for your platform directly from `python.org`_. +For the case of conda, please create a VE using the following commands in your terminal: + :: - ## Create scikit-surgerytutorial01VE.yml in your favorite location with the following content: - ## - ## scikit-surgerytutorial01VE.yml - ## - ## Some useful commands to manage your conda env: - ## LIST CONDA ENVS: conda list -n *VE # show list of installed packages - ## UPDATE CONDA: conda update -n base -c defaults conda - ## INSTALL CONDA EV: conda env create -f *VE.yml - ## UPDATE CONDA ENV: conda env update --file *VE.yml --prune - ## ACTIVATE CONDA ENV: conda activate *VE - ## REMOVE CONDA ENV: conda remove -n *VE --all - - name: scikit-surgerytutorial01VE - channels: - - defaults - - conda-forge #vtk; tox; - - anaconda #coverage; scipy; - dependencies: - - python=3.7 - - numpy>=1.17.4 - - vtk=8.1.2 - - tox>=3.26.0 - - pytest>=7.1.2 - - pylint>=2.14.5 - - pip>=22.2.2 - - pip: - - PySide2>=5.14.2.3 - - scikit-surgerycore>=0.1.7 - - scikit-surgeryutils>=1.2.0 - - scikit-surgeryarucotracker>=0.1.1 - - opencv-python-headless - -Step 2: -You should now be able to follow the tutorial, using the code snippets contained herein. + + conda update -n base -c defaults conda + conda create -n sst01VE python=3.8 pip -c conda-forge #try3.7 + conda activate sst01VE + pip install -r requirements.txt + pip install -r requirements-dev.txt + .. _`python.org`: https://www.python.org/downloads/ .. _`SmartLiver`: https://link.springer.com/article/10.1007/s11548-018-1761-3 diff --git a/requirements-dev.txt b/requirements-dev.txt index baa086b..5cc162c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,6 @@ # for development. # It is used by pip to manage software dependencies. It is not to be # confused with the software requirements, which are listed in -# doc/requirements.rst -r requirements.txt coverage mock diff --git a/requirements.txt b/requirements.txt index 4fc3e80..103caac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,9 @@ # confused with the software requirements, which are listed in # doc/requirements.rst numpy>=1.17.4 -PySide2 +vtk>=9.2.6 +PySide6>=6.5.1.1 +opencv-contrib-python-headless>=4.2.0.32 scikit-surgerycore>=0.1.7 scikit-surgeryutils>=1.2.0 -scikit-surgeryarucotracker>= 0.2.7 \ No newline at end of file +scikit-surgeryarucotracker>= 0.2.7 diff --git a/sksurgerytutorial01/vtk_aruco_app.py b/sksurgerytutorial01/vtk_aruco_app.py index ddd3cbe..6c90c06 100644 --- a/sksurgerytutorial01/vtk_aruco_app.py +++ b/sksurgerytutorial01/vtk_aruco_app.py @@ -1,12 +1,15 @@ -# coding=utf-8 +""" +Script to create a viewer window with a movable surface +model overlaid in a live video feed -"""Script to create a viewer window with a movable surface -model overlaid in a live video feed""" +USAGE: +python vtk_aruco_app.py +""" import sys #add an import for numpy, to manipulate arrays import numpy -from PySide2.QtWidgets import QApplication +from PySide6.QtWidgets import QApplication from sksurgeryutils.common_overlay_apps import OverlayBaseWidget from sksurgerycore.transforms.transform_manager import TransformManager from sksurgeryarucotracker.arucotracker import ArUcoTracker @@ -60,6 +63,8 @@ def update_view(self): #see what happens. self.vtk_overlay_window.set_camera_state({"ClippingRange": [10, 800]}) self.vtk_overlay_window.set_video_image(image) + self.vtk_overlay_window.Initialize() # Allows the interactor to initialize itself. + self.vtk_overlay_window.Start() # Start the event loop. self.vtk_overlay_window.Render() def _aruco_detect_and_follow(self, image): @@ -104,4 +109,4 @@ def _move_camera(self, tag2camera): viewer.show() viewer.start() - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/sksurgerytutorial01/vtkoverlay_app.py b/sksurgerytutorial01/vtkoverlay_app.py index 7deb70f..785d48c 100644 --- a/sksurgerytutorial01/vtkoverlay_app.py +++ b/sksurgerytutorial01/vtkoverlay_app.py @@ -1,10 +1,13 @@ -# coding=utf-8 +""" +Script to create a viewer window with a static surface +model overlaid in a live video feed -"""Script to create a viewer window with a static surface -model overlaid in a live video feed""" +USAGE: +python vtkoverlay_app.py +""" import sys -from PySide2.QtWidgets import QApplication +from PySide6.QtWidgets import QApplication from sksurgeryutils.common_overlay_apps import OverlayBaseWidget #create an OverlayApp class, that inherits from OverlayBaseApp @@ -16,6 +19,8 @@ def update_view(self): and render""" _, image = self.video_source.read() self.vtk_overlay_window.set_video_image(image) + self.vtk_overlay_window.Initialize() # Allows the interactor to initialize itself. + self.vtk_overlay_window.Start() # Start the event loop. self.vtk_overlay_window.Render() #the following line prevents the code below from running unless @@ -43,4 +48,4 @@ def update_view(self): viewer.start() #start the application - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/sksurgerytutorial01/vtkoverlay_with_movement_app.py b/sksurgerytutorial01/vtkoverlay_with_movement_app.py index 1e611fa..562769d 100644 --- a/sksurgerytutorial01/vtkoverlay_with_movement_app.py +++ b/sksurgerytutorial01/vtkoverlay_with_movement_app.py @@ -1,10 +1,13 @@ -# coding=utf-8 +""" +Script to create a viewer window with a moving surface +model overlaid in a live video feed -"""Script to create a viewer window with a moving surface -model overlaid in a live video feed""" +USAGE: +python vtkoverlay_with_movement_app.py +""" import sys -from PySide2.QtWidgets import QApplication +from PySide6.QtWidgets import QApplication from sksurgeryutils.common_overlay_apps import OverlayBaseWidget class OverlayApp(OverlayBaseWidget): @@ -20,6 +23,8 @@ def update_view(self): self._move_model() self.vtk_overlay_window.set_video_image(image) + self.vtk_overlay_window.Initialize() # Allows the interactor to initialize itself. + self.vtk_overlay_window.Start() # Start the event loop. self.vtk_overlay_window.Render() def _move_model(self): @@ -48,4 +53,4 @@ def _move_model(self): viewer.show() viewer.start() - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/tests/conftest.py b/tests/conftest.py index e87f0d5..316a666 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- import pytest -from PySide2.QtWidgets import QApplication +from PySide6.QtWidgets import QApplication @pytest.fixture(scope="session") def setup_qt(): """ Create the QT application. """ app = QApplication([]) - return app \ No newline at end of file + return app diff --git a/tests/test_sksurgerytorial01.py b/tests/test_sksurgerytorial01.py index 0c841b5..78b8274 100644 --- a/tests/test_sksurgerytorial01.py +++ b/tests/test_sksurgerytorial01.py @@ -1,6 +1,9 @@ -# coding=utf-8 +""" +sksurgerytutorial01 vtkoverlay tests -"""sksurgerytutorial01 vtkoverlay tests""" +USAGE: +python -m pytest -v -s tests +""" import pytest