imshowTk

Author: Stephen Thompson
imshowTk is a zero dependency alternative to opencv’s imshow function. It was developed to allow us to show an image window when using opencv-headless and don’t want to use a larger UI library. It uses tkinter which comes as standard in most Python installations.
imshowTk is part of the SciKit-Surgery software project, developed at the Wellcome EPSRC Centre for Interventional and Surgical Sciences, part of University College London (UCL).
Basic use case
from from imshowtk.imshowtk import ImshowTk
imshow = ImshowTk()
frame = cv2.imread('project-icon.png')
imshow.imshow(frame)
del imshow
Developing
Cloning
You can clone the repository using the following command:
git clone https://github.com/SciKit-Surgery/imshowTk
Running tests
Pytest is used for running unit tests:
pip install pytest
python -m pytest
Linting
This code conforms to the PEP8 standard. Pylint can be used to analyse the code:
pip install pylint
pylint --rcfile=tests/pylintrc imshowtk
Installing
You can pip install directly from the repository as follows:
pip install git+https://github.com/SciKit-Surgery/imshowTk
Contributing
Please see the contributing guidelines.
Useful links
Licensing and copyright
Copyright 2023 University College London. imshowTk is released under the BSD-3 license. Please see the license file for details.
Acknowledgements
Supported by Wellcome and EPSRC.
latest
exampleUsages module
imshowtk package
Submodules
imshowtk.imshowtk module
A class to bring up a debugging window
- class imshowtk.imshowtk.ImshowTk(in_use=True, subsample=1)[source]
Bases:
object
Creates a window using TkInter, into which we can place an opencv image. Conceived as a zero dependency alternative to opencv’s imshow window, for when we want to use opencv-headless or avoid conflict with Qt.
- imshowtk.imshowtk.bitmap_to_photo(bitmap, subsample=1)[source]
converts a 3 channel numpy array image into a tkinter photoImage suitable for putting into tk widget https://stackoverflow.com/questions/1581799/ how-to-draw-a-bitmap-real-quick-in-python-using-tk-only
- Parameters:
bitmap – The bitmap image, taken from opencv as a 3 channel numpy array
subsample – You can optionally subsample the image which might be useful if you want it to run faster. A value of n will give an nxn speed up as we use 2 loops to convert the image.
Module contents
imshowTk