cvui 2.7.0 is out! OpenCV GUI in Python
I am pleased to inform that version 2.7.0 of cvui is out! cvui is a simple UI lib built on top of OpenCV drawing primitives.
This release contains bug fixes and the addition of a pure Python implementation of cvui, i.e. cvui.py
. The Python port of cvui has been conceived and developed with the aim of achieving a 1-to-1 match regarding the already existing C++ API. As a consequence, functions and parameters names were kept the same, so existing C++ documentation should apply to Python with minor changes.
From now on, all computer vision developers out there working with Python can add UI components to their applications in an extremely easy way. The Python port of cvui is available via PyPy, so it is a pip
command away. Just run:
pip install cvui
and you are ready to go. As simple as cvui itself.
cvui.py
also aims to be a “header-only” file, so all you have to do is add it to your project if you are not using any package manager. Here is a simple example of the Python usage of cvui:
import numpy as np
import cv2
import cvui
WINDOW_NAME = 'CVUI Test'
cvui.init(WINDOW_NAME)
# Create a frame
frame = np.zeros((200, 400, 3), np.uint8)
while True:
# clear the frame
frame[:] = (49, 52, 49)
# render a message in the frame at position (10, 15)
# then show it on the screen
cvui.text(frame, 10, 15, 'Hello world!')
cvui.imshow(WINDOW_NAME, frame)
if cv2.waitKey(20) == 27:
break
All code examples are now also available in Python. The C++ version of cvui makes heavy use of parameters overloading, which is a problem in Python. To ensure good documentation and proper code auto-completion for cvui in Python IDEs, cvui.py
has several dummy/wrapping functions. They have a proper list of arguments instead of a single *args
parameter. It should provide a good user experience without causing any problems.
Finally, I would like to highlight the addition of new code examples, particularly the ui-enhanced-*
ones. They show how to improve existing cvui components, e.g. make a window movable and minimizable. Documentation pages have also been tweaked to accommodate information regarding the newly added Python support.
Below is a list of changes according to the CHANGELOG. Thank you to all contributors that have helped improve cvui!
Added
- Python implementation of cvui, i.e.
cvui.py
(read more) - Python examples ported from the already existing C++ ones.
- New ui-enhanced-* examples, e.g. moving settings window (#41, #36, help from Amaury Bréhéret and ShengYu).
- Cmake option
ADD_PYTHON_EXAMPLES
to control the build of Python examples (read more).
Changed
- Documentation tweaks (help from ShengYu and Akash Kumar Singh).
- Cmake version
3.1
or higher is now required to build the examples. - Cmake files were improved.
rect()
color filling now supports alpha values, e.g.0x7700ff00
(blue with 50% transparency) (#39, help from Justin Muncaster).
Fixed
rect()
issue related to opacity (#42, help from Justin Muncaster).- Conflict with
dirent.h
andmin()/max()
macros on Windows (#38, help from Ali Zarei).