Closed mxochicale closed 1 year ago
OverlayBaseApp was renamed OverlayBaseWidget from SciKit-SurgeryUtils v1.2.0 so that line needs to be updated to
from sksurgeryutils.common_overlay_apps import OverlayBaseWidget
.
I can't remember if this tutorial has a requirements.txt, but if it does it should then specify scikit-surgeryutils >= 1.2.0
Thanks @thompson318
Current version of requirements says scikit-surgeryutils>=0.6.2
, which will be updated in coming PR. In any case, conda env has "scikit-surgeryutils 1.2.0".
Just run this bit:
import sys
from PySide2.QtWidgets import QApplication
from sksurgeryutils.common_overlay_apps import OverlayBaseWidget
#create an OverlayApp class, that inherits from OverlayBaseWidget
class OverlayApp(OverlayBaseWidget):
def update(self):
#read a new image from the video source
_, image = self.video_source.read()
#copy the image to the overlay window
self.vtk_overlay_window.set_video_image(image)
#and render
self.vtk_overlay_window.Render()
#first we create an application
app = QApplication([])
#then an instance of OverlayApp. The video source
#is set when we create the instance. This is an index
#starting at 0. If you have more than one webcam, you can
#try using different numbered sources
video_source = 0
viewer = OverlayApp(video_source)
#Set a model directory containing the models you wish
#to render and optionally a colours.txt defining the
#colours to render in.
model_dir = '../models'
viewer.add_vtk_models_from_dir(model_dir)
#start the viewer
viewer.start()
#start the application
sys.exit(app.exec_())
$ python vtkoverlay_app.py
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
* Then tried `export QT_QPA_PLATFORM=wayland` not showing anything but
$ export QT_QPA_PLATFORM=wayland $ python vtkoverlay_app.py Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. QSocketNotifier: Can only be used with threads started with QThread X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 12 (X_ConfigureWindow) Resource id in failed request: 0x1 Serial number of failed request: 7 Current serial number in output stream: 8
Any other suggestions?
In the meantime will do a bit of googling.
Thanks
Hi @thompson318
Still working out why I cannot run python vtkoverlay_app.py
under Ubuntu22.04 which might be related to versions of vtk , python and Ubuntu. See few logs.
opencv-contrib-python-headless 4.6.0.66 pypi_0 pypi
python 3.8.13 haa1d7c7_1
scikit-surgeryarucotracker 0.2.7 pypi_0 pypi scikit-surgerycalibration 0.2.1 pypi_0 pypi scikit-surgerycore 0.6.10 pypi_0 pypi scikit-surgeryimage 0.10.1 pypi_0 pypi scikit-surgeryopencvcpp 0.0.10 pypi_0 pypi scikit-surgeryutils 1.2.0 pypi_0 pypi scikit-surgeryvtk 1.0.6 pypi_0 pypi
vtk 9.1.0 pypi_0 pypi
* **py37 with vtk820**
python 3.7.13 haa1d7c7_1
scikit-surgeryarucotracker 0.2.7 pypi_0 pypi scikit-surgerycalibration 0.2.1 pypi_0 pypi scikit-surgerycore 0.6.10 pypi_0 pypi scikit-surgeryimage 0.10.1 pypi_0 pypi scikit-surgeryopencvcpp 0.0.13 pypi_0 pypi scikit-surgeryutils 1.2.0 pypi_0 pypi scikit-surgeryvtk 1.0.6 pypi_0 pypi
vtk 8.2.0 py37haa4764d_200
logs:
python my_example.py
Traceback (most recent call last):
File "/home/mxochicale/anaconda3/envs/scikit-surgeryTUTORIAL01VE/lib/python3.7/site-packages/vtkmodules/vtkCommonCore.py", line 5, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "my_example.py", line 8, in
then I installed - tbb=2021.6.0 but got same error.
* **py37 with vtk<9.0.0**
python 3.7.13 haa1d7c7_1
scikit-surgeryarucotracker 0.2.7 pypi_0 pypi scikit-surgerycalibration 0.2.1 pypi_0 pypi scikit-surgerycore 0.6.10 pypi_0 pypi scikit-surgeryimage 0.10.1 pypi_0 pypi scikit-surgeryopencvcpp 0.0.13 pypi_0 pypi scikit-surgeryutils 1.2.0 pypi_0 pypi scikit-surgeryvtk 1.0.6 pypi_0 pypi scipy 1.7.3 pypi_0 pypi
vtk 8.2.0 py37haa4764d_200
logs
$ python vtkoverlay_app.py
Traceback (most recent call last):
File "/home/mxochicale/anaconda3/envs/scikit-surgeryTUTORIAL01VE/lib/python3.7/site-packages/vtkmodules/vtkIOParallel.py", line 5, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "vtkoverlay_app.py", line 8, in
* **py37 vtk903**
python 3.7.13 haa1d7c7_1
scikit-surgeryarucotracker 0.2.7 pypi_0 pypi scikit-surgerycalibration 0.2.1 pypi_0 pypi scikit-surgerycore 0.6.10 pypi_0 pypi scikit-surgeryimage 0.10.1 pypi_0 pypi scikit-surgeryopencvcpp 0.0.13 pypi_0 pypi scikit-surgeryutils 1.2.0 pypi_0 pypi scikit-surgeryvtk 1.0.6 pypi_0 pypi scipy 1.7.3 pypi_0 pypi
vtk 9.0.3 py37h0649366_201
* logs
python vtkoverlay_app.py
Traceback (most recent call last):
File "/home/mxochicale/anaconda3/envs/scikit-surgeryTUTORIAL01VE/lib/python3.7/site-packages/vtkmodules/vtkIOParallel.py", line 5, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "vtkoverlay_app.py", line 8, in
There's a couple of import errors for libjsoncpp.so.19
ImportError: libjsoncpp.so.19: cannot open shared object file: No such file or directory
Have you tried installing libjsoncpp-dev? i.e.
apt-get install libjsoncpp-dev
- python>3.9
#- cookiecutter>=1.7.3
- numpy
#- numpy>=1.17.4
#- numpy>=1.11
- vtk>9.0
#- vtk=8.2.0
#- vtk<9.0.0
# - vtk=9.1.0
# - vtk #(8.2.0)
# - vtk=9.2.* #ERROR: Cannot uninstall 'vtk'. It is
#- tbb=2021.6.0
#- tbb=2020.2 #https://github.com/NCAR/pyngl/issues/46
# - six>=1.10
# - scipy>=1.7.3
- tox>=3.26.0
- pytest>=7.1.2
- pylint>=2.14.5
- pip>=22.2.2
- pip:
- PySide2
#- PySide2<5.15.0
issues
Using cached shiboken2-5.12.0-5.12.0-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (175 kB) INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C. Collecting PySide2 Using cached PySide2-5.11.1-5.11.1-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (166.5 MB) Using cached PySide2-5.11.0-5.11.0-cp35.cp36-abi3-manylinux1_x86_64.whl (166.4 MB)
Pip subprocess error: ERROR: Ignored the following versions that require a different python version: 5.14.0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.3 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.15.0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4.*, <3.9 ERROR: Could not find a version that satisfies the requirement scikit-surgeryopencvcpp (from scikit-surgerycalibration) (from versions: none) ERROR: No matching distribution found for scikit-surgeryopencvcpp
failed
* Tried py38,vtk>9
issues
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C. Collecting shiboken2==5.12.0 Using cached shiboken2-5.12.0-5.12.0-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (175 kB) INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C. Collecting PySide2 Using cached PySide2-5.11.1-5.11.1-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (166.5 MB) Using cached PySide2-5.11.0-5.11.0-cp35.cp36-abi3-manylinux1_x86_64.whl (166.4 MB)
Pip subprocess error: ERROR: Ignored the following versions that require a different python version: 5.14.0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.3 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.15.0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4.*, <3.9 ERROR: Could not find a version that satisfies the requirement scikit-surgeryopencvcpp (from scikit-surgerycalibration) (from versions: none) ERROR: No matching distribution found for scikit-surgeryopencvcpp
failed
CondaEnvException: Pip failed
* py38, vtk>9
issues
Collecting PySide2<5.15.0 Using cached PySide2-5.11.2-5.11.2-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (166.4 MB) Using cached PySide2-5.11.1-5.11.1-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (166.5 MB) Using cached PySide2-5.11.0-5.11.0-cp35.cp36-abi3-manylinux1_x86_64.whl (166.4 MB) INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.
Pip subprocess error: ERROR: Ignored the following versions that require a different python version: 5.14.0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.3 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.15.0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4.*, <3.9 ERROR: Could not find a version that satisfies the requirement scikit-surgeryopencvcpp (from scikit-surgerycalibration) (from versions: none) ERROR: No matching distribution found for scikit-surgeryopencvcpp
failed
CondaEnvException: Pip failed
* py38,vtk
issues
Using cached shiboken2-5.12.0-5.12.0-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (175 kB) Collecting PySide2<5.15.0 Using cached PySide2-5.11.2-5.11.2-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (166.4 MB) Using cached PySide2-5.11.1-5.11.1-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (166.5 MB) Using cached PySide2-5.11.0-5.11.0-cp35.cp36-abi3-manylinux1_x86_64.whl (166.4 MB) INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.
Pip subprocess error: ERROR: Ignored the following versions that require a different python version: 5.14.0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.14.2.3 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.9; 5.15.0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4.*, <3.9 ERROR: Could not find a version that satisfies the requirement scikit-surgeryopencvcpp (from scikit-surgerycalibration) (from versions: none) ERROR: No matching distribution found for scikit-surgeryopencvcpp
failed
CondaEnvException: Pip failed
* :fire: py37, vtk903, numpy1.21.5
name: scikit-surgeryTUTORIAL01VE channels:
dependencies:
good
numpy 1.21.5 py37h6c91a56_3
numpy-base 1.21.5 py37ha15fc14_3
opencv-contrib-python-headless 4.6.0.66 pypi_0 pypi
python 3.7.13 haa1d7c7_1
scikit-surgeryarucotracker 0.2.7 pypi_0 pypi scikit-surgerycalibration 0.2.1 pypi_0 pypi scikit-surgerycore 0.6.10 pypi_0 pypi scikit-surgeryimage 0.10.1 pypi_0 pypi scikit-surgeryopencvcpp 0.0.13 pypi_0 pypi scikit-surgeryutils 1.2.0 pypi_0 pypi scikit-surgeryvtk 1.0.6 pypi_0 pypi scipy 1.7.3 pypi_0 pypi
vtk 9.0.3 py37h0649366_201
scikit-surgeryopencvcpp is difficult because it uses pre-compiled binaries from c++. We haven't done this for py39. However I'm not sure why this project should require it. Can you work out where the requirement is coming from?
New error:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, xcb.
Aborted (core dumped)
pip uninstall opencv-python
pip install opencv-python-headless
*VE
name: scikit-surgeryTUTORIAL01VE channels:
dependencies:
https://github.com/NVlabs/instant-ngp/discussions/300
*TRIED sudo apt install libxcb-xinerama0
sudo apt install libxcb-xinerama0
[sudo] password for mxochicale:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libxcb-xinerama0 is already the newest version (1.14-3ubuntu3).
Yes, try and use opencv-python-headless wherever possible. When we started we used opencv-python but have been steadily trying to remove it from all our libraries. It comes with it's version of the qt library which may conflict with the one installed by PySide.
I tried opencv-python-headless
but not success, so trying to figure it out the right ingredients for versions of vtk, Qt, PySide, etc.
sudo apt-get install libjsoncpp-dev
and testsudo apt-get install xvfb libxkbcommon-x11-0
but still get:
$ python vtkoverlay_app.py
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, xcb.
Aborted (core dumped)
$ python vtkoverlay_app.py
Traceback (most recent call last):
File "/home/mxochicale/anaconda3/envs/scikit-surgeryTUTORIAL01VE/lib/python3.7/site-packages/vtkmodules/vtkCommonCore.py", line 5, in <module>
from .vtkCommonCorePython import *
ImportError: libtbb.so.2: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "vtkoverlay_app.py", line 8, in <module>
from sksurgeryutils.common_overlay_apps import OverlayBaseWidget
File "/home/mxochicale/anaconda3/envs/scikit-surgeryTUTORIAL01VE/lib/python3.7/site-packages/sksurgeryutils/common_overlay_apps.py", line 15,
tried "Solution: Manually install libtbb. This command worked for me “conda install tbb tbb-devel tbb4py” although it is likely that only ‘tbb’ is required. " https://groups.google.com/g/pylidar/c/O6G1lE-9dqo
ImportError: libtbb.so.2: cannot open shared object file: No such file or directory
Then: sudo apt-get install libtbb2
Traceback (most recent call last):
File "/home/mxochicale/anaconda3/envs/scikit-surgeryTUTORIAL01VE/lib/python3.7/site-packages/vtkmodules/vtkIOParallel.py", line 5, in <module>
from .vtkIOParallelPython import *
ImportError: libjsoncpp.so.19: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "vtkoverlay_app.py", line 8, in <module>
Then tried: sudo apt-get install libjsoncpp-dev
https://study-grow.tistory.com/entry/ImportError-libtbbso2-%EC%98%A4%EB%A5%98
python vtkoverlay_app.py
Traceback (most recent call last):
File "/home/mxochicale/anaconda3/envs/scikit-surgeryTUTORIAL01VE/lib/python3.7/site-packages/vtkmodules/vtkIOParallel.py", line 5, in <module>
from .vtkIOParallelPython import *
ImportError: libjsoncpp.so.19: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
:+1: : After rebooting, the application seems to run in the background and activate the camera but I don't see any windows!
python vtkoverlay_app.py
Traceback (most recent call last):
File "/home/mxochicale/anaconda3/envs/scikit-surgeryTUTORIAL01VE/lib/python3.7/site-packages/vtkmodules/vtkIOParallel.py", line 5, in <module>
from .vtkIOParallelPython import *
ImportError: libjsoncpp.so.19: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
* tried py37, vtk8.1.2, etc from https://github.com/conda-forge/mayavi-feedstock/issues/33
the application seems to run in the background and activate the camera but I don't see any windows!
* tried py38, vtk8.1.2, etc from https://github.com/conda-forge/mayavi-feedstock/issues/33
conda env create -f scikit-surgeryTUTORIAL01VE.yml Collecting package metadata (repodata.json): done Solving environment: | Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort.
THEN
#
conda env create -f scikit-surgeryTUTORIAL01VE.yml Collecting package metadata (repodata.json): done Solving environment: \ Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort.
Let's reboot and try again with installed py37, vtk8.1.2, etc from https://github.com/conda-forge/mayavi-feedstock/issues/33
Trying latest merged in Ubuntu 18.04 but
(scikit-surgerytutorial01VE) miguel@smartliveri4i-Alienware-13-R3:~/repositories/SciKit-Surgery/scikit-surgerytutorial01/sksurgerytutorial01$ python vtk_aruco_app.py
Traceback (most recent call last):
File "vtk_aruco_app.py", line 9, in <module>
from PySide2.QtWidgets import QApplication
ImportError: /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2: symbol krb5_ser_context_init version krb5_3_MIT not defined in file libkrb5.so.3 with link time reference
tried > https://stackoverflow.com/questions/63186438/pyside2-installation-problem-on-ubuntu18-04-python-3-8-3-on-anaconda
conda install -c conda-forge pyside2
but taking more than 15 minutes to solve env, so just cancel. will try again next time when I have access to Alienware-13-R3 with ubuntu1804
I am not able to see the window showing live video from webcam while running the vtkoverlay_app.py . I am using ubuntu 20.04 and have created a virtual environment with python3.7 and installed scikit-surgeryutils 1.2.0. The issue is: I am not seeing anything but the python process is still running. Is there anything I have to look into to work with tutorial 1?
Hi @shrestha1
Thanks for your message. I would suggest to opening a new issue to help you to track the problem. Please replicate the latest version of the tutorial using the suggested conda env: https://scikit-surgerytutorial01.readthedocs.io/en/latest/index.html for which vtk_aruco_app.py
, vtkoverlay_app.py
, vtkoverlay_with_movement_app.py
are running fine under ubuntu 22.04.
Thanks
Hello @shrestha1, this sounds like an issue with vtk we have on ubuntu, see https://github.com/SciKit-Surgery/scikit-surgeryvtk/issues/181. We are working to resolve this, but in the meantime if you add vtk<9 to your requirements.txt file it will probably fix your problem.
@thompson318 I think I solved this issue for ubuntu20.04 with some changes made on the vtk_overlay_window.py and QVTRenderWindowInteractor.py degrading the vtk version to 8.1.2. in python3.7 virtual environment.
@mxochicale Thank you for your advice. I will do it next time for sure.
Closing this one as it was sorted out here https://github.com/SciKit-Surgery/scikit-surgerytutorial01/pull/32
Hi @thompson318
I am following tutorial "Making a simple model overlay application" but it seems that I am not running the right version of sksurgeryutils in python3.7 in Ubuntu 22.04.1 LTS.
Any suggestions?
Miscellaneous
Perhaps the following can be improved in coming branch>PR:
vtkoverlay_app.py
from sksurgeryutils.common_overlay_apps import OverlayBaseWidget.