Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 13 additions & 51 deletions doc/00_Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
thompson318 marked this conversation as resolved.
Outdated


.. _`python.org`: https://www.python.org/downloads/
.. _`SmartLiver`: https://link.springer.com/article/10.1007/s11548-018-1761-3
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
scikit-surgeryarucotracker>= 0.2.7
15 changes: 10 additions & 5 deletions sksurgerytutorial01/vtk_aruco_app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -104,4 +109,4 @@ def _move_camera(self, tag2camera):
viewer.show()
viewer.start()

sys.exit(app.exec_())
sys.exit(app.exec())
15 changes: 10 additions & 5 deletions sksurgerytutorial01/vtkoverlay_app.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -43,4 +48,4 @@ def update_view(self):
viewer.start()

#start the application
sys.exit(app.exec_())
sys.exit(app.exec())
15 changes: 10 additions & 5 deletions sksurgerytutorial01/vtkoverlay_with_movement_app.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -48,4 +53,4 @@ def _move_model(self):
viewer.show()
viewer.start()

sys.exit(app.exec_())
sys.exit(app.exec())
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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
return app
7 changes: 5 additions & 2 deletions tests/test_sksurgerytorial01.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# coding=utf-8
"""
sksurgerytutorial01 vtkoverlay tests

"""sksurgerytutorial01 vtkoverlay tests"""
USAGE:
python -m pytest -v -s tests
"""

import pytest

Expand Down